diff --git a/mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java b/mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java index 168f995f3..576dadd28 100644 --- a/mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java +++ b/mallinkPublicApi/src/main/java/com/iformall/controller/UserThirdCircleOrderController.java @@ -9,6 +9,7 @@ import com.iformall.service.WxThirdPartyOrdersService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -46,27 +47,27 @@ public class UserThirdCircleOrderController extends BaseController { logger.info("UserThirdCircleOrderController >>>>>>>>>>>> createOrder >>>>>>>>>>>>>"+map.toString()); String transactionId = (String) map.get("transactionId");//***订单Id - Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店 + String shopNumber = (String) map.get("shopNumber");//***门店唯一标识 对应双方平台门店 String shopName = (String) map.get("shopName");//门店名称 - Long userNumber = (Long) map.get("userNumber");//***会员Id + String userNumber = (String) map.get("userNumber");//***会员Id String userPhone = (String) map.get("userPhone");//会员手机号 String timeEnd = (String) map.get("timeEnd");//***付款时间(yyyy-MM-dd HH:mm:ss) - Integer amount = (Integer) map.get("amount");//***付款金额(分) + String amount = (String) map.get("amount");//***付款金额(分) String summary = (String) map.get("summary");//付款摘要 if(StringUtils.isBlank(transactionId)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空"); } - if(shopNumber == null){ + if(StringUtils.isBlank(shopNumber)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空"); } - if(userNumber == null){ + if(StringUtils.isBlank(userNumber)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空"); } if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){ return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"userPhone格式不正确"); } - if(timeEnd == null){ + if(StringUtils.isBlank(timeEnd)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"timeEnd为空"); } Date timeEndDate = null; @@ -75,22 +76,25 @@ public class UserThirdCircleOrderController extends BaseController { } catch (ParseException e) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确"); } - if(amount == null){ + if(StringUtils.isBlank(amount)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空"); } + if(NumberUtils.isCreatable(amount)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"amount为非数字"); + } WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders(); thirdPartyOrders.updateTenantInfo(getTenantInfo()); thirdPartyOrders.setSourceAppId(getAppId()); thirdPartyOrders.setTransactionId(transactionId); - thirdPartyOrders.setShopNumber(String.valueOf(shopNumber)); + thirdPartyOrders.setShopNumber(shopNumber); thirdPartyOrders.setShopName(shopName); - thirdPartyOrders.setUserNumber(String.valueOf(userNumber)); + thirdPartyOrders.setUserNumber(userNumber); thirdPartyOrders.setUserPhone(userPhone); thirdPartyOrders.setTimeEnd(timeEndDate); - thirdPartyOrders.setAmount(amount); - thirdPartyOrders.setPayAmount(amount); + thirdPartyOrders.setAmount(Integer.parseInt(amount)); + thirdPartyOrders.setPayAmount(Integer.parseInt(amount)); thirdPartyOrders.setSummary(summary); try{ thirdPartyOrdersService.createOrder(thirdPartyOrders); @@ -118,8 +122,8 @@ public class UserThirdCircleOrderController extends BaseController { String transactionId = (String) map.get("transactionId");//***订单Id String refundTime = (String) map.get("refundTime");//***退款时间(yyyy-MM-dd HH:mm:ss) String refundSummary = (String) map.get("refundSummary");//退款摘要 - Integer refundAmount = (Integer) map.get("refundAmount");//退款金额(分) - String refundId = (String) map.get("refundId");//退款Id + String refundAmount = (String) map.get("refundAmount");//退款金额(分) + String refundId = (String) map.get("refundId");//**退款Id if(StringUtils.isBlank(transactionId)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空"); @@ -133,6 +137,13 @@ public class UserThirdCircleOrderController extends BaseController { } catch (ParseException e) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确"); } + if(StringUtils.isNotBlank(refundAmount) && NumberUtils.isCreatable(refundAmount)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"refundAmount为非数字"); + } + + if(StringUtils.isBlank(refundId)){ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"refundId为空"); + } WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders(); thirdPartyOrders.updateTenantInfo(getTenantInfo()); @@ -142,7 +153,7 @@ public class UserThirdCircleOrderController extends BaseController { thirdPartyOrders.setTransactionId(transactionId); thirdPartyOrders.setEndTime(refundTimeDate); thirdPartyOrders.setSummary(refundSummary); - thirdPartyOrders.setRefundAmount(refundAmount); + thirdPartyOrders.setRefundAmount(Integer.parseInt(refundAmount)); thirdPartyOrders.setRefundId(refundId); try{ @@ -170,21 +181,21 @@ public class UserThirdCircleOrderController extends BaseController { logger.info("UserThirdCircleOrderController >>>>>>>>>>>> pointDeduction >>>>>>>>>>>>>"+map.toString()); String transactionId = (String) map.get("transactionId");//***订单Id - Long shopNumber = (Long) map.get("shopNumber");//***门店唯一标识 对应双方平台门店 + String shopNumber = (String) map.get("shopNumber");//***门店唯一标识 对应双方平台门店 String shopName = (String) map.get("shopName");//门店名称 - Long userNumber = (Long) map.get("userNumber");//***会员Id + String userNumber = (String) map.get("userNumber");//***会员Id String userPhone = (String) map.get("userPhone");//会员手机号 String timeEnd = (String) map.get("timeEnd");//***抵扣时间 - Integer amount = (Integer) map.get("amount");//***积分数量 - String summary = (String) map.get("summary");//付款摘要 + String amount = (String) map.get("amount");//***积分数量 + String summary = (String) map.get("summary");//摘要 if(StringUtils.isBlank(transactionId)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"transactionId为空"); } - if(shopNumber == null){ + if(StringUtils.isBlank(shopNumber)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopNumber为空"); } - if(userNumber == null){ + if(StringUtils.isBlank(userNumber)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"userNumber为空"); } if(StringUtils.isNotBlank(userPhone) && !userPhone.matches("^1[0-9]{10}$")){ @@ -199,21 +210,25 @@ public class UserThirdCircleOrderController extends BaseController { } catch (ParseException e) { return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"timeEnd格式不正确"); } - if(amount == null){ + if(StringUtils.isBlank(amount)){ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"amount为空"); } + if(NumberUtils.isCreatable(amount)){ + return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"amount为非数字"); + } WxThirdPartyOrders thirdPartyOrders = new WxThirdPartyOrders(); thirdPartyOrders.updateTenantInfo(getTenantInfo()); thirdPartyOrders.setSourceAppId(getAppId()); thirdPartyOrders.setTransactionId(transactionId); - thirdPartyOrders.setShopNumber(String.valueOf(shopNumber)); + thirdPartyOrders.setShopNumber(shopNumber); thirdPartyOrders.setShopName(shopName); - thirdPartyOrders.setUserNumber(String.valueOf(userNumber)); + thirdPartyOrders.setUserNumber(userNumber); thirdPartyOrders.setUserPhone(userPhone); thirdPartyOrders.setTimeEnd(timeEndDate); - thirdPartyOrders.setAmount(amount); + thirdPartyOrders.setAmount(Integer.parseInt(amount)); + thirdPartyOrders.setPayAmount(Integer.parseInt(amount)); thirdPartyOrders.setSummary(summary); try{ thirdPartyOrdersService.pointDeduction(thirdPartyOrders); diff --git a/mallinkPublicApi/src/main/java/com/iformall/utils/AppTest.java b/mallinkPublicApi/src/main/java/com/iformall/utils/AppTest.java index d9c12c086..f4b536a39 100644 --- a/mallinkPublicApi/src/main/java/com/iformall/utils/AppTest.java +++ b/mallinkPublicApi/src/main/java/com/iformall/utils/AppTest.java @@ -38,7 +38,7 @@ public class AppTest { */ IdWorker idWorker = IdWorker.get(); paramMap.put("transactionId",String.valueOf(idWorker.nextId()));//***订单Id - paramMap.put("shopNumber","461675336101793792");//***门店唯一标识 对应双方平台门店 + paramMap.put("shopNumber","1001");//***门店唯一标识 对应双方平台门店 paramMap.put("shopName","百丽");//门店名称 paramMap.put("userNumber","542490555719278592");//***会员Id paramMap.put("userPhone","18872592633");//会员手机号 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java index d76244bb2..d5deab7fa 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxThirdPartyOrdersServiceImpl.java @@ -22,8 +22,6 @@ import java.math.BigDecimal; import java.util.Date; import java.util.List; -import static org.springframework.transaction.annotation.Propagation.REQUIRED; - @Service public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService { @@ -120,7 +118,13 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService } WxCUserBasicInfo basicInfo = null; - basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId()); + Long userId = null; + try { + userId = Long.parseLong(record.getUserNumber()); + } catch (NumberFormatException e) {} + if(userId != null){ + basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); + } if(basicInfo == null){ basicInfo = wxCUserBasicInfoService.registerByPhone(record, record.getUserPhone()); } @@ -207,6 +211,9 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService refundIncreasedPoints += ro.getIncreasedPoints(); } } + if(record.getRefundAmount() == null){ + record.setRefundAmount(order.getPayAmount()-refundAmount); + } if(refundAmount >= amount){ logger.error("--第三方退款--已经退款--transactionId="+record.getTransactionId()); throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已经退款"); @@ -292,8 +299,12 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService public void pointDeduction(WxThirdPartyOrders record) { WxCUserBasicInfo basicInfo = null; - if(StringUtils.isNotBlank(record.getUserNumber())){ - basicInfo = wxCUserBasicInfoService.getById(Long.parseLong(record.getUserNumber()), record.getFinalTenantId()); + Long userId = null; + try { + userId = Long.parseLong(record.getUserNumber()); + } catch (NumberFormatException e) {} + if(userId != null){ + basicInfo = wxCUserBasicInfoService.getById(userId, record.getFinalTenantId()); } if(basicInfo == null){ logger.error("--第三方积分订单--未找到用户---userId="+record.getUserNumber());