From cd820d1ed3086b26d2d0f4b11cbd7b6641ee86a3 Mon Sep 17 00:00:00 2001 From: xhxu Date: Thu, 23 Mar 2023 14:28:22 +0800 Subject: [PATCH] //COUPON --- .../db/migration/V2023031600001_cardspend.sql | 4 ++++ .../migration/V2023032200001_coupon_press.sql | 7 ------- .../com/iformall/domain/po/WxCardSpend.java | 2 ++ .../com/iformall/enums/EnumCardInfoType.java | 1 + .../service/impl/WxCardInfoServiceImpl.java | 19 +++++++++++++------ .../service/impl/WxCardSpendServiceImpl.java | 3 +++ .../impl/WxRefundOrderServiceImpl.java | 1 + .../resources/mapper/WxCardSpendMapper.xml | 3 ++- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/mallinkAdmin/src/main/resources/db/migration/V2023031600001_cardspend.sql b/mallinkAdmin/src/main/resources/db/migration/V2023031600001_cardspend.sql index da23a77cf..69bd89402 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2023031600001_cardspend.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2023031600001_cardspend.sql @@ -334,5 +334,9 @@ ADD COLUMN `used_password` varchar(50) COMMENT '使用密码' AFTER `is_recharge +ALTER TABLE `mallink`.`wx_card_spend` +ADD COLUMN `card_type` smallint(2) DEFAULT 0 AFTER `card_id`; +update wx_card_spend set card_type=1 where owner_id = 111111111111111111; + diff --git a/mallinkAdmin/src/main/resources/db/migration/V2023032200001_coupon_press.sql b/mallinkAdmin/src/main/resources/db/migration/V2023032200001_coupon_press.sql index caf3b204f..fe9a1eb7f 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2023032200001_coupon_press.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2023032200001_coupon_press.sql @@ -100,10 +100,3 @@ update wx_coupon_97 set press_limit_hours = press_limit_hours * 60 where press_l update wx_coupon_98 set press_limit_hours = press_limit_hours * 60 where press_limit_hours is not null; update wx_coupon_99 set press_limit_hours = press_limit_hours * 60 where press_limit_hours is not null; - - - - - - - diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java index fd31e6dbf..1b242c60a 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java @@ -27,6 +27,8 @@ public class WxCardSpend extends TenantEntity { private Long cardId; @TableField(exist = false) private List cardIdList; + @io.swagger.annotations.ApiModelProperty(value="EnumCardInfoType",name="cardType") + private Integer cardType; @io.swagger.annotations.ApiModelProperty(value="持有人ID",name="ownerId") private Long ownerId; @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCardInfoType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCardInfoType.java index 6777b3e28..1e41790a7 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCardInfoType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCardInfoType.java @@ -33,4 +33,5 @@ public enum EnumCardInfoType { public String getMessage() { return message; } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCardInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCardInfoServiceImpl.java index c37fac2e4..d44363ea1 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCardInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCardInfoServiceImpl.java @@ -16,10 +16,7 @@ import com.iformall.domain.vo.WxCouponPasswordVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; -import com.iformall.service.ExcelService; -import com.iformall.service.WxCUserBasicInfoService; -import com.iformall.service.WxCardInfoService; -import com.iformall.service.WxCouponService; +import com.iformall.service.*; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; import com.iformall.utils.RedisLock; @@ -83,8 +80,10 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { @Autowired WxCardSpendMapper wxCardSpendMapper; - - + + @Autowired + WxCardSpendService wxCardSpendService; + @Override public PageInfo listAsPage(WxCardVo record, Integer pageIndex, Integer pageSize) { @@ -507,6 +506,14 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { logger.error("card spend insert error"); throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "card spend 插入出错!"); } + + if(record.getCardBeforeAmount().equals(0)){ + if (wxCardSpendService.cardFinishedUsing(currentDate, cardInfo)) { + throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "couponOrder status 更新出错!"); + } + } + wxCardSpendService.sendCardBalanceChange(wxCoupon,record); + return new ResultData(); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java index 4f27ca4a4..0cf91a240 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java @@ -185,6 +185,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { // 5 insert card_spend record.setId(idWorker.nextId()); record.updateTenantInfo(cardInfo); + record.setCardType(cardInfo.getType()); record.setPayType(EnumPayType.PAY_PAYMENT.getCode()); if(record.getPayFrom() == null){ record.setPayFrom(EnumCardSpendFrom.C.getCode()); @@ -1083,6 +1084,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { // 5 insert card_spend record.setId(idWorker.nextId()); record.updateTenantInfo(cardInfo); + record.setCardType(cardInfo.getType()); + record.setPayType(EnumPayType.PAY_PAYMENT.getCode()); record.setPayment(payment); record.setRealPayment(real_payment); record.setCardBeforeAmount(cardInfo.getRemainingAmount()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java index 8f0da04c1..d736b9f2c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRefundOrderServiceImpl.java @@ -1280,6 +1280,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); + record.setCardType(cardSend.getCardType()); record.setOwnerId(cardSend.getOwnerId()); record.setMerchantId(cardSend.getMerchantId()); record.setPayFrom(EnumCardSpendFrom.refund.getCode()); diff --git a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml index 17e78578e..198a81792 100644 --- a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml @@ -6,6 +6,7 @@ + @@ -29,7 +30,7 @@ - `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`owner_id`,`pay_type`,`merchant_id`,`order_id`,`pos_order_id`, + `id`,`tenant_id`,`parent_tenant_id`,`card_id`,`card_type`,`owner_id`,`pay_type`,`merchant_id`,`order_id`,`pos_order_id`, `deduction_amount`,`payment`,`real_payment`,`subsidy`, `card_remain_amount`, `card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`, `create_date`, `update_date`, `pay_status`, `pay_from`, `refund_status`, `refund_remark`, `settlement_status`