diff --git a/cweb/src/main/java/com/cweb/controller/TestController.java b/cweb/src/main/java/com/cweb/controller/TestController.java index d0c1461..e725e4c 100644 --- a/cweb/src/main/java/com/cweb/controller/TestController.java +++ b/cweb/src/main/java/com/cweb/controller/TestController.java @@ -24,11 +24,11 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.device.SoundService; import com.hfkj.config.mqtt.MqttProviderService; import com.hfkj.entity.BsLklMcc; +import com.hfkj.entity.BsTradeOrder; +import com.hfkj.entity.BsTradeOrderProfitSharing; import com.hfkj.entity.SecRegion; import com.hfkj.model.ResponseData; -import com.hfkj.service.BsLklMccService; -import com.hfkj.service.CommonService; -import com.hfkj.service.SecRegionService; +import com.hfkj.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.collections4.MapUtils; @@ -81,20 +81,10 @@ public class TestController { @Resource private LaKaLaLedgerService laKaLaLedgerService; - @RequestMapping(value="/rotationQueryTrade",method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "交易【被扫】") - public ResponseData rotationQueryTrade() { - try { - - // return ResponseMsgUtil.success(LaKaLaConfig.queryCardBin("3100020709200056842")); - return ResponseMsgUtil.success(laKaLaLedgerService.queryLedgerMer("8221210701101SB")); - - } catch (Exception e) { - log.error(e.getMessage(), e); - return ResponseMsgUtil.exception(e); - } - } + @Resource + private BsTradeOrderService tradeOrderService; + @Resource + private BsTradeOrderProfitSharingService tradeOrderProfitSharingService; @RequestMapping(value="/saasGetToken",method = RequestMethod.GET) @ResponseBody @@ -121,7 +111,8 @@ public class TestController { // return ResponseMsgUtil.success(saasCommon.getArea("1")); // return ResponseMsgUtil.success(saasCommon.getBank("6530", "大坪支行")); - return ResponseMsgUtil.success(laKaLaLedgerService); + tradeOrderProfitSharingService.createProfitSharing(tradeOrderService.getOrderByOutTradeNo("")); + return ResponseMsgUtil.success(""); // return ResponseMsgUtil.success(""); // 1200 // return ResponseMsgUtil.success(saasCommon.fileUpload(new HashMap<>())); @@ -142,47 +133,6 @@ public class TestController { } } - public static String test(String str, Integer type) { - char[] chars = str.toCharArray(); -// oP: '省' 的偏移, oC: '市' 的偏移, oR: "自治区" 的偏移 - int oP = -1, oC = -1, oR = -1; - char ch; - for (int i = 0; i < chars.length; i++) { - ch = chars[i]; - // 一般来说 '省' 的位置会比 '市' 早出现 - if (ch == '省') { - oP = i; - } else if (ch == '市') { - oC = i; - // 找到 '市' 后就可以跳出循环了 - break; - } else if (ch == '自' - && i + 2 < chars.length - && chars[i + 1] == '治' - && chars[i + 2] == '区') { - // "自治区" 出现的几率挺小 - oR = i + 2; - } - } - - if (type == 1) { - if (oC != -1) { - str = str.substring(oC + 1); - } else if (oP != -1) { - str = str.substring(oP + 1); - } else if (oR != -1) { - str = str.substring(oR + 1); - } - } else if (type == 2) { - if (oP != -1) { - str = str.substring(oP + 1); - } else if (oR != -1) { - str = str.substring(oR + 1); - } - } - - return str; - } @RequestMapping(value="/soundSendMsg",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "音响发送消息") diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderProfitSharingServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderProfitSharingServiceImpl.java index 0210a67..4ca88f8 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderProfitSharingServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderProfitSharingServiceImpl.java @@ -76,7 +76,7 @@ public class BsTradeOrderProfitSharingServiceImpl implements BsTradeOrderProfitS // 渠道平台手续费 BigDecimal platformServiceCharge = null; if (tradeOrder.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { - platformServiceCharge = new BigDecimal("0.002"); + platformServiceCharge = new BigDecimal("0.000"); } else if (tradeOrder.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { platformServiceCharge = new BigDecimal("0.002"); } diff --git a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java index 617a750..e4a3867 100644 --- a/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/BsTradeOrderRefundServiceImpl.java @@ -2,12 +2,17 @@ package com.hfkj.service.impl; import com.hfkj.channel.ccb.CCBTradeService; import com.hfkj.channel.weixin.WeiXinPayService; +import com.hfkj.common.exception.BizException; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; import com.hfkj.dao.BsTradeOrderRefundMapper; import com.hfkj.entity.*; import com.hfkj.channel.lakala.LaKaLaTradeService; import com.hfkj.service.*; import com.hfkj.sysenum.PlatformTypeEnum; import com.hfkj.sysenum.StoreDiscountActivityPartakeWayEnum; +import com.hfkj.sysenum.TradeOrderRefundStatusEnum; import com.hfkj.sysenum.TradeOrderStatusEnum; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -58,44 +63,55 @@ public class BsTradeOrderRefundServiceImpl implements BsTradeOrderRefundService @Override public Map tradeOrderRefund(BsTradeOrderRefund tradeOrderRefund) throws Exception { - editOrderRefund(tradeOrderRefund); + try { + editOrderRefund(tradeOrderRefund); - Map refund = new HashMap<>(); - if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { - refund = laKaLaTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); + Map refund = new HashMap<>(); + if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type1.getNumber())) { + refund = laKaLaTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); - } else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type3.getNumber())) { - refund = ccbTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); + } else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type3.getNumber())) { + refund = ccbTradeService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); - } else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { - refund = weiXinPayService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); - } + } else if (tradeOrderRefund.getPlatformType().equals(PlatformTypeEnum.type4.getNumber())) { + refund = weiXinPayService.refund(tradeOrderRefund.getRefundNo(), tradeOrderRefund.getRefundAmount()); + } - // 交易订单 - BsTradeOrder tradeOrder = tradeOrderService.getOrderByTradeNoId(tradeOrderRefund.getTradeOrderId()); - if (tradeOrder != null) { - // 退回门店优惠活动 - if (tradeOrder.getStoreDiscountId() != null) { - BsStoreDiscountActivity storeDiscountActivity = storeDiscountActivityService.getDetailById(tradeOrder.getStoreDiscountId()); - if (storeDiscountActivity != null - && !storeDiscountActivity.getPartakeWay().equals(StoreDiscountActivityPartakeWayEnum.type1.getNumber()) - && StringUtils.isNotBlank(tradeOrder.getUserPhone())) { - - BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId()); - if (partakeUser != null) { - partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() + 1); - partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() - 1); - discountActivityPartakeUserService.editData(partakeUser); + // 交易订单 + BsTradeOrder tradeOrder = tradeOrderService.getOrderByTradeNoId(tradeOrderRefund.getTradeOrderId()); + if (tradeOrder != null) { + // 退回门店优惠活动 + if (tradeOrder.getStoreDiscountId() != null) { + BsStoreDiscountActivity storeDiscountActivity = storeDiscountActivityService.getDetailById(tradeOrder.getStoreDiscountId()); + if (storeDiscountActivity != null + && !storeDiscountActivity.getPartakeWay().equals(StoreDiscountActivityPartakeWayEnum.type1.getNumber()) + && StringUtils.isNotBlank(tradeOrder.getUserPhone())) { + + BsStoreDiscountActivityPartakeUser partakeUser = discountActivityPartakeUserService.getPartakeUser(tradeOrder.getUserPhone(), tradeOrder.getStoreDiscountId()); + if (partakeUser != null) { + partakeUser.setPartakeSurplusNum(partakeUser.getPartakeSurplusNum() + 1); + partakeUser.setPartakeUseNum(partakeUser.getPartakeUseNum() - 1); + discountActivityPartakeUserService.editData(partakeUser); + } } } - } - if (tradeOrder.getUserDiscountId() != null) { - userDiscountService.userDiscountReturn(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone()); + if (tradeOrder.getUserDiscountId() != null) { + userDiscountService.userDiscountReturn(tradeOrder.getUserDiscountId(), tradeOrder.getUserPhone()); + } } - } + return refund; + + } catch (BizException e) { + tradeOrderRefund.setStatus(TradeOrderRefundStatusEnum.status0.getNumber()); + editOrderRefund(tradeOrderRefund); + throw e; - return refund; + } catch (Exception e) { + tradeOrderRefund.setStatus(TradeOrderRefundStatusEnum.status0.getNumber()); + editOrderRefund(tradeOrderRefund); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e.getMessage()); + } } @Override diff --git a/service/src/main/java/com/hfkj/sysenum/TradeOrderRefundStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/TradeOrderRefundStatusEnum.java index ce4731e..6e2c02d 100644 --- a/service/src/main/java/com/hfkj/sysenum/TradeOrderRefundStatusEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/TradeOrderRefundStatusEnum.java @@ -5,6 +5,7 @@ package com.hfkj.sysenum; * @author hurui */ public enum TradeOrderRefundStatusEnum { + status0(0, "删除"), status1(1, "退款中"), status2(2, "已退款"), status3(3, "退款失败"),