提交 8e645976 作者: 张小凤

AppletMsg(update)

上级 da73b547
......@@ -13,6 +13,23 @@
<dependencies>
<!-- 微信支付相关 -->
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.9</version>
</dependency>
<dependency>
<groupId>com.github.wxpay</groupId>
<artifactId>wxpay-sdk</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-java</artifactId>
<version>0.2.10</version>
</dependency>
<!-- apache 提供的一些工具类 -->
<dependency>
<groupId>commons-codec</groupId>
......
package com.mmc.csf.infomation.vo;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author small
* @Date 2023/8/24 10:49
* @Version 1.0
*/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AppletMsgVOS implements Serializable {
private static final long serialVersionUID = 2124104608303700492L;
@ApiModelProperty(value = "openid")
@NotBlank
private String touser;
@ApiModelProperty(value = "模板ID")
@NotBlank
private String template_id;
@ApiModelProperty(value = "点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。")
private String page;
@ApiModelProperty(value = "模板内容")
private JSONObject data;
@ApiModelProperty(value = "跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版")
private String miniprogram_state;
@ApiModelProperty(value = "默认为zh_CN")
private String lang;
}
package com.mmc.csf.infomation.vo;
import com.wechat.pay.java.service.refund.model.GoodsDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @Author small
* @Date 2023/8/24 14:09
* @Version 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApplyRefundVO {
@ApiModelProperty(value = "商户订单号", required = true)
private String outTradeNo;
@ApiModelProperty(value = "退款原因")
private String reason;
@ApiModelProperty(value = "退款金额", required = true)
private Long refund;
@ApiModelProperty(value = "商品信息(可填可不填)")
private List<GoodsDetail> goodsDetail;
}
package com.mmc.csf.release.auth.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -7,23 +8,25 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author 作者 geDuo
* @version 创建时间:2021年8月31日 下午8:06:14
* @explain 类说明
*/
/**
* @author 作者 geDuo
* @version 创建时间:2021年8月31日 下午8:06:14
* @explain 类说明
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LoginSuccessDTO implements Serializable {
private static final long serialVersionUID = -1200834589953161925L;
private String token;
private Integer userAccountId;
private String accountNo;
private String uid;
private String phoneNum;
private String userName;
private String nickName;
private static final long serialVersionUID = -1200834589953161925L;
private String token;
private Integer userAccountId;
private String accountNo;
private String uid;
private String phoneNum;
private String userName;
private String nickName;
@ApiModelProperty(value = "openid")
private String openid;
// private RoleInfoDTO roleInfo;
}
package com.mmc.csf.release.constant;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
/**
* @Author small
* @Date 2023/8/24 13:28
* @Version 1.0
*/
public class HttpsOpenUtil {
/**
* http请求
*
* @param url 发送请求的URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return URL 所代表远程资源的响应结果
* @category 向指定URL发送GET方法的请求
*/
public static String httpSendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
// for (String key : map.keySet()) {
// System.out.println(key + "--->" + map.get(key));
// }
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
/**
* http请求
*
* @param url 发送请求的 URL
* @return 所代表远程资源的响应结果
* @category 向指定URL 发送POST方法的请求
*/
public static String httpSendPost(String url, String param) {
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 发送POST请求必须设置如下两行
conn.setDoOutput(true);
conn.setDoInput(true);
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
// 定义BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送 POST 请求出现异常!" + e);
e.printStackTrace();
}
// 使用finally块来关闭输出流、输入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result;
}
}
package com.mmc.csf.release.constant;
import com.alibaba.fastjson.JSONObject;
import com.mmc.csf.common.util.json.JsonUtil;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Map;
/**
* @Author small
* @Date 2023/8/24 13:27
* @Version 1.0
*/
public class WxApiUtilS {
// 与接口配置信息中的Token要一致
private static final String token = "MMCDingYueHaoToken2020";
public static boolean checkSignature(String signature, String timestrap, String nonce) {
String[] arr = new String[]{token, timestrap, nonce};
// 将token、timestamp、nonce三个参数进行字典序排序
Arrays.sort(arr);
StringBuffer buf = new StringBuffer();
for (int i = 0; i < arr.length; i++) {
buf.append(arr[i]);
}
String temp = getSha1(buf.toString());
return temp.equals(signature);
}
public static String getSha1(String str) {
if (null == str || str.length() == 0) {
return null;
}
char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
try {
MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
mdTemp.update(str.getBytes("UTF-8"));
byte[] md = mdTemp.digest();
int j = md.length;
char[] buf = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byTemp = md[i];
buf[k++] = hexDigits[byTemp >>> 4 & 0xf];
buf[k++] = hexDigits[byTemp & 0xf];
}
return new String(buf);
} catch (Exception e) {
return null;
}
}
/**
* 截取模板长度
*/
public static JSONObject buildMsgJson(JSONObject jsonObject) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
if (entry.getKey().startsWith("thing") && entry.getValue() != null) {
String json = JsonUtil.parseObjToJson(entry.getValue());
JSONObject obj = JSONObject.parseObject(json);
String str = obj.getString("value");
if (str.length() > 20) {
obj.put("value", str.substring(0, 17) + "...");
entry.setValue(obj);
}
}
if (entry.getKey().startsWith("phrase") && entry.getValue() != null) {
String json = JsonUtil.parseObjToJson(entry.getValue());
JSONObject obj = JSONObject.parseObject(json);
String str = obj.getString("value");
if (str.length() > 5) {
obj.put("value", str.substring(0, 5));
entry.setValue(obj);
}
}
if (entry.getKey().startsWith("character_string") && entry.getValue() != null) {
String json = JsonUtil.parseObjToJson(entry.getValue());
JSONObject obj = JSONObject.parseObject(json);
String str = obj.getString("value");
if (str.length() > 32) {
obj.put("value", str.substring(0, 29) + "...");
entry.setValue(obj);
}
}
}
return jsonObject;
}
}
package com.mmc.csf.release.constant;
/**
* @Author small
* @Date 2023/8/24 13:29
* @Version 1.0
*/
public class WxMsgTemplete {
public static final String INDEMNIFY_FOR_PUBLICATION = "0C9uqQymP4k4qiYRA4r-sEHXti_yd3PjHjGMezuGOtc";
}
......@@ -215,7 +215,7 @@ public class RequirementsController extends BaseController {
@PostMapping("droneFlyerCancel")
public ResultBody droneFlyerCancel(HttpServletRequest request, @ApiParam(value = "发布服务需求id", required = true) @RequestParam Integer requirementsInfoId) {
Integer userAccountId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
return requirementsService.droneFlyerCancel(requirementsInfoId, userAccountId);
return requirementsService.droneFlyerCancel(requirementsInfoId, userAccountId, request);
}
@ApiOperation(value = "new——小程序-—发布者单方便取消订单")
......@@ -223,7 +223,7 @@ public class RequirementsController extends BaseController {
@PostMapping("publisherCancel")
public ResultBody publisherCancel(HttpServletRequest request, @ApiParam(value = "发布服务需求id", required = true) @RequestParam Integer requirementsInfoId) {
Integer userAccountId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
return requirementsService.publisherCancel(requirementsInfoId, userAccountId);
return requirementsService.publisherCancel(requirementsInfoId, userAccountId, request);
}
@ApiOperation(value = "new——小程序-—结算:发布者修改任务佣金")
......
......@@ -119,6 +119,19 @@ public class RequirementsInfoDO implements Serializable {
@ApiModelProperty(value = "原因url")
private String url;
@ApiModelProperty(value = "微信支付订单编号")
private String wechatPayOrderNumber;
@ApiModelProperty(value = "发布者支付任务佣金 佣金金额")
private BigDecimal cashAmount;
private BigDecimal weChat;
private BigDecimal salaryAmount;
public RequirementsInfoVO buildRequirementsInfoVO() {
return RequirementsInfoVO.builder().id(this.id).requirementTypeId(this.requirementTypeId).userAccountId(this.userAccountId).publishName(this.publishName)
......
package com.mmc.csf.release.entity.requirements;
import com.alibaba.fastjson.annotation.JSONField;
import com.mmc.csf.config.IsNullConvertZero;
import com.mmc.csf.infomation.dto.PilotCertificationInteriorDTO;
import io.swagger.annotations.ApiModelProperty;
......@@ -9,6 +10,7 @@ import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author small
......@@ -59,6 +61,18 @@ public class RequirementsServiceDO implements Serializable {
@ApiModelProperty(value = "任务流程id", example = "任务流程id")
private Integer serviceFlowId;
@ApiModelProperty(value = "发布者用户id")
private Integer userAccountId;
@ApiModelProperty(value = "订单编号")
private String publisherNumber;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "任务佣金")
private BigDecimal percentagePenaltyOfOrder;
@ApiModelProperty(value = "发布者订单的任务佣金")
private BigDecimal orderAmount;
@ApiModelProperty(value = "抢单者openid")
private String openid;
public RequirementsServiceDO(PilotCertificationInteriorDTO pilot, ServiceRequirementsDO requirementsInfoDO) {
this.pilotCertificationId = pilot.getId();
......
......@@ -134,6 +134,8 @@ public class ServiceRequirementsDO {
@ApiModelProperty(value = "置顶/加急 云享金支付多少", example = "100")
@IsNullConvertZero
private BigDecimal levelCashAmount;
@ApiModelProperty(value = "openid")
private String openid;
public ServiceRequirementsDO(ServiceRequirementsVO serviceRequirementsVO) {
......
......@@ -95,9 +95,9 @@ public interface RequirementsService {
PageResult myPreempt(Integer userAccountId, MyPreemptQO param);
ResultBody droneFlyerCancel(Integer requirementsInfoId, Integer userAccountId);
ResultBody droneFlyerCancel(Integer requirementsInfoId, Integer userAccountId, HttpServletRequest request);
ResultBody publisherCancel(Integer requirementsInfoId, Integer userAccountId);
ResultBody publisherCancel(Integer requirementsInfoId, Integer userAccountId, HttpServletRequest request);
ResultBody cancelAll(Integer requirementsInfoId, Integer userAccountId);
......
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mmc.csf.common.util.json.JsonUtil;
import com.mmc.csf.common.util.page.PageResult;
import com.mmc.csf.common.util.web.HttpsRequestUtil;
import com.mmc.csf.common.util.web.ResultBody;
import com.mmc.csf.common.util.web.ResultEnum;
import com.mmc.csf.config.IsNullConvertZeroUtil;
......@@ -12,6 +13,7 @@ import com.mmc.csf.infomation.qo.IndustryCaseQO;
import com.mmc.csf.infomation.qo.MyPreemptQO;
import com.mmc.csf.infomation.qo.MyPublishQO;
import com.mmc.csf.infomation.vo.*;
import com.mmc.csf.release.constant.*;
import com.mmc.csf.release.dao.RequirementsDao;
import com.mmc.csf.release.entity.requirements.*;
import com.mmc.csf.release.feign.PmsAppApi;
......@@ -37,8 +39,11 @@ import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.mmc.csf.common.util.redis.RedisConstant.createWxToken;
/**
* @author: zj
* @Date: 2023/5/18 14:29
......@@ -69,10 +74,15 @@ public class RequirementsServiceImpl implements RequirementsService {
@Value("${iuav.pmsapp.url}")
private String pmsApp;
@Value("${iuav.payment.url}")
private String paymentApp;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private UserSystemConstant userSystemConstant;
@Override
public ResultBody listType(Integer id) {
List<RequirementsTypeDO> requirementsTypeDOList = requirementsDao.listTypeReq(id);
......@@ -491,20 +501,198 @@ public class RequirementsServiceImpl implements RequirementsService {
}
@Override
public ResultBody droneFlyerCancel(Integer requirementsInfoId, Integer userAccountId) {
public ResultBody droneFlyerCancel(Integer requirementsInfoId, Integer userAccountId, HttpServletRequest request) {
RequirementsServiceDO requirementsServiceDO = requirementsDao.droneFlyerCancel(requirementsInfoId, userAccountId);
Integer serviceFlowId = requirementsServiceDO.getServiceFlowId();
if (serviceFlowId != 2) {
return ResultBody.error(ResultEnum.YOU_CANNOT_CANCEL_THE_ORDER_AT_THIS_TIME.getResultMsg());
}
BigDecimal bigDecimal = new BigDecimal(0.9);
BigDecimal preemptTotalAmount = requirementsServiceDO.getPreemptTotalAmount();
BigDecimal percentagePenaltyOfOrder = preemptTotalAmount.multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
WalletFlowVO walletFlowVO = new WalletFlowVO();
FlyerWalletFlowVO flyerWalletFlowVO = new FlyerWalletFlowVO();
IsNullConvertZeroUtil.checkIsNull(flyerWalletFlowVO);
IsNullConvertZeroUtil.checkIsNull(walletFlowVO);
PublisherWalletFlowVO publisherWalletFlowVO = new PublisherWalletFlowVO();
IsNullConvertZeroUtil.checkIsNull(walletFlowVO);
flyerWalletFlowVO.setModeOfPayment(600);
flyerWalletFlowVO.setPercentagePenaltyOfOrder(percentagePenaltyOfOrder);
flyerWalletFlowVO.setUserAccountId(userAccountId);
flyerWalletFlowVO.setOperateUserAccountId(userAccountId);
walletFlowVO.setFlyerWalletFlowVO(flyerWalletFlowVO);
publisherWalletFlowVO.setUserAccountId(requirementsServiceDO.getUserAccountId());
publisherWalletFlowVO.setModeOfPayment(600);
walletFlowVO.setPublisherWalletFlowVO(publisherWalletFlowVO);
//任务佣金
requirementsServiceDO.setPercentagePenaltyOfOrder(percentagePenaltyOfOrder);
//飞手单方面取消将20之二十退回到发布者佣金里面
flyerCancel(walletFlowVO, request.getHeader("token"));
requirementsDao.updateScene(requirementsInfoId, 7);
requirementsDao.updateInfo(requirementsInfoId, 7);
this.sendMsgFlyerInfoAuth(requirementsServiceDO);
return ResultBody.success(ResultEnum.PAYMENT_SUCCESS.getResultMsg());
}
private void sendMsgFlyerInfoAuth(RequirementsServiceDO requirementsServiceDO) {
//订单编号
JSONObject value1 = new JSONObject();
value1.put("value", requirementsServiceDO.getPublisherNumber());
//订单金额
JSONObject value2 = new JSONObject();
value2.put("value", requirementsServiceDO.getOrderAmount());
//下单时间
JSONObject value3 = new JSONObject();
value3.put("value", requirementsServiceDO.getCreateTime());
//取消时间
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
String date = df.format(new Date());
JSONObject value4 = new JSONObject();
value4.put("value", date);
/* //不通过原因
String reason = null;
if (param.getAuditStatus() == 1) {
reason = userAccountDO.getUserName() + match.getMessage();
}
if (param.getAuditStatus() == 2) {
PilotReasonDO pilotReasonDO = certificationDao.selectPilotReason(param.getReasonId());
reason = pilotReasonDO.getReason();
}
value4.put("value", reason);*/
JSONObject value5 = new JSONObject();
value5.put("value", "");
JSONObject datad = new JSONObject();
//订单编号
datad.put("character_string2", value1);
//订单金额
datad.put("amount3", value2);
//下单时间
datad.put("date5", value3);
//取消时间
datad.put("time7", value4);
//备注
datad.put("thing4", value5);
AppletMsgVOS appletMsgVO = new AppletMsgVOS();
appletMsgVO.setTouser(requirementsServiceDO.getOpenid());
appletMsgVO.setTemplate_id(WxMsgTemplete.INDEMNIFY_FOR_PUBLICATION);
appletMsgVO.setPage("pages/welcome/index");
appletMsgVO.setData(datad);
appletMsgVO.setMiniprogram_state(userSystemConstant.getMiniProgramState());
appletMsgVO.setLang("zh_CN");
sendUserAppletMsg(appletMsgVO);
}
/**
* 小程序-用户端-发送消息
*/
public ResultBody sendUserAppletMsg(AppletMsgVOS aMsg) {
System.out.println("###########开始发送-小程序-用户端消息##########");
String accessToken = null;
try {
accessToken = getStableAccessToken();
System.out.println("accesstoken:" + accessToken);
} catch (Exception e) {
System.out.println("accessToken获取失败:" + e.getMessage());
return ResultBody.error(ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultCode(),
ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultMsg() + e.getMessage());
}
try {
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken;
aMsg.setData(WxApiUtilS.buildMsgJson(aMsg.getData()));
System.out.println(aMsg);
String param = JsonUtil.parseObjToJson(aMsg);
System.out.println("参数:" + param);
String result = HttpsOpenUtil.httpSendPost(url, param);
JSONObject resJson = JSONObject.parseObject(result);
if ("40001".equals(resJson.getString("errcode"))) {
UserSystemConstant userSystemConstant = new UserSystemConstant();
stringRedisTemplate.delete(createWxToken(userSystemConstant.getWxAppId()));
System.out.println("accessToken二次获取失败:" + resJson);
return ResultBody.error(ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultCode(),
ResultEnum.WX_ACCESS_TOKEN_ERROR.getResultMsg() + resJson);
}
System.out.println(result);
} catch (Exception e) {
System.out.println("系统异常:" + e.getMessage());
}
System.out.println("###########结束发送-小程序-消息##########");
return ResultBody.success();
}
public String getStableAccessToken() {
//token有效期为7200s,需要保存起来,先从redis中获取accessToken,没有则请求获取
String accessToken = stringRedisTemplate.opsForValue().get(WxConstant.IUAV_MINI_PROGRAM_STABLE_ACCESS_TOKEN);
if (org.apache.commons.lang.StringUtils.isBlank(accessToken)) {
Map<String, String> params = new HashMap<String, String>();
params.put("grant_type", "client_credential");
params.put("appid", userSystemConstant.getWxAppId());
params.put("secret", userSystemConstant.getWxAppSecret());
String stableAccessTokenUrl = "https://api.weixin.qq.com/cgi-bin/stable_token";
String res = null;
try {
res = HttpsRequestUtil.httpsRequest(stableAccessTokenUrl, "POST", null, JSONObject.toJSONString(params));
} catch (Exception e) {
e.printStackTrace();
}
JSONObject tokenResult = JSONObject.parseObject(res);
if (res.indexOf("access_token") == -1) {
return null;
}
accessToken = tokenResult.getString("access_token");
long expiresIn = tokenResult.getLong("expires_in");
//保存进redis
stringRedisTemplate.opsForValue().set(WxConstant.IUAV_MINI_PROGRAM_STABLE_ACCESS_TOKEN, accessToken, expiresIn, TimeUnit.SECONDS);
return accessToken;
}
return accessToken;
}
@Override
public ResultBody publisherCancel(Integer requirementsInfoId, Integer userAccountId) {
public ResultBody publisherCancel(Integer requirementsInfoId, Integer userAccountId, HttpServletRequest request) {
RequirementsInfoDO requirementsInfoDO = requirementsDao.publisherCancel(requirementsInfoId, userAccountId);
Integer serviceFlowId = requirementsInfoDO.getServiceFlowId();
ApplyRefundVO applyRefundVO = new ApplyRefundVO();
WalletFlowVO walletFlowVO = new WalletFlowVO();
PublisherWalletFlowVO publisherWalletFlowVO = new PublisherWalletFlowVO();
IsNullConvertZeroUtil.checkIsNull(publisherWalletFlowVO);
if (serviceFlowId == 1) {
//飞手无责取消 将全部退回 不包含加急或者置顶
//支付
if (requirementsInfoDO.getCashAmount().compareTo(BigDecimal.ZERO) != 0 ||
requirementsInfoDO.getSalaryAmount().compareTo(BigDecimal.ZERO) != 0) {
publisherWalletFlowVO.setModeOfPayment(200);
publisherWalletFlowVO.setUserAccountId(userAccountId);
publisherWalletFlowVO.setOperateUserAccountId(userAccountId);
walletFlowVO.setPublisherWalletFlowVO(publisherWalletFlowVO);
flyerCancel(walletFlowVO, request.getHeader("token"));
}
if (requirementsInfoDO.getWechatPayOrderNumber() != null
&& requirementsInfoDO.getWeChat().compareTo(BigDecimal.ZERO) != 0) {
BigDecimal weChat = requirementsInfoDO.getWeChat();
BigDecimal multiply = weChat.multiply(new BigDecimal(100));
Long longWeChat = multiply.longValue();
applyRefundVO.setRefund(longWeChat);
applyRefundVO.setOutTradeNo(requirementsInfoDO.getWechatPayOrderNumber());
applyRefundVO.setReason("退发布者微信支付的任务佣金");
applyRefund(applyRefundVO, request.getHeader("token"));
}
return ResultBody.success(ResultEnum.THE_AMOUNT_OF_THE_MISSION_WILL_BE_RETURNED.getResultMsg());
}
if (serviceFlowId != 2 && serviceFlowId != 1) {
......@@ -512,6 +700,33 @@ public class RequirementsServiceImpl implements RequirementsService {
}
//单方面取消订单并且飞手已经抢单
if (serviceFlowId == 2) {
BigDecimal orderAmount = requirementsInfoDO.getOrderAmount();
BigDecimal bigDecimal = new BigDecimal(0.7);
//剩余金额
BigDecimal residueOrderAmount = orderAmount.multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
//先退微信 再退任务佣金 最后退云享金
BigDecimal weChat = requirementsInfoDO.getWeChat();
//微信需要退款多少金额
//微信金额大于扣除之后的金额
BigDecimal refundCashAmount = new BigDecimal(0);
BigDecimal refundSalaryAmount = new BigDecimal(0);
BigDecimal refundWeChat = new BigDecimal(0);
if (weChat.compareTo(residueOrderAmount) == 1) {
refundWeChat = refundCashAmount;
BigDecimal multiply = weChat.multiply(new BigDecimal(100));
Long longWeChat = multiply.longValue();
applyRefundVO.setRefund(longWeChat);
applyRefundVO.setReason("扣除飞手百分之三十的费用");
applyRefund(applyRefundVO, request.getHeader("token"));
}
return ResultBody.success(ResultEnum.REFUND_PERCENTAGE.getResultMsg());
}
return ResultBody.success();
......@@ -563,6 +778,9 @@ public class RequirementsServiceImpl implements RequirementsService {
@Override
public ResultBody publishService(ServiceRequirementsVO serviceRequirementsVO, HttpServletRequest request) {
//获取用户基本信息
UserAccountSimpleDTO userAccountSimpleDTO = feignGetUserSimpleInfo(serviceRequirementsVO.getUserAccountId(), request);
String openid = userAccountSimpleDTO.getOpenid();
//需要冻结的金额
WalletFlowVO walletFlowVO = new WalletFlowVO();
// PublisherWalletFlowVO publisherWalletFlowVO = walletFlowVO.getPublisherWalletFlowVO();
......@@ -706,10 +924,12 @@ public class RequirementsServiceImpl implements RequirementsService {
if (userCashAmt.compareTo(tempTotalAmount) == 1 || userCashAmt.compareTo(tempTotalAmount) == 0) {
// walletFlowVO.setCashAmount(tempTotalAmount);
publisherWalletFlowVO.setCashAmount(tempTotalAmount);
requirementsInfoDO.setCashAmount(tempTotalAmount);
tempTotalAmount = BigDecimal.ZERO;
} else {
tempTotalAmount = tempTotalAmount.subtract(userCashAmt);
publisherWalletFlowVO.setCashAmount(userCashAmt);
requirementsInfoDO.setCashAmount(userCashAmt);
}
}
break;
......@@ -717,10 +937,12 @@ public class RequirementsServiceImpl implements RequirementsService {
if (!(tempTotalAmount.compareTo(BigDecimal.ZERO) == 0)) {
if (userSalaryAmt.compareTo(tempTotalAmount) == 1 || userSalaryAmt.compareTo(tempTotalAmount) == 0) {
publisherWalletFlowVO.setSalaryAmount(tempTotalAmount);
requirementsInfoDO.setSalaryAmount(tempTotalAmount);
tempTotalAmount = BigDecimal.ZERO;
} else {
tempTotalAmount = tempTotalAmount.subtract(userSalaryAmt);
publisherWalletFlowVO.setSalaryAmount(userSalaryAmt);
requirementsInfoDO.setSalaryAmount(userSalaryAmt);
}
}
......@@ -808,11 +1030,10 @@ public class RequirementsServiceImpl implements RequirementsService {
}
}
}
requirementsInfoDO.setOpenid(openid);
requirementsDao.addPublishService(requirementsInfoDO);
RequirementsAmountDO requirementsAmountDO = new RequirementsAmountDO(requirementsInfoDO);
requirementsDao.addAmount(requirementsAmountDO);
System.out.println(requirementsAmountDO);
if (requirementsAmountDO.getCashAmount().compareTo(BigDecimal.ZERO) != 0
|| requirementsAmountDO.getSalaryAmount().compareTo(BigDecimal.ZERO) != 0
|| requirementsAmountDO.getLevelCashAmount().compareTo(BigDecimal.ZERO) != 0
......@@ -870,6 +1091,9 @@ public class RequirementsServiceImpl implements RequirementsService {
@Override
public ResultBody grabTheOrder(GrabTheOrderVO grabTheOrderVO, HttpServletRequest request) {
UserAccountSimpleDTO userAccountSimpleDTO = feignGetUserSimpleInfo(grabTheOrderVO.getUserAccountId(), request);
String openid = userAccountSimpleDTO.getOpenid();
ServiceRequirementsDO requirementsInfoDO = requirementsDao.grabTheOrder(grabTheOrderVO.getRequirementsInfoId());
if (grabTheOrderVO.getRequirementsInfoId().equals(requirementsInfoDO.getId()) && grabTheOrderVO.getUserAccountId().equals(requirementsInfoDO.getUserAccountId())) {
return ResultBody.error("自己不能抢自己发布的需求");
......@@ -904,6 +1128,7 @@ public class RequirementsServiceImpl implements RequirementsService {
totalAmount = totalAmount.multiply(bigDecimal).setScale(2, BigDecimal.ROUND_HALF_UP);
String json = stringRedisTemplate.opsForValue().get(grabTheOrderVO.getWechatPayOrderNumber() + grabTheOrderVO.getUserAccountId());
GetOrderNumberDTO orderNumberDTO = JSONObject.parseObject(json, GetOrderNumberDTO.class);
IsNullConvertZeroUtil.checkIsNull(orderNumberDTO);
//需要冻结的金额
FlyerWalletFlowVO flyerWalletFlowVO = new FlyerWalletFlowVO();
IsNullConvertZeroUtil.checkIsNull(flyerWalletFlowVO);
......@@ -1073,6 +1298,18 @@ public class RequirementsServiceImpl implements RequirementsService {
}
public UserAccountSimpleDTO feignGetUserSimpleInfo(Integer userAccountId, HttpServletRequest request) {
String token = request.getHeader("token");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(userAccountId), headers);
ResponseEntity<UserAccountSimpleDTO> exchange1 = restTemplate.exchange(userApp + "/userapp/user-account/feignGetUserSimpleInfo?userAccountId=" + userAccountId, HttpMethod.GET, entity, UserAccountSimpleDTO.class);
UserAccountSimpleDTO body = exchange1.getBody();
return body;
}
public PilotCertificationInteriorDTO feignInteriorDetailPilot(Integer userAccountId, HttpServletRequest request) {
String token = request.getHeader("token");
HttpHeaders headers = new HttpHeaders();
......@@ -1085,6 +1322,45 @@ public class RequirementsServiceImpl implements RequirementsService {
}
/**
* 退款
*/
public ResultBody applyRefund(ApplyRefundVO applyRefundVO, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(applyRefundVO), headers);
ResponseEntity<Object> exchange = null;
try {
exchange = restTemplate.exchange(paymentApp + "/payment/wechat/applyRefund", HttpMethod.POST, entity, Object.class);
} catch (RestClientException e) {
return ResultBody.error(ResultEnum.THE_THIRD_PARTY_INTERFACE_IS_BEING_UPDATED);
}
return ResultBody.success();
}
/**
* 公共调用
*
* @param walletFlowVO
* @param token
* @return
*/
public ResultBody flyerCancel(WalletFlowVO walletFlowVO, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("token", token);
HttpEntity<String> entity = new HttpEntity<>(JSONObject.toJSONString(walletFlowVO), headers);
ResponseEntity<Object> exchange = null;
try {
exchange = restTemplate.exchange(userApp + "/userapp/pay/feignWalletFlow", HttpMethod.POST, entity, Object.class);
} catch (RestClientException e) {
return ResultBody.error(ResultEnum.THE_THIRD_PARTY_INTERFACE_IS_BEING_UPDATED);
}
return ResultBody.success();
}
public ResultBody walletFlow(FlyerWalletFlowVO flyerWalletFlowVO, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
......
......@@ -149,6 +149,8 @@ iuav:
url: http://pms-svc:8099
omsapp:
url: https://test.iuav.shop/oms/
payment:
url: https://test.iuav.shop
#mmc:
......
......@@ -147,6 +147,8 @@ iuav:
url: http://pms-svc:8099
omsapp:
url: https://www.iuav.shop/oms/
payment:
url: https://www.iuav.shop
#mmc:
# appid: 80001
......
......@@ -293,11 +293,11 @@
require_description, create_time,
update_time, task_start_time, task_end_time, task_address, longitude,
latitude, publisher_number, insurance, publish,
service_flow_id, adcode, order_level_amount)
service_flow_id, adcode, order_level_amount, openid)
VALUES (#{serviceId}, #{userAccountId}, #{publishName}, #{publishPhone},
#{requireDescription}, NOW(),
NOW(), #{taskStartTime}, #{taskEndTime}, #{taskAddress}, #{longitude},
#{latitude}, #{publisherNumber}, #{insurance}, 1, 1, #{adcode}, #{orderLevelAmount});
#{latitude}, #{publisherNumber}, #{insurance}, 1, 1, #{adcode}, #{orderLevelAmount}, #{openid});
</insert>
<insert id="addAmount" parameterType="com.mmc.csf.release.entity.requirements.RequirementsAmountDO"
......@@ -355,10 +355,10 @@
INSERT INTO requirements_service(requirements_info_id, pilot_certification_id,
pilot_certification_user_id, team_id, team_user_id, cash_amount, we_chat,
salary_amount,
wechat_pay_order_number, service_flow_id, preempt_total_amount)
wechat_pay_order_number, service_flow_id, preempt_total_amount, openid)
VALUES (#{requirementsInfoId}, #{pilotCertificationId}, #{pilotCertificationUserId},
#{teamId}, #{teamUserId}, #{cashAmount}, #{weChat}, #{salaryAmount}, #{wechatPayOrderNumber}, 2,
#{preemptTotalAmount});
#{preemptTotalAmount}, #{openid});
</insert>
<insert id="arriveAtTheScene" parameterType="com.mmc.csf.release.entity.requirements.ServiceArriveSceneDO"
......@@ -379,7 +379,7 @@
UPDATE requirements_info
set service_flow_id=#{serviceFlowId},
update_time=NOW()
where requirements_info_id = #{requirementsInfoId}
where id = #{requirementsInfoId}
</update>
<select id="arriveAtTheSceneDetails" resultType="com.mmc.csf.release.entity.requirements.ServiceArriveSceneDO">
......@@ -560,8 +560,9 @@
ri.publish_phone,
ri.publisher_number,
ri.service_id,
ri.total_amount,
ra.total_amount,
ri.insurance,
rs.create_time,
sf.doing,
sf.waiting,
sf.user_port,
......@@ -569,19 +570,22 @@
sf.order_status,
ri.publish,
rs.preempt_total_amount,
rs.cash_amount,
rs.we_chat,
rs.salary_amount,
ra.cash_amount,
ra.we_chat,
ra.salary_amount,
rs.wechat_pay_order_number,
rs.preempt_total_amount,
rs.service_flow_id
rs.service_flow_id,
ra.order_amount,
ri.openid
FROM requirements_info ri
LEFT JOIN requirements_type rt
ON rt.id = ri.requirement_type_id
LEFT JOIN service_flow sf ON sf.id = ri.service_flow_id
LEFT JOIN requirements_amount ra ON ra.requirements_info_id = ri.id
INNER JOIN requirements_service rs ON ri.id = rs.requirements_info_id
WHERE rs.pilot_certification_user_id = #{userAccountId}
and rs.requirements_info_id = #{requirementsInfoId}
AND rs.requirements_info_id = #{requirementsInfoId}
</select>
<select id="publisherCancel" resultType="com.mmc.csf.release.entity.requirements.RequirementsInfoDO">
......@@ -600,19 +604,29 @@
ri.publish_phone,
ri.publisher_number,
ri.service_id,
ri.total_amount,
ra.total_amount,
ri.insurance,
ri.order_level,
ri.order_amount,
ra.order_level,
ra.order_amount,
sf.doing,
sf.waiting,
sf.user_port,
sf.flyer_port,
sf.order_status,
ri.publish
ri.publish,
ra.order_amount,
ra.we_chat,
ra.salary_amount,
ra.cash_amount,
ra.level_cash_amount,
ra.level_salary_amount,
ra.level_we_chat_amount,
ra.wechat_pay_order_number,
ri.service_flow_id
FROM requirements_info ri
LEFT JOIN requirements_type rt ON rt.id = ri.requirement_type_id
LEFT JOIN service_flow sf ON sf.id = ri.service_flow_id
LEFT JOIN requirements_amount ra ON ra.requirements_info_id = ri.id
WHERE ri.user_account_id = #{userAccountId}
AND ri.id = #{requirementsInfoId}
</select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论