From 86036f963e8427faed2b377ae4a756b9925d0f40 Mon Sep 17 00:00:00 2001 From: xhxu Date: Sat, 16 Apr 2022 13:10:06 +0800 Subject: [PATCH] //update test --- .../controller/market/WxCouponController.java | 4 ++- .../db/migration/V2022041100001__addpoi.sql | 6 ++++ .../controller/WxCouponController.java | 1 + .../iformall/service/impl/PosServiceImpl.java | 4 +++ .../iformall/douyin/web/bean/TtSpuSync.java | 3 ++ .../douyin/web/json/TtSpuSyncAdapter.java | 2 ++ .../com/iformall/enums/EnumCouponType.java | 10 +++--- .../impl/TtMerchantPoiServiceImpl.java | 31 ++++++++++++++++--- .../impl/WxCouponOrderServiceImpl.java | 7 +++-- 9 files changed, 54 insertions(+), 14 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index 7b72d4106..9413a5f8e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -89,7 +89,8 @@ public class WxCouponController extends BaseController { EnumCouponType.COUPON_DAIJIN.getCode(), EnumCouponType.COUPON_LIPIN.getCode(), EnumCouponType.COUPON_TINGCHE.getCode(), - EnumCouponType.COUPON_MULTIMCH.getCode()}; + EnumCouponType.COUPON_MULTIMCH.getCode(), + EnumCouponType.COUPON_DOUYIN.getCode()}; wxCoupon.setTypes(Arrays.asList(typeArray)); } @@ -122,6 +123,7 @@ public class WxCouponController extends BaseController { EnumCouponType.COUPON_LIPIN.getCode(), EnumCouponType.COUPON_TINGCHE.getCode(), EnumCouponType.COUPON_MULTIMCH.getCode(), + EnumCouponType.COUPON_DOUYIN.getCode(), EnumCouponType.COUPON_PRESS.getCode(), EnumCouponType.COUPON_PREORDER.getCode()}; diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022041100001__addpoi.sql b/mallinkAdmin/src/main/resources/db/migration/V2022041100001__addpoi.sql index 5e581f370..eb6231de0 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2022041100001__addpoi.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2022041100001__addpoi.sql @@ -2,3 +2,9 @@ INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, UPDATE `mallink`.`mall_sale_type` SET `menus` = '[1, 2, 4, 5, 6, 50, 105, 110, 201, 205, 202, 211, 212, 221, 222, 223, 251, 409, 410, 411, 416, 500, 502, 504, 505, 506, 507, 508, 511, 512, 521, 522, 523, 531, 532, 591, 592, 595, 602, 605, 606, 607, 610, 641, 671, 674, 675, 680, 711, 901, 902, 904, 907, 60702]' WHERE `id` = 11; + + +INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (647, '抖音券', 602, 'Y', NULL, 1, NULL, NULL, 'douyinCoupon', NULL, 0, 641); + + +UPDATE `mallink`.`mall_sale_type` SET `menus` = '[1, 2, 4, 5, 6, 50, 105, 110, 201, 205, 202, 211, 212, 221, 222, 223, 251, 409, 410, 411, 416, 500, 502, 504, 505, 506, 507, 508, 511, 512, 521, 522, 523, 531, 532, 591, 592, 595, 602, 605, 606, 607, 610, 641, 647, 671, 674, 675, 680, 711, 901, 902, 904, 907, 60702]' WHERE `id` = 11; diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index ba9bd9e83..3519b9c00 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -95,6 +95,7 @@ public class WxCouponController extends BaseController { EnumCouponType.COUPON_LIPIN.getCode(), EnumCouponType.COUPON_TINGCHE.getCode(), EnumCouponType.COUPON_MULTIMCH.getCode(), + EnumCouponType.COUPON_DOUYIN.getCode(), EnumCouponType.COUPON_PRESS.getCode(), EnumCouponType.COUPON_PREORDER.getCode()}; diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index 08a834d67..d7e29795b 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -416,6 +416,7 @@ public class PosServiceImpl implements PosService { // 2. 检查券类型 核销可用(4, 6, 8, 9) EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || + couponType.getCode().equals(EnumCouponType.COUPON_DOUYIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_LIPIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_PRESS.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_GROUP.getCode()) || @@ -455,6 +456,7 @@ public class PosServiceImpl implements PosService { // 2. 检查券类型 核销可用(4, 6, 8, 9) EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || + couponType.getCode().equals(EnumCouponType.COUPON_DOUYIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_LIPIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_PRESS.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_GROUP.getCode()) || @@ -508,6 +510,7 @@ public class PosServiceImpl implements PosService { // 2. 检查券类型 支付可用(1, 2, 6), EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || + couponType.getCode().equals(EnumCouponType.COUPON_DOUYIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_MANJIAN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_DAIJIN.getCode()))) { logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage()); @@ -568,6 +571,7 @@ public class PosServiceImpl implements PosService { // 2. 检查券类型 支付可用(1, 2, 6), EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || + couponType.getCode().equals(EnumCouponType.COUPON_DOUYIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_MANJIAN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_DAIJIN.getCode()))) { logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/douyin/web/bean/TtSpuSync.java b/mallinkService/src/main/java/com/iformall/douyin/web/bean/TtSpuSync.java index 8c944388a..f71840344 100644 --- a/mallinkService/src/main/java/com/iformall/douyin/web/bean/TtSpuSync.java +++ b/mallinkService/src/main/java/com/iformall/douyin/web/bean/TtSpuSync.java @@ -15,6 +15,8 @@ import java.util.List; public class TtSpuSync implements Serializable { private static final long serialVersionUID = -132141170587251217L; + + private String spuId;//接入方商品ID******************** /** * 入口信息 * entry_miniApp onject 小程序入口参数 @@ -56,6 +58,7 @@ public class TtSpuSync implements Serializable { private Boolean orderDependsOnDate;//下单是否依赖日期 private Integer spuType;//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券********** private Integer status;//SPU状态, 1 - 在线; 2 - 下线********** + private String statusDesc;//状态描述 private Integer stock;//库存********* diff --git a/mallinkService/src/main/java/com/iformall/douyin/web/json/TtSpuSyncAdapter.java b/mallinkService/src/main/java/com/iformall/douyin/web/json/TtSpuSyncAdapter.java index d45cd3296..bf724b920 100644 --- a/mallinkService/src/main/java/com/iformall/douyin/web/json/TtSpuSyncAdapter.java +++ b/mallinkService/src/main/java/com/iformall/douyin/web/json/TtSpuSyncAdapter.java @@ -76,6 +76,7 @@ public class TtSpuSyncAdapter implements JsonSerializer, JsonDeserial protected TtSpuSync convertFromJson(JsonObject json) { TtSpuSync spuSync = new TtSpuSync(); + spuSync.setSpuId(GsonHelper.getString(json, "spu_id")); spuSync.setEntryInfo(json.getAsJsonObject("entry_info")); String[] front_category_tags = GsonHelper.getStringArray(json, "front_category_tag"); if(front_category_tags != null){ @@ -111,6 +112,7 @@ public class TtSpuSyncAdapter implements JsonSerializer, JsonDeserial spuSync.setOrderDependsOnDate(GsonHelper.getBoolean(json, "order_depends_on_date")); spuSync.setSpuType(GsonHelper.getInteger(json, "spu_type")); spuSync.setStatus(GsonHelper.getInteger(json, "status")); + spuSync.setStatusDesc(GsonHelper.getString(json, "status_desc")); spuSync.setStock(GsonHelper.getInteger(json, "stock")); return spuSync; } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java index 0664215d3..1c5a70726 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponType.java @@ -16,6 +16,7 @@ public enum EnumCouponType { COUPON_LIPIN(4, "礼品券"), COUPON_TINGCHE(5, "停车券"), COUPON_MULTIMCH(6, "通用券"), + COUPON_DOUYIN(66, "抖音券"), COUPON_PRESS(8, "砍价券"), COUPON_GROUP(9, "团购券"), COUPON_PREORDER(10, "预购商品"), @@ -23,6 +24,7 @@ public enum EnumCouponType { COUPON_GIFT(12, "券礼包"), COUPON_CREDIT(50,"积分券"), COUPON_CREDIT_PARK(51,"积分停车券"), + CARD_MULTIMCH(100, "消费卡"), ; @@ -61,14 +63,10 @@ public enum EnumCouponType { return message; } - //只有通用,满减,代金,礼品才能同步poi + //只有抖音卷才能同步poi public static List getSpuSyncType(){ List typeList = new ArrayList<>(); - typeList.add(COUPON_MANJIAN.getCode()); - typeList.add(COUPON_DAIJIN.getCode()); - typeList.add(COUPON_TUANGOU.getCode()); - typeList.add(COUPON_LIPIN.getCode()); - typeList.add(COUPON_MULTIMCH.getCode()); + typeList.add(COUPON_DOUYIN.getCode()); return typeList; } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java index 40aeb232f..fdf3b7874 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java @@ -28,9 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -725,16 +723,39 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { TtSpuGet spuGet = new TtSpuGet(); spuGet.setSpuExtId(couponChannel.getId().toString()); spuGet.setNeedSpuDraft(true); - spuGet.setSpuDraftcount(10); + spuGet.setSpuDraftcount(3); try { TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet); - return new ResultData(spuGetResult); + //处理一下数据 + Map map = new HashMap<>(); + if(spuGetResult.getSpuDetail() != null){//线上数据 + TtSpuSync spuDetail = spuGetResult.getSpuDetail(); + map.put("spuDetail",handSpuSync(spuDetail)); + } + if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据 + TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0); + map.put("spuDraft",handSpuSync(spuDraft)); + } + return new ResultData(map); } catch (WxErrorException e) { logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage()); return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage()); } } + private Map handSpuSync(TtSpuSync spuSync){ + Map map = new HashMap<>(); + map.put("id",spuSync.getSpuExtId()); + map.put("spu_id",spuSync.getSpuId()); + map.put("name",spuSync.getName()); + map.put("price",spuSync.getPrice()); + map.put("origin_price",spuSync.getOriginPrice()); + map.put("stock",spuSync.getStock()); + map.put("status",spuSync.getStatus()); + map.put("status_desc",spuSync.getStatusDesc()); + return map; + } + @Override public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) { WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index bf10dfd66..8fb7845b6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -2471,6 +2471,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { // 2. 检查券类型 支付可用(1, 2, 6), EnumCouponType couponType = EnumCouponType.getEnum(couponOrderCVo.getCouponType()); if (!(couponType.getCode().equals(EnumCouponType.COUPON_MULTIMCH.getCode()) || + couponType.getCode().equals(EnumCouponType.COUPON_DOUYIN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_MANJIAN.getCode()) || couponType.getCode().equals(EnumCouponType.COUPON_DAIJIN.getCode()))) { logger.error(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT.getMessage()); @@ -2549,8 +2550,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); } if (!(wxCoupon.getType().equals(EnumCouponType.COUPON_MANJIAN.getCode()) || - wxCoupon.getType().equals(EnumCouponType.COUPON_DAIJIN.getCode()) || - wxCoupon.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()))) { + wxCoupon.getType().equals(EnumCouponType.COUPON_DOUYIN.getCode()) || + wxCoupon.getType().equals(EnumCouponType.COUPON_DAIJIN.getCode()) || + wxCoupon.getType().equals(EnumCouponType.COUPON_MULTIMCH.getCode()))) { logger.error("收银台不支持此券类型: " + wxCoupon.getType()); throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); } @@ -3028,6 +3030,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { typeList.add(EnumCouponType.COUPON_MANJIAN.getCode()); typeList.add(EnumCouponType.COUPON_DAIJIN.getCode()); typeList.add(EnumCouponType.COUPON_MULTIMCH.getCode()); + typeList.add(EnumCouponType.COUPON_DOUYIN.getCode()); couponQ.setTypes(typeList); List couponIds = wxCouponMapper.findIdList(couponQ); List realCouponIds = new ArrayList();