From 441c2aa619d847729cfd6c99cdeeeb6caa4e9891 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 6 Mar 2023 15:04:38 +0800 Subject: [PATCH 1/6] fix bug --- .../controller/market/WxCouponBatchController.java | 2 +- .../com/iformall/mapper/WxCouponBatchItemMapper.java | 6 +++--- .../service/impl/WxCouponBatchServiceImpl.java | 2 +- .../resources/mapper/WxCouponBatchItemMapper.xml | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponBatchController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponBatchController.java index 7ba5c04bd..167af6f81 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponBatchController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponBatchController.java @@ -101,7 +101,7 @@ public class WxCouponBatchController extends BaseController { return new ResultData(order); } - @ApiOperation("砍价券接口") + @ApiOperation("券接口") @GetMapping("itemList") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true), diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchItemMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchItemMapper.java index eb71c2e7f..ae9f0eb36 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchItemMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchItemMapper.java @@ -9,15 +9,15 @@ public interface WxCouponBatchItemMapper extends CommonMapper findList(WxCouponBatchItem record); - List getBatchIdList(@Param("couponIds")List couponIds,@Param("tenantId")String tenantId,@Param("pressBatchStatus")Integer pressBatchStatus); + List getBatchIdList(@Param("couponIds")List couponIds,@Param("tenantId")String tenantId,@Param("couponBatchStatus")Integer couponBatchStatus); WxCouponBatchItem getById(@Param("id")Long id,@Param("tenantId")String tenantId); - void updateWxPressBatchStatus(WxCouponBatchItem record); + void updateWxCouponBatchItemStatus(WxCouponBatchItem record); void deleteItem(WxCouponBatchItem record); void deleteAllItem(WxCouponBatchItem record); - List getCouponIds(@Param("pressBatchId")Long pressBatchId,@Param("tenantId")String tenantId,@Param("pressBatchStatus")Integer pressBatchStatus); + List getCouponIds(@Param("couponBatchId")Long pressBatchId,@Param("tenantId")String tenantId,@Param("couponBatchStatus")Integer pressBatchStatus); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java index 0de24417d..814938ae4 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java @@ -164,7 +164,7 @@ public class WxCouponBatchServiceImpl implements WxCouponBatchService { item.updateTenantInfo(pressBatch); item.setCouponBatchId(pressBatch.getId()); item.setCouponBatchStatus(pressBatch.getStatus()); - wxCouponBatchItemMapper.updateWxPressBatchStatus(item); + wxCouponBatchItemMapper.updateWxCouponBatchItemStatus(item); } @Override diff --git a/mallinkService/src/main/resources/mapper/WxCouponBatchItemMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponBatchItemMapper.xml index 4dafcdb2a..a86cd8c1f 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponBatchItemMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponBatchItemMapper.xml @@ -28,16 +28,16 @@ and `parent_tenant_id` = #{parentTenantId} - - and `press_batch_id` = #{pressBatchId} + + and `coupon_batch_id` = #{couponBatchId} and `coupon_id` = #{couponId} - - and `press_batch_status` = #{pressBatchStatus} + + and `coupon_batch_status` = #{couponBatchStatus} @@ -59,7 +59,7 @@ - + update wx_coupon_batch_item set coupon_batch_status = #{couponBatchStatus} where `coupon_batch_id` = #{couponBatchId} and tenant_id=#{tenantId} From 7984e65734e2b29524e6e4187d891463ee9b0df2 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 6 Mar 2023 15:36:04 +0800 Subject: [PATCH 2/6] fix bug --- .../src/main/java/com/iformall/mapper/WxCouponBatchMapper.java | 2 +- .../com/iformall/service/impl/WxCouponBatchServiceImpl.java | 2 +- .../src/main/resources/mapper/WxCouponBatchMapper.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchMapper.java index f376a8a66..6cf245201 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponBatchMapper.java @@ -12,7 +12,7 @@ public interface WxCouponBatchMapper extends CommonMapper { WxCouponBatch getById(@Param("id")Long id,@Param("tenantId")String tenantId); - void updateWxPressBatchStatus(WxCouponBatch record); + void updateWxCouponBatchStatus(WxCouponBatch record); void deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java index 814938ae4..d2699d090 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java @@ -159,7 +159,7 @@ public class WxCouponBatchServiceImpl implements WxCouponBatchService { @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) @Override public void updateStatus(WxCouponBatch pressBatch) { - wxCouponBatchMapper.updateWxPressBatchStatus(pressBatch); + wxCouponBatchMapper.updateWxCouponBatchStatus(pressBatch); WxCouponBatchItem item = new WxCouponBatchItem(); item.updateTenantInfo(pressBatch); item.setCouponBatchId(pressBatch.getId()); diff --git a/mallinkService/src/main/resources/mapper/WxCouponBatchMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponBatchMapper.xml index 0ef271efb..f6b5aebff 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponBatchMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponBatchMapper.xml @@ -57,7 +57,7 @@ select from wx_coupon_batch where `id` = #{id} and tenant_id=#{tenantId} - + update wx_coupon_batch set status = #{status} where `id` = #{id} and tenant_id=#{tenantId} From c73fb4581d03d528bf9b90f8bf47f49af35a09e1 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 6 Mar 2023 16:12:41 +0800 Subject: [PATCH 3/6] fix bug --- .../main/java/com/iformall/service/WxCouponBatchService.java | 2 +- .../com/iformall/service/impl/WxCouponBatchServiceImpl.java | 2 +- .../main/java/com/iformall/service/impl/WxOrderServiceImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponBatchService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponBatchService.java index bf6b2a051..3a0eb4468 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponBatchService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponBatchService.java @@ -55,6 +55,6 @@ public interface WxCouponBatchService { void updateStatus(WxCouponBatch pressBatch); - CouponBatchVo getCouponPressBatch(WxCoupon coupon, Long cUserId); + CouponBatchVo getCouponBatch(WxCoupon coupon, Long cUserId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java index d2699d090..8121f8f8e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponBatchServiceImpl.java @@ -168,7 +168,7 @@ public class WxCouponBatchServiceImpl implements WxCouponBatchService { } @Override - public CouponBatchVo getCouponPressBatch(WxCoupon coupon, Long cUserId) { + public CouponBatchVo getCouponBatch(WxCoupon coupon, Long cUserId) { WxCouponBatchItem query = new WxCouponBatchItem(); query.updateTenantInfo(coupon); query.setCouponId(coupon.getId()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index f089be994..219db373c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -842,7 +842,7 @@ public class WxOrderServiceImpl implements WxOrderService { } private void checkCouponBatchRule(WxCoupon counpon,WxCouponOrder couponOrderQ,WxCUserBasicInfo user) { - CouponBatchVo checkPressResult = wxCouponBatchService.getCouponPressBatch(counpon, user.getId()); + CouponBatchVo checkPressResult = wxCouponBatchService.getCouponBatch(counpon, user.getId()); if (null != checkPressResult) { WxCouponBatch pressBatch = checkPressResult.getCouponBatch(); List cids = checkPressResult.getCouponIdList(); From f213bc01551c1900d26c581306cf18d82873f689 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 6 Mar 2023 16:18:35 +0800 Subject: [PATCH 4/6] fix coupon batch --- .../iformall/config/BaseMyBatisConfiguration.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java b/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java index 4faf77d3c..add3e55d6 100644 --- a/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java +++ b/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java @@ -337,6 +337,20 @@ public class BaseMyBatisConfiguration { wxCarPayOrderSharding.setRule(EnumShardingRule.HASH.getCode()); shardingList.add(wxCarPayOrderSharding); + ShardingSphere wxCouponBatchSharding = new ShardingSphere(); + wxCouponBatchSharding.setColumn("tenant_id"); + wxCouponBatchSharding.setTableName("wx_coupon_batch"); + wxCouponBatchSharding.setCount(100); + wxCouponBatchSharding.setRule(EnumShardingRule.HASH.getCode()); + shardingList.add(wxCouponBatchSharding); + + ShardingSphere wxCouponBatchItemSharding = new ShardingSphere(); + wxCouponBatchItemSharding.setColumn("tenant_id"); + wxCouponBatchItemSharding.setTableName("wx_coupon_batch_item"); + wxCouponBatchItemSharding.setCount(100); + wxCouponBatchItemSharding.setRule(EnumShardingRule.HASH.getCode()); + shardingList.add(wxCouponBatchItemSharding); + //初始化 shardingSpherePlugin.setShardingSpheres(shardingList); Properties properties = new Properties(); From deaddce341c85a2282edb8264203b154987e8517 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 6 Mar 2023 16:27:39 +0800 Subject: [PATCH 5/6] fix bug --- .../V2023030800001__coupon_press.sql | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/mallinkAdmin/src/main/resources/db/migration/V2023030800001__coupon_press.sql b/mallinkAdmin/src/main/resources/db/migration/V2023030800001__coupon_press.sql index 7444ea748..7ecc6f305 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2023030800001__coupon_press.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2023030800001__coupon_press.sql @@ -22,3 +22,209 @@ CREATE TABLE `wx_coupon_batch_item` ( `parent_tenant_id` varchar(5) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +create table wx_coupon_batch_0 like wx_coupon_batch; +create table wx_coupon_batch_1 like wx_coupon_batch; +create table wx_coupon_batch_2 like wx_coupon_batch; +create table wx_coupon_batch_3 like wx_coupon_batch; +create table wx_coupon_batch_4 like wx_coupon_batch; +create table wx_coupon_batch_5 like wx_coupon_batch; +create table wx_coupon_batch_6 like wx_coupon_batch; +create table wx_coupon_batch_7 like wx_coupon_batch; +create table wx_coupon_batch_8 like wx_coupon_batch; +create table wx_coupon_batch_9 like wx_coupon_batch; +create table wx_coupon_batch_10 like wx_coupon_batch; +create table wx_coupon_batch_11 like wx_coupon_batch; +create table wx_coupon_batch_12 like wx_coupon_batch; +create table wx_coupon_batch_13 like wx_coupon_batch; +create table wx_coupon_batch_14 like wx_coupon_batch; +create table wx_coupon_batch_15 like wx_coupon_batch; +create table wx_coupon_batch_16 like wx_coupon_batch; +create table wx_coupon_batch_17 like wx_coupon_batch; +create table wx_coupon_batch_18 like wx_coupon_batch; +create table wx_coupon_batch_19 like wx_coupon_batch; +create table wx_coupon_batch_20 like wx_coupon_batch; +create table wx_coupon_batch_21 like wx_coupon_batch; +create table wx_coupon_batch_22 like wx_coupon_batch; +create table wx_coupon_batch_23 like wx_coupon_batch; +create table wx_coupon_batch_24 like wx_coupon_batch; +create table wx_coupon_batch_25 like wx_coupon_batch; +create table wx_coupon_batch_26 like wx_coupon_batch; +create table wx_coupon_batch_27 like wx_coupon_batch; +create table wx_coupon_batch_28 like wx_coupon_batch; +create table wx_coupon_batch_29 like wx_coupon_batch; +create table wx_coupon_batch_30 like wx_coupon_batch; +create table wx_coupon_batch_31 like wx_coupon_batch; +create table wx_coupon_batch_32 like wx_coupon_batch; +create table wx_coupon_batch_33 like wx_coupon_batch; +create table wx_coupon_batch_34 like wx_coupon_batch; +create table wx_coupon_batch_35 like wx_coupon_batch; +create table wx_coupon_batch_36 like wx_coupon_batch; +create table wx_coupon_batch_37 like wx_coupon_batch; +create table wx_coupon_batch_38 like wx_coupon_batch; +create table wx_coupon_batch_39 like wx_coupon_batch; +create table wx_coupon_batch_40 like wx_coupon_batch; +create table wx_coupon_batch_41 like wx_coupon_batch; +create table wx_coupon_batch_42 like wx_coupon_batch; +create table wx_coupon_batch_43 like wx_coupon_batch; +create table wx_coupon_batch_44 like wx_coupon_batch; +create table wx_coupon_batch_45 like wx_coupon_batch; +create table wx_coupon_batch_46 like wx_coupon_batch; +create table wx_coupon_batch_47 like wx_coupon_batch; +create table wx_coupon_batch_48 like wx_coupon_batch; +create table wx_coupon_batch_49 like wx_coupon_batch; +create table wx_coupon_batch_50 like wx_coupon_batch; +create table wx_coupon_batch_51 like wx_coupon_batch; +create table wx_coupon_batch_52 like wx_coupon_batch; +create table wx_coupon_batch_53 like wx_coupon_batch; +create table wx_coupon_batch_54 like wx_coupon_batch; +create table wx_coupon_batch_55 like wx_coupon_batch; +create table wx_coupon_batch_56 like wx_coupon_batch; +create table wx_coupon_batch_57 like wx_coupon_batch; +create table wx_coupon_batch_58 like wx_coupon_batch; +create table wx_coupon_batch_59 like wx_coupon_batch; +create table wx_coupon_batch_60 like wx_coupon_batch; +create table wx_coupon_batch_61 like wx_coupon_batch; +create table wx_coupon_batch_62 like wx_coupon_batch; +create table wx_coupon_batch_63 like wx_coupon_batch; +create table wx_coupon_batch_64 like wx_coupon_batch; +create table wx_coupon_batch_65 like wx_coupon_batch; +create table wx_coupon_batch_66 like wx_coupon_batch; +create table wx_coupon_batch_67 like wx_coupon_batch; +create table wx_coupon_batch_68 like wx_coupon_batch; +create table wx_coupon_batch_69 like wx_coupon_batch; +create table wx_coupon_batch_70 like wx_coupon_batch; +create table wx_coupon_batch_71 like wx_coupon_batch; +create table wx_coupon_batch_72 like wx_coupon_batch; +create table wx_coupon_batch_73 like wx_coupon_batch; +create table wx_coupon_batch_74 like wx_coupon_batch; +create table wx_coupon_batch_75 like wx_coupon_batch; +create table wx_coupon_batch_76 like wx_coupon_batch; +create table wx_coupon_batch_77 like wx_coupon_batch; +create table wx_coupon_batch_78 like wx_coupon_batch; +create table wx_coupon_batch_79 like wx_coupon_batch; +create table wx_coupon_batch_80 like wx_coupon_batch; +create table wx_coupon_batch_81 like wx_coupon_batch; +create table wx_coupon_batch_82 like wx_coupon_batch; +create table wx_coupon_batch_83 like wx_coupon_batch; +create table wx_coupon_batch_84 like wx_coupon_batch; +create table wx_coupon_batch_85 like wx_coupon_batch; +create table wx_coupon_batch_86 like wx_coupon_batch; +create table wx_coupon_batch_87 like wx_coupon_batch; +create table wx_coupon_batch_88 like wx_coupon_batch; +create table wx_coupon_batch_89 like wx_coupon_batch; +create table wx_coupon_batch_90 like wx_coupon_batch; +create table wx_coupon_batch_91 like wx_coupon_batch; +create table wx_coupon_batch_92 like wx_coupon_batch; +create table wx_coupon_batch_93 like wx_coupon_batch; +create table wx_coupon_batch_94 like wx_coupon_batch; +create table wx_coupon_batch_95 like wx_coupon_batch; +create table wx_coupon_batch_96 like wx_coupon_batch; +create table wx_coupon_batch_97 like wx_coupon_batch; +create table wx_coupon_batch_98 like wx_coupon_batch; +create table wx_coupon_batch_99 like wx_coupon_batch; + +drop table wx_coupon_batch; + +create table wx_coupon_batch_item_0 like wx_coupon_batch_item; +create table wx_coupon_batch_item_1 like wx_coupon_batch_item; +create table wx_coupon_batch_item_2 like wx_coupon_batch_item; +create table wx_coupon_batch_item_3 like wx_coupon_batch_item; +create table wx_coupon_batch_item_4 like wx_coupon_batch_item; +create table wx_coupon_batch_item_5 like wx_coupon_batch_item; +create table wx_coupon_batch_item_6 like wx_coupon_batch_item; +create table wx_coupon_batch_item_7 like wx_coupon_batch_item; +create table wx_coupon_batch_item_8 like wx_coupon_batch_item; +create table wx_coupon_batch_item_9 like wx_coupon_batch_item; +create table wx_coupon_batch_item_10 like wx_coupon_batch_item; +create table wx_coupon_batch_item_11 like wx_coupon_batch_item; +create table wx_coupon_batch_item_12 like wx_coupon_batch_item; +create table wx_coupon_batch_item_13 like wx_coupon_batch_item; +create table wx_coupon_batch_item_14 like wx_coupon_batch_item; +create table wx_coupon_batch_item_15 like wx_coupon_batch_item; +create table wx_coupon_batch_item_16 like wx_coupon_batch_item; +create table wx_coupon_batch_item_17 like wx_coupon_batch_item; +create table wx_coupon_batch_item_18 like wx_coupon_batch_item; +create table wx_coupon_batch_item_19 like wx_coupon_batch_item; +create table wx_coupon_batch_item_20 like wx_coupon_batch_item; +create table wx_coupon_batch_item_21 like wx_coupon_batch_item; +create table wx_coupon_batch_item_22 like wx_coupon_batch_item; +create table wx_coupon_batch_item_23 like wx_coupon_batch_item; +create table wx_coupon_batch_item_24 like wx_coupon_batch_item; +create table wx_coupon_batch_item_25 like wx_coupon_batch_item; +create table wx_coupon_batch_item_26 like wx_coupon_batch_item; +create table wx_coupon_batch_item_27 like wx_coupon_batch_item; +create table wx_coupon_batch_item_28 like wx_coupon_batch_item; +create table wx_coupon_batch_item_29 like wx_coupon_batch_item; +create table wx_coupon_batch_item_30 like wx_coupon_batch_item; +create table wx_coupon_batch_item_31 like wx_coupon_batch_item; +create table wx_coupon_batch_item_32 like wx_coupon_batch_item; +create table wx_coupon_batch_item_33 like wx_coupon_batch_item; +create table wx_coupon_batch_item_34 like wx_coupon_batch_item; +create table wx_coupon_batch_item_35 like wx_coupon_batch_item; +create table wx_coupon_batch_item_36 like wx_coupon_batch_item; +create table wx_coupon_batch_item_37 like wx_coupon_batch_item; +create table wx_coupon_batch_item_38 like wx_coupon_batch_item; +create table wx_coupon_batch_item_39 like wx_coupon_batch_item; +create table wx_coupon_batch_item_40 like wx_coupon_batch_item; +create table wx_coupon_batch_item_41 like wx_coupon_batch_item; +create table wx_coupon_batch_item_42 like wx_coupon_batch_item; +create table wx_coupon_batch_item_43 like wx_coupon_batch_item; +create table wx_coupon_batch_item_44 like wx_coupon_batch_item; +create table wx_coupon_batch_item_45 like wx_coupon_batch_item; +create table wx_coupon_batch_item_46 like wx_coupon_batch_item; +create table wx_coupon_batch_item_47 like wx_coupon_batch_item; +create table wx_coupon_batch_item_48 like wx_coupon_batch_item; +create table wx_coupon_batch_item_49 like wx_coupon_batch_item; +create table wx_coupon_batch_item_50 like wx_coupon_batch_item; +create table wx_coupon_batch_item_51 like wx_coupon_batch_item; +create table wx_coupon_batch_item_52 like wx_coupon_batch_item; +create table wx_coupon_batch_item_53 like wx_coupon_batch_item; +create table wx_coupon_batch_item_54 like wx_coupon_batch_item; +create table wx_coupon_batch_item_55 like wx_coupon_batch_item; +create table wx_coupon_batch_item_56 like wx_coupon_batch_item; +create table wx_coupon_batch_item_57 like wx_coupon_batch_item; +create table wx_coupon_batch_item_58 like wx_coupon_batch_item; +create table wx_coupon_batch_item_59 like wx_coupon_batch_item; +create table wx_coupon_batch_item_60 like wx_coupon_batch_item; +create table wx_coupon_batch_item_61 like wx_coupon_batch_item; +create table wx_coupon_batch_item_62 like wx_coupon_batch_item; +create table wx_coupon_batch_item_63 like wx_coupon_batch_item; +create table wx_coupon_batch_item_64 like wx_coupon_batch_item; +create table wx_coupon_batch_item_65 like wx_coupon_batch_item; +create table wx_coupon_batch_item_66 like wx_coupon_batch_item; +create table wx_coupon_batch_item_67 like wx_coupon_batch_item; +create table wx_coupon_batch_item_68 like wx_coupon_batch_item; +create table wx_coupon_batch_item_69 like wx_coupon_batch_item; +create table wx_coupon_batch_item_70 like wx_coupon_batch_item; +create table wx_coupon_batch_item_71 like wx_coupon_batch_item; +create table wx_coupon_batch_item_72 like wx_coupon_batch_item; +create table wx_coupon_batch_item_73 like wx_coupon_batch_item; +create table wx_coupon_batch_item_74 like wx_coupon_batch_item; +create table wx_coupon_batch_item_75 like wx_coupon_batch_item; +create table wx_coupon_batch_item_76 like wx_coupon_batch_item; +create table wx_coupon_batch_item_77 like wx_coupon_batch_item; +create table wx_coupon_batch_item_78 like wx_coupon_batch_item; +create table wx_coupon_batch_item_79 like wx_coupon_batch_item; +create table wx_coupon_batch_item_80 like wx_coupon_batch_item; +create table wx_coupon_batch_item_81 like wx_coupon_batch_item; +create table wx_coupon_batch_item_82 like wx_coupon_batch_item; +create table wx_coupon_batch_item_83 like wx_coupon_batch_item; +create table wx_coupon_batch_item_84 like wx_coupon_batch_item; +create table wx_coupon_batch_item_85 like wx_coupon_batch_item; +create table wx_coupon_batch_item_86 like wx_coupon_batch_item; +create table wx_coupon_batch_item_87 like wx_coupon_batch_item; +create table wx_coupon_batch_item_88 like wx_coupon_batch_item; +create table wx_coupon_batch_item_89 like wx_coupon_batch_item; +create table wx_coupon_batch_item_90 like wx_coupon_batch_item; +create table wx_coupon_batch_item_91 like wx_coupon_batch_item; +create table wx_coupon_batch_item_92 like wx_coupon_batch_item; +create table wx_coupon_batch_item_93 like wx_coupon_batch_item; +create table wx_coupon_batch_item_94 like wx_coupon_batch_item; +create table wx_coupon_batch_item_95 like wx_coupon_batch_item; +create table wx_coupon_batch_item_96 like wx_coupon_batch_item; +create table wx_coupon_batch_item_97 like wx_coupon_batch_item; +create table wx_coupon_batch_item_98 like wx_coupon_batch_item; +create table wx_coupon_batch_item_99 like wx_coupon_batch_item; + +drop table wx_coupon_batch_item; \ No newline at end of file From bdac2742853906f4835ae48b15ec36b73d084c1c Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Tue, 7 Mar 2023 14:01:47 +0800 Subject: [PATCH 6/6] fix card --- .../market/WxCouponPasswordController.java | 105 ++++++++++++++++++ .../iformall/controller/mem/AsyncTask.java | 77 ++++++++++++- .../domain/vo/WxCardPriceTemplate.java | 24 ++++ .../service/WxCouponPasswordService.java | 4 + .../impl/WxCouponPasswordServiceImpl.java | 35 ++++++ .../java/com/iformall/utils/Constant.java | 3 + 6 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/domain/vo/WxCardPriceTemplate.java diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java index 2aaa55fed..acb8e8d46 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponPasswordController.java @@ -4,10 +4,13 @@ import com.github.pagehelper.PageInfo; import com.iformall.annotation.SystemControllerLog; import com.iformall.annotation.TenantIgnore; import com.iformall.common.ErrorCode; +import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.controller.base.BaseController; +import com.iformall.controller.mem.AsyncTask; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponPassword; import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; @@ -15,15 +18,27 @@ import com.iformall.domain.vo.WxCouponPasswordVo; import com.iformall.enums.EnumCouponPasswordStatus; import com.iformall.enums.EnumCouponSubsidyType; import com.iformall.enums.EnumYesOrNo; +import com.iformall.exception.MallinkException; import com.iformall.service.WxCouponPasswordService; +import com.iformall.utils.Constant; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; /** * @author gongbiao @@ -36,6 +51,13 @@ public class WxCouponPasswordController extends BaseController { @Autowired private WxCouponPasswordService wxCouponPasswordService; + + @Autowired + StringRedisTemplate stringRedisTemplate; + @Autowired + private AsyncTask asyncTask; + @Autowired + private String fmUploadDir; @ApiOperation("分页列表接口") @GetMapping("/list") @@ -136,6 +158,89 @@ public class WxCouponPasswordController extends BaseController { wxCouponPasswordService.setPrice(wxCouponPassword); return new ResultData(); } + + @TenantIgnore + @PostMapping(value = "/importPrice", consumes = "multipart/*") + @SystemControllerLog(description = "消费卡批量导入面额") + public ResultData importPrice(@RequestParam("file") MultipartFile mFile) { + if (mFile.isEmpty()) { + throw new MallinkException(Result.ERROR, "上传文件不能为空"); + } + //得到当前用户ID + final MallUserInfo user = getUser(); + String userId = "" + user.getId(); + String importKey = Constant.importCardPrice + userId; + + //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 + Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); + if (allCount) { + return new ResultData(Result.SUCCESS, "模板正在导入"); + } + + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); + stringRedisTemplate.expire(importKey,30,TimeUnit.MINUTES); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); + + String fpath = fmUploadDir; + File targetFile = new File(fpath); + if (!targetFile.exists()) { + targetFile.mkdirs(); + } + String fileName = "1.xlsx"; + int dot = mFile.getOriginalFilename().lastIndexOf('.'); + fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); + + File lFile = new File(fpath + File.separator + fileName); + + FileOutputStream fos = null; + BufferedInputStream fs = null; + try { + fos = new FileOutputStream(lFile); + fs = (BufferedInputStream) mFile.getInputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = fs.read(buffer)) != -1) { + fos.write(buffer, 0, len); + } + fos.close(); + fs.close(); + } catch (Exception e) { + stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); + logger.error(e.getMessage()); + return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); + logger.error(e.getMessage()); + return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); + } + } + if (fs != null) { + try { + fs.close(); + } catch (IOException e) { + stringRedisTemplate.expire(importKey,3,TimeUnit.SECONDS); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); + stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); + logger.error(e.getMessage()); + return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); + } + } + } + + asyncTask.importExcelData(lFile, user, importKey); + + return new ResultData(Result.SUCCESS, "模板正在导入"); + } } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java index e2af3637d..3046e2f68 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java @@ -9,8 +9,10 @@ import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxTags; import com.iformall.domain.vo.CUserBaseInfoT; import com.iformall.domain.vo.MerchantPoiT; +import com.iformall.domain.vo.WxCardPriceTemplate; import com.iformall.service.TtMerchantPoiService; import com.iformall.service.WxCUserBasicInfoService; +import com.iformall.service.WxCouponPasswordService; import com.iformall.service.WxTagsService; import org.apache.shiro.session.UnknownSessionException; import org.slf4j.Logger; @@ -36,6 +38,9 @@ public class AsyncTask { @Autowired private WxTagsService wxTagsService; + + @Autowired + private WxCouponPasswordService wxCouponPasswordService; @Autowired StringRedisTemplate stringRedisTemplate; @@ -46,7 +51,6 @@ public class AsyncTask { if (value == null) { value = ""; } - System.out.println(name + " + " + value.toString()); return super.importHandler(obj, name, value); } @@ -58,7 +62,17 @@ public class AsyncTask { if (value == null) { value = ""; } - System.out.println(name + " + " + value.toString()); + return super.importHandler(obj, name, value); + } + + } + + private class CardPriceExcelHandler extends ExcelDataHandlerDefaultImpl { + @Override + public Object importHandler(WxCardPriceTemplate obj, String name, Object value) { + if (value == null) { + value = ""; + } return super.importHandler(obj, name, value); } @@ -195,4 +209,63 @@ public class AsyncTask { } } } + + @Async + public void importCardPriceData(File file, MallUserInfo user, String importKey) { + ImportParams params = new ImportParams(); + // 需要验证 + params.setImportFields(new String[]{"卡ID", "面额(元)"}); + IExcelDataHandler handler = new AsyncTask.CardPriceExcelHandler(); + handler.setNeedHandlerFields(new String[]{"卡ID","面额(元)"}); + params.setNeedVerify(true); + + ExcelImportResult datalist = null; + + try { + datalist = ExcelImportUtil.importExcelMore(file, WxCardPriceTemplate.class, params); + } catch (Exception e) { + set_redis_value(importKey, "1", "0", "0", "1", true); + logger.error(e.getMessage()); + // 删除缓存文件 + file.delete(); + return; + } + // 删除缓存文件 + file.delete(); + + if(datalist == null) { + logger.error("导入模板失败: 模板数据解析失败"); + set_redis_value(importKey, "1", "0", "0", "1", true); + return; + } + + List successList = datalist.getList(); + List failList = datalist.getFailList(); + + logger.info("验证通过的数量: " + successList.size()); + logger.info("验证未通过的数量: " + failList.size()); + + int total = successList.size() + failList.size(); + int all_success = successList.size(); + int all_fail = failList.size(); + + //添加到redis里 + set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); + + if(successList.size() > 0) { + try { + successList.parallelStream().forEach(poiBase -> { + try { + wxCouponPasswordService.importPrice(user,importKey, poiBase); + } catch (UnknownSessionException ue) { + logger.error("session :"+ue.getMessage()); + } + }); + } catch (Exception e) { + set_redis_value(importKey, "1", "0", "0", "1", true); + e.printStackTrace(); + logger.error("导入模板失败:"+e.getMessage()); + } + } + } } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCardPriceTemplate.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCardPriceTemplate.java new file mode 100644 index 000000000..9bc6a8c94 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCardPriceTemplate.java @@ -0,0 +1,24 @@ +package com.iformall.domain.vo; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class WxCardPriceTemplate implements Serializable { + private static final long serialVersionUID = -2321650008236516884L; + + @NotNull + @Excel(name="卡密ID",width = 20,orderNum = "1") + @io.swagger.annotations.ApiModelProperty(value="ID",name="couponPasswordId") + private String couponPasswordId; + @NotNull + @Excel(name="面额(元)",width = 20,orderNum = "2") + @io.swagger.annotations.ApiModelProperty(value="面额(元)",name="price") + private String price; +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java index 4bb59eb04..c5feac64a 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponPasswordService.java @@ -1,8 +1,10 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxCouponPassword; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.WxCardPriceTemplate; import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; import com.iformall.domain.vo.WxCouponPasswordVo; @@ -79,4 +81,6 @@ public interface WxCouponPasswordService { void startOrStop(WxCouponPassword wxCouponPassword); void setPrice(WxCouponPassword wxCouponPassword); + + void importPrice(MallUserInfo user,String importKey, WxCardPriceTemplate template); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java index bfacf925b..69f415f54 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponPasswordServiceImpl.java @@ -3,6 +3,7 @@ package com.iformall.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.iformall.common.IdWorker; +import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCardInfo; import com.iformall.domain.po.WxCoupon; @@ -15,6 +16,7 @@ import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.EnumCouponOrderStatus; import com.iformall.enums.EnumCouponPasswordStatus; import com.iformall.enums.EnumYesOrNo; +import com.iformall.domain.vo.WxCardPriceTemplate; import com.iformall.domain.vo.WxCouponOrderBVo; import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; import com.iformall.domain.vo.WxCouponPasswordVo; @@ -34,6 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; @@ -48,6 +51,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.concurrent.TimeUnit; @Service public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { @@ -65,6 +69,9 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { @Autowired ExcelService excelService; + + @Autowired + StringRedisTemplate stringRedisTemplate; @Override public PageInfo listAsPage(WxCouponPassword record, Integer pageIndex, Integer pageSize) { @@ -340,5 +347,33 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { public void setPrice(WxCouponPassword wxCouponPassword) { wxCouponPasswordMapper.setPrice(wxCouponPassword); } + + @Override + public void importPrice(MallUserInfo user,String importKey, WxCardPriceTemplate template) { + if (StringUtils.isBlank(template.getCouponPasswordId())) { + stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); + logger.error("卡密ID为空", template.toString()); + return; + } + if (StringUtils.isBlank(template.getPrice())) { + stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); + logger.error("面额为空", template.toString()); + return; + } + + try { + WxCouponPassword password = new WxCouponPassword(); + password.updateTenantInfo(user); + password.setId(Long.parseLong(template.getCouponPasswordId())); + password.setPrice(new BigDecimal(template.getPrice()).multiply(new BigDecimal(100)).intValue()); + setPrice(password); + }catch(Exception e) { + stringRedisTemplate.opsForHash().increment(importKey, "processCount", 1); + logger.error("import price error.",e); + return; + } + stringRedisTemplate.opsForHash().increment(importKey,"processCount",1); + stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); + } } diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index 354969f6c..074818438 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -88,6 +88,9 @@ public class Constant { // 导入会员 public static final String importMemPrev = "importmem:"; public static final String importInvestCustomerPrev = "importinvestcustomer:"; + + //导入卡面额 + public static final String importCardPrice = "importCardPrice:"; // 导入POI public static final String importPoiPrev = "importpoi:";