| @@ -71,6 +71,8 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| @@ -122,6 +124,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_customize_module", | |||
| "fengniao_map_config", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| @Override | |||
| @@ -5,7 +5,7 @@ INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, | |||
| INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (61202, '抖音物料', 612, 'Y', NULL, 1, NULL, NULL, 'ttpath', 'icon-wuliaoguanli-', 0, 61202); | |||
| INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (616, '批次活动', 6, 'Y', NULL, 0, NULL, NULL, NULL, 'icon-kehu', 0, 603); | |||
| INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (616, '营销批次', 6, 'Y', NULL, 0, NULL, NULL, NULL, 'icon-kehu', 0, 603); | |||
| UPDATE `mallink`.`mall_permission` SET `parent_id` = 616, `sort` = 6611 WHERE `id` = 6611; | |||
| INSERT INTO `mallink`.`mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (6610, '券批次管理', 616, 'Y', NULL, 1, NULL, NULL, 'couponbatch', NULL, 0, 6610); | |||
| @@ -0,0 +1,18 @@ | |||
| UPDATE `mallink`.`wx_third_party_config` SET `type` = 4 WHERE `type` = 2; | |||
| --测试 | |||
| --UPDATE `mallink`.`tt_merchant_poi` set `parent_tenant_id` = '1031' WHERE `tenant_id` in ('1032','1033','1034'); | |||
| --生产 | |||
| UPDATE `mallink`.`tt_merchant_poi` set `parent_tenant_id` = '1052' WHERE `tenant_id` in ('1049','1053','1054','1055','1056','1057','1058','1059'); | |||
| ALTER TABLE `mallink`.`tt_order_push_error` | |||
| MODIFY COLUMN `id` bigint(20) NOT NULL FIRST, | |||
| ADD COLUMN `main_id` bigint(20) NOT NULL COMMENT '主要ID' AFTER `parent_tenant_id`, | |||
| ADD COLUMN `msg_type` smallint(2) NOT NULL COMMENT 'EnumMsgRecordType' AFTER `main_id`, | |||
| ADD COLUMN `third_type` smallint(2) COMMENT 'EnumThirdPartyConfigType' AFTER `msg_type`; | |||
| @@ -60,6 +60,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| private static String[] filterSubTables = new String[] { | |||
| @@ -99,6 +100,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_customize_module", | |||
| "fengniao_map_config", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| @Override | |||
| @@ -65,6 +65,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| private static String[] filterSubTables = new String[] { | |||
| @@ -112,6 +113,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_customize_module", | |||
| "fengniao_map_config", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| @@ -46,8 +46,8 @@ public class MqBaseConsumer { | |||
| private FmInsideCouponVerifyMsgServiceImpl fmInsideCouponVerifyMsgService; | |||
| @Autowired | |||
| private FmInsideOrderRefundMsgServiceImpl fmInsideOrderRefundMsgService; | |||
| // @Autowired | |||
| // private FmInsideOrderPushMsgServiceImpl fmInsideOrderPushMsgService; | |||
| @Autowired | |||
| private FmInsideOrderPushMsgServiceImpl fmInsideOrderPushMsgService; | |||
| @Autowired | |||
| private FmInsideOrderPushDeliveryMsgServiceImpl fmInsideOrderPushDeliveryMsgServiceImpl; | |||
| @Autowired | |||
| @@ -169,8 +169,8 @@ public class MqBaseConsumer { | |||
| } | |||
| else if(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode().equals(baseMsg.getMsgType())) { | |||
| // 内部消息 - 订单同步 | |||
| // FmInsideOrderPushMsg msg = (FmInsideOrderPushMsg)JsonUtil.readValue(message,FmInsideOrderPushMsg.class); | |||
| // fmInsideOrderPushMsgService.send(msg); | |||
| FmInsideOrderPushMsg msg = (FmInsideOrderPushMsg)JsonUtil.readValue(message,FmInsideOrderPushMsg.class); | |||
| fmInsideOrderPushMsgService.send(msg); | |||
| } | |||
| else if(EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode().equals(baseMsg.getMsgType())) { | |||
| // 内部消息 - 2.0核销同步 | |||
| @@ -65,6 +65,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_merchant_b_user", | |||
| "wx_user_visit", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| private static String[] filterSubTables = new String[] { | |||
| @@ -112,6 +113,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_customize_module", | |||
| "fengniao_map_config", | |||
| "tt_goods_category", | |||
| "tt_merchant_poi", | |||
| }; | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.domain.po.TtOrderPushError; | |||
| import com.iformall.enums.EnumMsgRecordType; | |||
| import com.iformall.mapper.TtOrderPushErrorMapper; | |||
| import com.iformall.service.WxOrderService; | |||
| import org.slf4j.Logger; | |||
| @@ -29,11 +30,20 @@ public class TtOrderPushErrorSchedule { | |||
| List<TtOrderPushError> orderPushErrors = ttOrderPushErrorMapper.findList(new TtOrderPushError()); | |||
| if(orderPushErrors != null && orderPushErrors.size() > 0){ | |||
| for (TtOrderPushError error:orderPushErrors) { | |||
| try{ | |||
| wxOrderService.sendInsideOrderPushDeliveryMsg(error,null,error.getId()); | |||
| }catch(Exception e){ | |||
| logger.error("订单同步重试error"); | |||
| if(EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode().equals(error.getMsgType())){ | |||
| try{ | |||
| wxOrderService.sendInsideOrderPushDeliveryMsg(error,error.getMainId(),error.getThirdType()); | |||
| }catch(Exception e){ | |||
| logger.error("订单核销同步重试error"); | |||
| } | |||
| }else if(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode().equals(error.getMsgType())){ | |||
| try{ | |||
| wxOrderService.sendInsideOrderPushMsg(error,error.getMainId(),error.getThirdType()); | |||
| }catch(Exception e){ | |||
| logger.error("订单同步重试error"); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -14,7 +14,15 @@ import java.util.Date; | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class TtOrderPushError extends TenantEntity { | |||
| protected Long id;//batch_order_id | |||
| protected Long id;// | |||
| private Long mainId; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumMsgRecordType",name="msgType") | |||
| private Integer msgType; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumThirdPartyConfigType",name="thirdType") | |||
| private Integer thirdType; | |||
| @io.swagger.annotations.ApiModelProperty(value="errMsg",name="errMsg") | |||
| private String errMsg; | |||
| @@ -11,10 +11,13 @@ import lombok.ToString; | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class FmInsideOrderPushMsg extends BaseMsg{ | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "composeOrderId") | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "") | |||
| private Long batchOrderId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "couponOrderId") | |||
| private Long couponOrderId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "EnumThirdPartyConfigType", name = "thirdType") | |||
| private Integer thirdType; | |||
| } | |||
| @@ -58,6 +58,9 @@ public class WxOrderCouponVo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "来自(抖音来自poiId)", name = "fromId") | |||
| private String fromId; | |||
| @io.swagger.annotations.ApiModelProperty(value="有效日期-开始",name="validStartDate") | |||
| private Date validStartDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="有效日期-结束",name="validEndDate") | |||
| @@ -242,6 +245,7 @@ public class WxOrderCouponVo extends TenantEntity { | |||
| this.shippingType = o.getShippingType(); | |||
| this.shippingAddress = o.getShippingAddress(); | |||
| this.parentOrderId = o.getParentOrderId(); | |||
| this.fromId = o.getFromId(); | |||
| } | |||
| public void initByCoupon(WxCoupon c,boolean hasDetail) { | |||
| @@ -7,8 +7,10 @@ package com.iformall.enums; | |||
| public enum EnumThirdPartyConfigType { | |||
| WEIXIN(1, "微信"), | |||
| ALI(2, "支付宝"), | |||
| TOUTIAO(3, "今日头条"), | |||
| MALLCOO(4, "猫酷"), | |||
| GOOAGOO(5, "数衍科技"), | |||
| MALLCOO(2, "猫酷"), | |||
| ; | |||
| public static EnumThirdPartyConfigType getEnum(Integer code) { | |||
| @@ -6,6 +6,9 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxThirdPartyApi; | |||
| import com.iformall.domain.po.WxThirdPartyConfig; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mallcoo.biImport.BasicBi; | |||
| import com.iformall.mallcoo.biImport.BuyGroup; | |||
| import com.iformall.mallcoo.biImport.VerifyGroup; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.HttpUtil; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| @@ -137,14 +140,46 @@ public class MallcooHelper { | |||
| } | |||
| } | |||
| //BI数据推送 | |||
| public static String biImport(WxThirdPartyConfig config,Integer eventType,String eventData) { | |||
| String url = "https://openapi10.mallcoo.cn/BI/Event/v1/Data/Import/"; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| map.put("EventType",eventType); | |||
| map.put("EventData",eventData); | |||
| String response = doPost(config,url, map); | |||
| log.info("BI数据推送 request:"+JSON.toJSONString(map) | |||
| +" response:"+response); | |||
| JSONObject jsonObject = JSON.parseObject(response); | |||
| Integer code = jsonObject.getInteger("Code"); | |||
| if (null != code && code.intValue() == 1 ) { | |||
| JSONObject data = jsonObject.getJSONObject("Data"); | |||
| String traceID = data.getString("TraceID"); | |||
| return traceID; | |||
| }else{ | |||
| String message = jsonObject.getString("Message"); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),message); | |||
| } | |||
| } | |||
| public static String biImportDate(WxThirdPartyConfig config, BasicBi bi){ | |||
| if(bi instanceof BuyGroup){ | |||
| BuyGroup buyGroup = (BuyGroup) bi; | |||
| return biImport(config,buyGroup.getEventType(),JSON.toJSONString(buyGroup)); | |||
| }else if(bi instanceof VerifyGroup){ | |||
| VerifyGroup verifyGroup = (VerifyGroup) bi; | |||
| return biImport(config,verifyGroup.getEventType(),JSON.toJSONString(verifyGroup)); | |||
| } | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"数据类型错误"); | |||
| } | |||
| public static void main(String[] args) { | |||
| WxThirdPartyConfig config = new WxThirdPartyConfig(); | |||
| config.setAppId("625fa8b81c415a1114eab6d7"); | |||
| config.setAppKey("JV7kP9"); | |||
| config.setSignKey("12b51d39c3c1762d"); | |||
| config.setAppId("6385a2c9c3b5f5b90089e972"); | |||
| config.setAppKey("B0yuEJ"); | |||
| config.setSignKey("55d7cfff433b5101");//沧州吾悦 | |||
| String phone = "18872592633"; | |||
| // String phone = "18872592633"; | |||
| // String s = openByMobile(config, phone, null); | |||
| // System.out.println("-----"+s); | |||
| @@ -159,9 +194,28 @@ public class MallcooHelper { | |||
| // System.out.println("-----"+b); | |||
| McUserInfo byMobile = getByMobile(config, phone); | |||
| System.out.println("-----"+byMobile.toString()); | |||
| // McUserInfo byMobile = getByMobile(config, phone); | |||
| // System.out.println("-----"+byMobile.toString()); | |||
| BuyGroup buyGroup = new BuyGroup(); | |||
| buyGroup.setTime("2023-02-28 11:48:32"); | |||
| buyGroup.setUnique_id("790393475438768128"); | |||
| // buyGroup.setMember_card_id(""); | |||
| buyGroup.setMobile("18872592633"); | |||
| buyGroup.setEvent_source("抖音"); | |||
| buyGroup.setOrder_id("790393475438768128"); | |||
| buyGroup.setOrder_product_amount(1); | |||
| buyGroup.setOrder_total_price(2.90d); | |||
| buyGroup.setGroupon_id("790390072309346304"); | |||
| buyGroup.setGroupon_name("2.9团100美食现金券"); | |||
| buyGroup.setPayment_method("支付宝"); | |||
| buyGroup.setPayment_amount(2.90d); | |||
| // buyGroup.setBonus_amount(); | |||
| buyGroup.setPage_ref_id("790390072309346304"); | |||
| buyGroup.setPage_ref_name("2.9团100美食现金券"); | |||
| String s = biImportDate(config, buyGroup); | |||
| System.out.println(s); | |||
| } | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.iformall.mallcoo.biImport; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| public class BasicBi { | |||
| private String time;//时间 | |||
| private String unique_id;//唯一ID | |||
| private String member_card_id;//(member_card_id、mobile任一必填) | |||
| private String mobile;//(member_card_id、mobile任一必填) | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package com.iformall.mallcoo.biImport; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.Data; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @Data | |||
| public class BuyGroup extends BasicBi{ | |||
| @JsonIgnore | |||
| private Integer eventType= EnumBiEventType.buy.getCode(); | |||
| private String event_source;//事件来源:安卓、IOS、微信 | |||
| private String order_id;//订单号 | |||
| private Integer order_product_amount;//订单商品数量 | |||
| private Double order_total_price;//订单总价 | |||
| private String groupon_id;//团购ID | |||
| private String groupon_name;//团购名称 | |||
| private String payment_method;//支付方式:现金、银行卡等 | |||
| private Double payment_amount;//实收金额 | |||
| private Double bonus_amount;//积分抵扣金额 | |||
| private String page_ref_id;//页面关联ID | |||
| private String page_ref_name;//页面关联名称 | |||
| } | |||
| @@ -0,0 +1,35 @@ | |||
| package com.iformall.mallcoo.biImport; | |||
| import com.iformall.enums.EnumActivityType; | |||
| public enum EnumBiEventType { | |||
| buy(901001, "购买团购"), | |||
| verify(901002, "核销团购"), | |||
| refund(901003, "退货团购"); | |||
| public static EnumBiEventType getEnum(Integer code) { | |||
| for (EnumBiEventType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumBiEventType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package com.iformall.mallcoo.biImport; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import lombok.Data; | |||
| @Data | |||
| public class VerifyGroup extends BasicBi{ | |||
| @JsonIgnore | |||
| private Integer eventType= EnumBiEventType.buy.getCode(); | |||
| private String event_source;//事件来源:安卓、IOS、微信 | |||
| private String order_id;//订单号 | |||
| private Integer order_product_amount;//订单商品数量 | |||
| private Double order_total_price;//订单总价 | |||
| private String groupon_id;//团购ID | |||
| private String groupon_name;//团购名称 | |||
| private String payment_method;//支付方式:现金、银行卡等 | |||
| private Double payment_amount;//实收金额 | |||
| private Double verification_amount;//核销金额 | |||
| private Integer verification_product_amount;//核销商品数量 | |||
| private String shop_name;//页面关联ID | |||
| private String shop_code;//页面关联名称 | |||
| private String page_ref_id;//页面关联ID | |||
| private String page_ref_name;//页面关联名称 | |||
| } | |||
| @@ -9,6 +9,4 @@ public interface TtOrderPushErrorMapper extends CommonMapper<TtOrderPushError, L | |||
| List<TtOrderPushError> findList(TtOrderPushError record); | |||
| List<Long> findIdList(TtOrderPushError record); | |||
| } | |||
| @@ -29,5 +29,17 @@ public interface MallCooUserInfoService { | |||
| void pullByMobile(TenantEntity tenantEntity, Long basicUserId); | |||
| void pullByMobileMsg(TenantEntity tenantEntity, Long id); | |||
| String payOrderMallCooPush(TenantEntity tenantEntity,WxCUserBasicInfo basicInfo,WxBatchOrder batchOrder,WxPayOrder payOrder); | |||
| String verifyOrderMallCooPush(TenantEntity tenantEntity, WxCUserBasicInfo basicInfo, WxCoupon coupon, WxCouponOrder couponOrder,WxOrder order,WxPayOrder payOrder,WxMerchant merchant); | |||
| /** | |||
| * 通过下订单获取广场 | |||
| * @param | |||
| * @param basicInfo | |||
| * @return | |||
| */ | |||
| TenantEntity getMallCooPushTenant(TenantEntity tenantEntity,WxCUserBasicInfo basicInfo,String fromId); | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.domain.po.WxBatchOrder; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| /** | |||
| * @author | |||
| */ | |||
| public interface TtOrderPushErrorService { | |||
| int saveOrUpdate(TenantEntity tenantEntity, Long mainId, Integer msgType, Integer thirdType, String msg); | |||
| int deleteSuccess(TenantEntity tenantEntity, Long mainId, Integer msgType, Integer thirdType); | |||
| } | |||
| @@ -251,9 +251,9 @@ public interface WxOrderService { | |||
| ResultData composeSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<OrderComposeSaveDto> composeOrderSaveDto,Long cUserId,EnumPayWay payWay, | |||
| TenantEntity tenantEntity,EnumPayVersion payVersion); | |||
| void sendInsideOrderPushMsg(TenantEntity tenantEntity,Long composeOrderId); | |||
| void sendInsideOrderPushMsg(TenantEntity tenantEntity,Long composeOrderId,Integer thirdType); | |||
| void sendInsideOrderPushDeliveryMsg(TenantEntity couponOrderTenantEntity,Long composeOrderId,Long couponOrderId); | |||
| void sendInsideOrderPushDeliveryMsg(TenantEntity couponOrderTenantEntity,Long couponOrderId,Integer thirdType); | |||
| PageInfo<WxOrderCouponVo> listGoodsCAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); | |||
| @@ -3,28 +3,40 @@ package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.FmInsideBasicUserPushMsg; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mallcoo.MallcooHelper; | |||
| import com.iformall.mallcoo.McUserInfo; | |||
| import com.iformall.mallcoo.biImport.BuyGroup; | |||
| import com.iformall.mallcoo.biImport.VerifyGroup; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.miniApp.EnumTtPayChannel; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class MallCooUserInfoServiceImpl implements MallCooUserInfoService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMallService wxMallService; | |||
| @Autowired | |||
| MallCooUserInfoMapper mallCooUserInfoMapper; | |||
| @@ -34,6 +46,9 @@ public class MallCooUserInfoServiceImpl implements MallCooUserInfoService { | |||
| @Autowired | |||
| WxThirdPartyConfigMapper wxThirdPartyConfigMapper; | |||
| @Autowired | |||
| TtMerchantPoiMapper ttMerchantPoiMapper; | |||
| @Autowired | |||
| private MqBaseProducer mqBaseProducer; | |||
| @@ -112,6 +127,114 @@ public class MallCooUserInfoServiceImpl implements MallCooUserInfoService { | |||
| } | |||
| @Override | |||
| public String payOrderMallCooPush(TenantEntity tenantEntity,WxCUserBasicInfo basicInfo,WxBatchOrder batchOrder,WxPayOrder payOrder) { | |||
| WxThirdPartyConfig config = getThirdPartyConfig(tenantEntity); | |||
| if(config == null){ | |||
| logger.error("未找到猫酷配置信息"); | |||
| return "未找到猫酷配置信息"; | |||
| } | |||
| WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | |||
| BuyGroup buyGroup = new BuyGroup(); | |||
| buyGroup.setTime(DateUtils.date2String(batchOrder.getCreateDate())); | |||
| buyGroup.setUnique_id(batchOrder.getId().toString()); | |||
| // buyGroup.setMember_card_id(""); | |||
| buyGroup.setMobile(basicInfo.getPhone()); | |||
| buyGroup.setEvent_source("测试");//抖音 | |||
| buyGroup.setOrder_id(batchOrder.getId().toString()); | |||
| buyGroup.setOrder_product_amount(wxOrderCouponVo.getCouponNumber()); | |||
| double salePrice = new BigDecimal(wxOrderCouponVo.getSalePrice()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| buyGroup.setOrder_total_price(salePrice); | |||
| buyGroup.setGroupon_id(wxOrderCouponVo.getProductId().toString()); | |||
| buyGroup.setGroupon_name(wxOrderCouponVo.getTitle()); | |||
| EnumTtPayChannel payWay = EnumTtPayChannel.getEnum(payOrder.getTtPayWay()); | |||
| if(payWay != null){ | |||
| buyGroup.setPayment_method(payWay.getMessage()); | |||
| } | |||
| double payment = new BigDecimal(payOrder.getPayAmount()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| buyGroup.setPayment_amount(payment); | |||
| // buyGroup.setBonus_amount(); | |||
| buyGroup.setPage_ref_id(wxOrderCouponVo.getProductId().toString()); | |||
| buyGroup.setPage_ref_name(wxOrderCouponVo.getTitle()); | |||
| String traceID = MallcooHelper.biImportDate(config, buyGroup); | |||
| return traceID; | |||
| } | |||
| @Override | |||
| public String verifyOrderMallCooPush(TenantEntity tenantEntity, WxCUserBasicInfo basicInfo, WxCoupon coupon, WxCouponOrder couponOrder,WxOrder order,WxPayOrder payOrder,WxMerchant merchant) { | |||
| WxThirdPartyConfig config = getThirdPartyConfig(tenantEntity); | |||
| if(config == null){ | |||
| logger.error("未找到猫酷配置信息"); | |||
| return "未找到猫酷配置信息"; | |||
| } | |||
| VerifyGroup verifyGroup = new VerifyGroup(); | |||
| verifyGroup.setTime(DateUtils.date2String(couponOrder.getUpdateDate())); | |||
| verifyGroup.setUnique_id(couponOrder.getId().toString()); | |||
| // buyGroup.setMember_card_id(""); | |||
| verifyGroup.setMobile(basicInfo.getPhone()); | |||
| verifyGroup.setEvent_source("测试");//抖音 | |||
| verifyGroup.setOrder_id(couponOrder.getComposeOrderId().toString()); | |||
| verifyGroup.setOrder_product_amount(order.getCouponNumber()); | |||
| double salePrice = new BigDecimal(order.getPayment()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| verifyGroup.setOrder_total_price(salePrice); | |||
| verifyGroup.setGroupon_id(coupon.getId().toString()); | |||
| verifyGroup.setGroupon_name(coupon.getTitle()); | |||
| EnumTtPayChannel payWay = EnumTtPayChannel.getEnum(payOrder.getTtPayWay()); | |||
| if(payWay != null){ | |||
| verifyGroup.setPayment_method(payWay.getMessage()); | |||
| } | |||
| double payment = new BigDecimal(payOrder.getPayAmount()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| verifyGroup.setPayment_amount(payment); | |||
| double couponPrice = new BigDecimal(coupon.getPrice()).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||
| verifyGroup.setVerification_amount(couponPrice); | |||
| verifyGroup.setVerification_product_amount(couponOrder.getCouponNumber()); | |||
| verifyGroup.setShop_name(merchant.getName()); | |||
| verifyGroup.setShop_code(merchant.getId().toString()); | |||
| verifyGroup.setPage_ref_id(couponOrder.getId().toString()); | |||
| verifyGroup.setPage_ref_name(coupon.getTitle()); | |||
| String traceID = MallcooHelper.biImportDate(config, verifyGroup); | |||
| return traceID; | |||
| } | |||
| @Override | |||
| public TenantEntity getMallCooPushTenant(TenantEntity tenantEntity,WxCUserBasicInfo basicInfo,String fromId) { | |||
| TenantEntity mallCooPushTenant = new TenantEntity(); | |||
| if(wxMallService.isgroupSupport(tenantEntity)){ | |||
| if(StringUtils.isNotBlank(fromId)){ | |||
| TtMerchantPoi poiQ = new TtMerchantPoi(); | |||
| poiQ.setParentTenantId(tenantEntity.getTenantId()); | |||
| poiQ.setPoiId(fromId); | |||
| List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poiQ); | |||
| if(poiList != null && poiList.isEmpty()){ | |||
| mallCooPushTenant.updateTenantInfo(poiList.get(0)); | |||
| } | |||
| } | |||
| if(StringUtils.isBlank(mallCooPushTenant.getTenantId())){ | |||
| String[] split = basicInfo.getTenantId().split(","); | |||
| for (String tenantId: split) { | |||
| if(StringUtils.isNotBlank(tenantId) && !tenantId.equals(tenantEntity.getTenantId())){ | |||
| mallCooPushTenant.setTenantId(tenantId); | |||
| mallCooPushTenant.setParentTenantId(tenantEntity.getTenantId()); | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| }else{ | |||
| mallCooPushTenant.updateTenantInfo(tenantEntity); | |||
| } | |||
| return mallCooPushTenant; | |||
| } | |||
| @Override | |||
| public void pullByMobileMsg(TenantEntity tenantEntity, Long id) { | |||
| FmInsideBasicUserPushMsg basicUserPushMsg = new FmInsideBasicUserPushMsg(); | |||
| @@ -0,0 +1,58 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.mapper.TtOrderPushErrorMapper; | |||
| import com.iformall.service.TtOrderPushErrorService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Date; | |||
| @Service | |||
| public class TtOrderPushErrorServiceImpl implements TtOrderPushErrorService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| TtOrderPushErrorMapper ttOrderPushErrorMapper; | |||
| @Override | |||
| public int saveOrUpdate(TenantEntity tenantEntity, Long mainId, Integer msgType, Integer thirdType, String msg) { | |||
| TtOrderPushError pushError = new TtOrderPushError(); | |||
| pushError.updateTenantInfo(tenantEntity); | |||
| pushError.setMainId(mainId); | |||
| pushError.setMsgType(msgType); | |||
| pushError.setThirdType(thirdType); | |||
| TtOrderPushError pushError1 = ttOrderPushErrorMapper.selectOne(new QueryWrapper<>(pushError)); | |||
| Date now = new Date(); | |||
| if(pushError1 == null){ | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| pushError.setId(idWorker.nextId()); | |||
| pushError.setErrMsg(msg); | |||
| pushError.setCreateDate(now); | |||
| pushError.setUpdateDate(now); | |||
| return ttOrderPushErrorMapper.insert(pushError); | |||
| }else{ | |||
| pushError1.setErrMsg(msg); | |||
| pushError1.setUpdateDate(now); | |||
| return ttOrderPushErrorMapper.updateById(pushError1); | |||
| } | |||
| } | |||
| @Override | |||
| public int deleteSuccess(TenantEntity tenantEntity, Long mainId, Integer msgType, Integer thirdType) { | |||
| TtOrderPushError pushError = new TtOrderPushError(); | |||
| pushError.updateTenantInfo(tenantEntity); | |||
| pushError.setMainId(mainId); | |||
| pushError.setMsgType(msgType); | |||
| pushError.setThirdType(thirdType); | |||
| return ttOrderPushErrorMapper.delete(new QueryWrapper<>(pushError)); | |||
| } | |||
| } | |||
| @@ -2216,6 +2216,8 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } catch (Exception e) { | |||
| logger.error("订单成功通知用户error:" + e.getMessage(),e); | |||
| } | |||
| //同步订单 | |||
| sendInsideOrderPushMsg(order,order.getComposeOrderId(),null); | |||
| } | |||
| private void sendMsgAfterCouponOrderSuccess(WxOrder order,WxCoupon coupon, WxCUserBasicInfo user) { | |||
| @@ -3541,35 +3543,35 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| @Override | |||
| public void sendInsideOrderPushMsg(TenantEntity tenantEntity,Long composeOrderId) { | |||
| // try{ | |||
| // FmInsideOrderPushMsg orderPush = new FmInsideOrderPushMsg(); | |||
| // orderPush.setDelayTimeLevel(5); | |||
| // orderPush.setMsgType(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode()); | |||
| // orderPush.updateTenantInfo(tenantEntity); | |||
| // orderPush.setBatchOrderId(composeOrderId); | |||
| // logger.info(">>>>>>>>>>>send sendInsideOrderPushMsg :"+orderPush); | |||
| // mqBaseProducer.sendMessage(orderPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| // }catch(Exception e){ | |||
| // logger.info(">>>>>>>>>>>send sendInsideOrderPushMsg : error"+e.getMessage()); | |||
| // } | |||
| public void sendInsideOrderPushMsg(TenantEntity tenantEntity,Long composeOrderId,Integer thirdType) { | |||
| try{ | |||
| FmInsideOrderPushMsg orderPush = new FmInsideOrderPushMsg(); | |||
| orderPush.setDelayTimeLevel(5); | |||
| orderPush.setMsgType(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode()); | |||
| orderPush.updateTenantInfo(tenantEntity); | |||
| orderPush.setBatchOrderId(composeOrderId); | |||
| orderPush.setThirdType(thirdType); | |||
| logger.info(">>>>>>>>>>>send sendInsideOrderPushMsg :"+orderPush); | |||
| mqBaseProducer.sendMessage(orderPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| }catch(Exception e){ | |||
| logger.info(">>>>>>>>>>>send sendInsideOrderPushMsg : error"+e.getMessage()); | |||
| } | |||
| } | |||
| @Override | |||
| public void sendInsideOrderPushDeliveryMsg(TenantEntity couponOrderTenantEntity, Long composeOrderId,Long couponOrderId) { | |||
| public void sendInsideOrderPushDeliveryMsg(TenantEntity couponOrderTenantEntity, Long couponOrderId,Integer thirdType) { | |||
| try{ | |||
| FmInsideOrderPushMsg orderPush = new FmInsideOrderPushMsg(); | |||
| orderPush.setDelayTimeLevel(3); | |||
| orderPush.setMsgType(EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode()); | |||
| orderPush.updateTenantInfo(couponOrderTenantEntity); | |||
| //orderPush.setMallTenantEntity(mallTenantEntity); | |||
| orderPush.setBatchOrderId(composeOrderId); | |||
| orderPush.setCouponOrderId(couponOrderId); | |||
| logger.info(">>>>>>>>>>>send sendInsideOrderPushMsg :"+orderPush); | |||
| orderPush.setThirdType(thirdType); | |||
| logger.info(">>>>>>>>>>>send sendInsideOrderPushDeliveryMsg :"+orderPush); | |||
| mqBaseProducer.sendMessage(orderPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| }catch(Exception e){ | |||
| logger.info(">>>>>>>>>>>send sendInsideOrderPushMsg : error"+e.getMessage()); | |||
| logger.info(">>>>>>>>>>>send sendInsideOrderPushDeliveryMsg : error"+e.getMessage()); | |||
| } | |||
| } | |||
| @@ -58,7 +58,7 @@ public class FmInsideCouponVerifyMsgServiceImpl implements MsgSendService { | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "门店未找到" + msg.getMerchantId()); | |||
| } | |||
| orderService.sendInsideOrderPushDeliveryMsg(couponOrder,null,couponOrder.getId()); | |||
| orderService.sendInsideOrderPushDeliveryMsg(couponOrder,couponOrder.getId(),null); | |||
| // orderService.sendInsideOrderPushMsg(couponOrder,couponOrder.getComposeOrderId()); | |||
| wxCUserBasicInfoService.updateTenantIdMsg(couponOrder,merchant,couponOrder.getCUserId()); | |||
| @@ -7,13 +7,12 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| import com.iformall.domain.po.msg.FmInsideOrderPushMsg; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.douyin.pay.TtPayService; | |||
| import com.iformall.douyin.payv2.request.TtOrderPushDeliveryRequest; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.TtCUserMapper; | |||
| import com.iformall.mapper.TtOrderPushErrorMapper; | |||
| import com.iformall.mapper.WxPayOrderMapper; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.msg.MsgSendService; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| @@ -38,6 +37,9 @@ import java.util.List; | |||
| public class FmInsideOrderPushDeliveryMsgServiceImpl implements MsgSendService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @@ -60,7 +62,22 @@ public class FmInsideOrderPushDeliveryMsgServiceImpl implements MsgSendService { | |||
| private MaUtil maUtil; | |||
| @Autowired | |||
| private TtOrderPushErrorMapper ttOrderPushErrorMapper; | |||
| private TtOrderPushErrorService ttOrderPushErrorService; | |||
| @Autowired | |||
| private MallCooUserInfoService mallCooUserInfoService; | |||
| @Autowired | |||
| private WxPayOrderService wxPayOrderService; | |||
| @Autowired | |||
| private WxCouponMapper wxCouponMapper; | |||
| @Autowired | |||
| private WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||
| @Autowired | |||
| private TtMerchantPoiMapper ttMerchantPoiMapper; | |||
| @@ -81,66 +98,91 @@ public class FmInsideOrderPushDeliveryMsgServiceImpl implements MsgSendService { | |||
| // mallTenantEntity = tenantEntity; | |||
| // } | |||
| WxCouponOrder couponOrder = wxCouponOrderService.getById(msg.getCouponOrderId(), tenantEntity.getTenantId()); | |||
| if(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().equals(couponOrder.getCouponOrderStatus()) | |||
| && EnumPayWay.PAY_WAY_TT.getCode().equals(couponOrder.getPayVendor())){ | |||
| WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), couponOrder.getTenantId()); | |||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(), couponOrder.getTenantId()); | |||
| WxMerchant merchant = wxMerchantService.getById(couponOrder.getBMerchantId()); | |||
| if(msg.getThirdType() == null || EnumThirdPartyConfigType.TOUTIAO.getCode().equals(msg.getThirdType())){ | |||
| pushOrderTtDelivery(couponOrder,order,merchant); | |||
| } | |||
| if(msg.getThirdType() == null || EnumThirdPartyConfigType.MALLCOO.getCode().equals(msg.getThirdType())){ | |||
| pushOrderMallCooDelivery(couponOrder,order,wxCoupon,merchant); | |||
| } | |||
| } | |||
| } | |||
| private void pushOrderTtDelivery(WxCouponOrder couponOrder,WxOrder order,WxMerchant merchant){ | |||
| try{ | |||
| WxCouponOrder couponOrder = wxCouponOrderService.getById(msg.getCouponOrderId(), tenantEntity.getTenantId()); | |||
| if(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().equals(couponOrder.getCouponOrderStatus()) | |||
| && EnumPayWay.PAY_WAY_TT.getCode().equals(couponOrder.getPayVendor())){ | |||
| WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), tenantEntity.getTenantId()); | |||
| String itemOrderId = (String) order.getExpParamValue("itemOrderId"); | |||
| WxMerchant merchant = wxMerchantService.getById(couponOrder.getBMerchantId()); | |||
| String shop_name = merchant.getName(); | |||
| String ext_valid_shop_id = couponOrder.getBMerchantId().toString(); | |||
| TtMerchantPoi poi = ttMerchantPoiService.getById(couponOrder.getBMerchantId()); | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(couponOrder,EnumPayWay.PAY_WAY_TT.getPlat()); | |||
| WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | |||
| TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||
| TtOrderPushDeliveryRequest request = new TtOrderPushDeliveryRequest(); | |||
| request.setOutOrderNo(order.getComposeOrderId().toString()); | |||
| List<TtOrderPushDeliveryRequest.ItemOrder> itemOrderList = new ArrayList<>(); | |||
| TtOrderPushDeliveryRequest.ItemOrder itemOrder = new TtOrderPushDeliveryRequest.ItemOrder(); | |||
| itemOrder.setItemOrderId(itemOrderId); | |||
| itemOrderList.add(itemOrder); | |||
| request.setItemOrderList(itemOrderList); | |||
| JSONObject poiInfo = new JSONObject(); | |||
| poiInfo.put("shop_name",shop_name); | |||
| poiInfo.put("ext_valid_shop_id",ext_valid_shop_id); | |||
| if(poi != null){ | |||
| poiInfo.put("valid_poi_id_str",poi.getPoiId()); | |||
| } | |||
| request.setPoiInfo(poiInfo.toJSONString()); | |||
| boolean b = ttPayService.pushDelivery(request); | |||
| if(b){ | |||
| ttOrderPushErrorMapper.deleteById(msg.getCouponOrderId()); | |||
| } | |||
| String itemOrderId = (String) order.getExpParamValue("itemOrderId"); | |||
| String shop_name = merchant.getName(); | |||
| String ext_valid_shop_id = couponOrder.getBMerchantId().toString(); | |||
| TtMerchantPoi poi = ttMerchantPoiService.getById(couponOrder.getBMerchantId()); | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(couponOrder,EnumPayWay.PAY_WAY_TT.getPlat()); | |||
| WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); | |||
| TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||
| TtOrderPushDeliveryRequest request = new TtOrderPushDeliveryRequest(); | |||
| request.setOutOrderNo(order.getComposeOrderId().toString()); | |||
| List<TtOrderPushDeliveryRequest.ItemOrder> itemOrderList = new ArrayList<>(); | |||
| TtOrderPushDeliveryRequest.ItemOrder itemOrder = new TtOrderPushDeliveryRequest.ItemOrder(); | |||
| itemOrder.setItemOrderId(itemOrderId); | |||
| itemOrderList.add(itemOrder); | |||
| request.setItemOrderList(itemOrderList); | |||
| JSONObject poiInfo = new JSONObject(); | |||
| poiInfo.put("shop_name",shop_name); | |||
| poiInfo.put("ext_valid_shop_id",ext_valid_shop_id); | |||
| if(poi != null){ | |||
| poiInfo.put("valid_poi_id_str",poi.getPoiId()); | |||
| } | |||
| request.setPoiInfo(poiInfo.toJSONString()); | |||
| boolean b = ttPayService.pushDelivery(request); | |||
| if(b){ | |||
| ttOrderPushErrorService.deleteSuccess(couponOrder,couponOrder.getId(),EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode(),EnumThirdPartyConfigType.TOUTIAO.getCode()); | |||
| } | |||
| }catch(Exception e){ | |||
| TtOrderPushError pushError = new TtOrderPushError(); | |||
| pushError.setId(msg.getCouponOrderId()); | |||
| pushError.updateTenantInfo(tenantEntity); | |||
| pushError.setErrMsg(e.getMessage()); | |||
| saveOrUpdate(pushError); | |||
| logger.error("订单核销同步抖音异常batchOrderId"+couponOrder.getId()+"{}"+e.getMessage()); | |||
| ttOrderPushErrorService.saveOrUpdate(couponOrder,couponOrder.getId(),EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode(),EnumThirdPartyConfigType.TOUTIAO.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| private void saveOrUpdate(TtOrderPushError pushError){ | |||
| Date now = new Date(); | |||
| TtOrderPushError pushError1 = ttOrderPushErrorMapper.selectById(pushError.getId()); | |||
| if(pushError1 != null){ | |||
| pushError1.setErrMsg(pushError.getErrMsg()); | |||
| pushError1.setUpdateDate(now); | |||
| ttOrderPushErrorMapper.updateById(pushError1); | |||
| }else{ | |||
| pushError.setCreateDate(now); | |||
| pushError.setUpdateDate(now); | |||
| ttOrderPushErrorMapper.insert(pushError); | |||
| private void pushOrderMallCooDelivery(WxCouponOrder couponOrder,WxOrder order,WxCoupon coupon,WxMerchant merchant){ | |||
| try{ | |||
| WxPayOrder orderq = new WxPayOrder(); | |||
| orderq.setOrderId(order.getComposeOrderId()); | |||
| orderq.updateTenantInfo(order); | |||
| WxPayOrder payOrder = wxPayOrderService.getByObj(orderq); | |||
| if(payOrder == null){ | |||
| logger.error("支付订单未找到: " + order.getComposeOrderId()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "支付订单未找到" + order.getComposeOrderId()); | |||
| } | |||
| if(StringUtils.isBlank(payOrder.getTransactionId())){ | |||
| logger.error("担保支付订单未找到: " + order.getComposeOrderId()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "担保支付订单未找到" + order.getComposeOrderId()); | |||
| } | |||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoMapper.selectById(couponOrder.getCUserId(), couponOrder.getFinalTenantId()); | |||
| if(null == basicInfo){ | |||
| logger.error("未找到会员信息"+couponOrder.getCUserId()); | |||
| throw new MallinkException(ErrorCode.USER_NOT_MEMBER.getCode(), "未找到会员信息" + couponOrder.getId()); | |||
| } | |||
| String traceID = mallCooUserInfoService.verifyOrderMallCooPush(merchant, basicInfo, coupon, couponOrder, order, payOrder,merchant); | |||
| ttOrderPushErrorService.deleteSuccess(couponOrder,couponOrder.getId(),EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode(),EnumThirdPartyConfigType.MALLCOO.getCode()); | |||
| }catch(Exception e){ | |||
| logger.error("订单核销同步猫酷异常couponOrderId"+couponOrder.getId()+"{}"+e.getMessage()); | |||
| ttOrderPushErrorService.saveOrUpdate(couponOrder,couponOrder.getId(),EnumMsgRecordType.INSIDE_ORDER_PUSH_DELIVERY.getCode(),EnumThirdPartyConfigType.MALLCOO.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,157 +1,110 @@ | |||
| //package com.iformall.service.msg.impl; | |||
| // | |||
| //import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| //import com.iformall.common.ErrorCode; | |||
| //import com.iformall.domain.po.*; | |||
| //import com.iformall.domain.po.msg.BaseMsg; | |||
| //import com.iformall.domain.po.msg.FmInsideOrderPushMsg; | |||
| //import com.iformall.enums.*; | |||
| //import com.iformall.exception.MallinkException; | |||
| //import com.iformall.mapper.TtCUserMapper; | |||
| //import com.iformall.mapper.TtOrderPushErrorMapper; | |||
| //import com.iformall.mapper.WxPayOrderMapper; | |||
| //import com.iformall.service.*; | |||
| //import com.iformall.service.msg.MsgSendService; | |||
| //import com.iformall.service.pay.PayServiceFactory; | |||
| //import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| //import com.iformall.utils.DateUtils; | |||
| //import org.apache.commons.lang3.StringUtils; | |||
| //import org.slf4j.Logger; | |||
| //import org.slf4j.LoggerFactory; | |||
| //import org.springframework.beans.factory.annotation.Autowired; | |||
| //import org.springframework.stereotype.Service; | |||
| // | |||
| //import java.util.Date; | |||
| //import java.util.List; | |||
| // | |||
| ///** | |||
| // * | |||
| // * @author Stormeye Wu | |||
| // * @date 2019/5/10 | |||
| // */ | |||
| //@Service | |||
| //public class FmInsideOrderPushMsgServiceImpl implements MsgSendService { | |||
| // private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| // | |||
| // @Autowired | |||
| // private WxOrderService orderService; | |||
| // | |||
| // @Autowired | |||
| // WxAppinfoService wxAppinfoService; | |||
| // | |||
| // @Autowired | |||
| // PayServiceFactory payServiceFactory; | |||
| // | |||
| // @Autowired | |||
| // WxPayOrderService wxPayOrderService; | |||
| // | |||
| // @Autowired | |||
| // TtCUserMapper ttCUserMapper; | |||
| // | |||
| // @Autowired | |||
| // WxPayOrderMapper wxPayOrderMapper; | |||
| // | |||
| // @Autowired | |||
| // TtOrderPushErrorMapper ttOrderPushErrorMapper; | |||
| // | |||
| // @Autowired | |||
| // private String fmExceptionEmails; | |||
| // | |||
| // @Autowired | |||
| // private MailService mailService; | |||
| // | |||
| // | |||
| // @Override | |||
| // public void send(BaseMsg baseMsg) throws Exception{ | |||
| // FmInsideOrderPushMsg msg = (FmInsideOrderPushMsg)baseMsg; | |||
| // | |||
| // try{ | |||
| // Thread.currentThread().sleep(1000);//延时秒 | |||
| // }catch(Exception e){} | |||
| // | |||
| // WxBatchOrder border = new WxBatchOrder(); | |||
| // border.setTenantId(msg.getTenantId()); | |||
| // border.setParentTenantId(msg.getParentTenantId()); | |||
| // border.setId(msg.getBatchOrderId()); | |||
| // WxBatchOrder batchOrder = orderService.batchOrderDetail(border); | |||
| // if(batchOrder == null){ | |||
| // logger.error("主订单未找到: " + msg.getBatchOrderId()); | |||
| // throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "主订单未找到" + msg.getBatchOrderId()); | |||
| // } | |||
| // | |||
| // if(EnumPayWay.PAY_WAY_TT.getCode().equals(batchOrder.getPayVendor()) | |||
| // && EnumComposeOrder.SINGLE.getCode().equals(batchOrder.getOrderType()) | |||
| // && batchOrder.getOrders().size() == 1){ | |||
| // WxAppinfo appinfo = wxAppinfoService.getCAppInfo(batchOrder,EnumPayWay.PAY_WAY_TT.getPlat()); | |||
| // try{ | |||
| // payOrderPush(appinfo,batchOrder); | |||
| // }catch(Exception e){ | |||
| // logger.error("订单同步异常batchOrderId"+batchOrder.getId()+"{}"+e.getMessage()); | |||
| //// String[] receivers = fmExceptionEmails.split(","); | |||
| //// StringBuilder sb = new StringBuilder(); | |||
| //// sb.append(DateUtils.date2String(new Date())); | |||
| //// sb.append("\n"); | |||
| //// sb.append("tenantId="+batchOrder.getTenantId()); | |||
| //// sb.append("\n"); | |||
| //// sb.append(e.getMessage()); | |||
| //// sb.append("\n"); | |||
| //// sb.append("batchOrderId="+batchOrder.getId()); | |||
| //// //发送邮件 | |||
| //// mailService.sendSimpleMail(receivers, batchOrder.getTenantId()+"订单同步异常", sb.toString()); | |||
| // | |||
| // TtOrderPushError pushError = new TtOrderPushError(); | |||
| // pushError.setId(batchOrder.getId()); | |||
| // pushError.updateTenantInfo(batchOrder); | |||
| // pushError.setErrMsg(e.getMessage()); | |||
| // saveOrUpdate(pushError); | |||
| // | |||
| // } | |||
| // | |||
| // | |||
| //// WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | |||
| //// if(EnumPayType.PAY_PAYMENT.getCode().equals(wxOrderCouponVo.getPaymentType())){ | |||
| //// payOrderPush(appinfo,batchOrder); | |||
| //// }else{ | |||
| //// //退款 | |||
| //// //通过退款订单找支付订单 | |||
| //// WxOrder ref_order = orderService.getById(wxOrderCouponVo.getOrderNumber(), wxOrderCouponVo.getTenantId()); | |||
| //// WxBatchOrder ref_border = new WxBatchOrder(); | |||
| //// ref_border.setTenantId(ref_order.getTenantId()); | |||
| //// ref_border.setParentTenantId(ref_order.getParentTenantId()); | |||
| //// ref_border.setId(ref_order.getComposeOrderId()); | |||
| //// WxBatchOrder ref_batchOrder = orderService.batchOrderDetail(ref_border); | |||
| //// if(ref_batchOrder == null){ | |||
| //// logger.error("退款 主订单未找到: " + ref_order.getComposeOrderId()); | |||
| //// throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "退款 主订单未找到" + ref_order.getComposeOrderId()); | |||
| //// } | |||
| //// if(EnumPayWay.PAY_WAY_TT.getCode().equals(ref_batchOrder.getPayVendor()) | |||
| //// && EnumComposeOrder.SINGLE.getCode().equals(ref_batchOrder.getOrderType()) | |||
| //// && ref_batchOrder.getOrders().size() == 1){ | |||
| //// for (WxOrderCouponVo ref_vo:ref_batchOrder.getOrders()) { | |||
| //// ref_vo.setOrderStatus(wxOrderCouponVo.getOrderStatus()); | |||
| //// } | |||
| //// payOrderPush(appinfo,ref_batchOrder); | |||
| //// } | |||
| //// | |||
| //// } | |||
| // } | |||
| // } | |||
| // | |||
| // private void saveOrUpdate(TtOrderPushError pushError){ | |||
| // Date now = new Date(); | |||
| // TtOrderPushError pushError1 = ttOrderPushErrorMapper.selectById(pushError.getId()); | |||
| // if(pushError1 != null){ | |||
| // pushError1.setErrMsg(pushError.getErrMsg()); | |||
| // pushError1.setUpdateDate(now); | |||
| // ttOrderPushErrorMapper.updateById(pushError1); | |||
| // }else{ | |||
| // pushError.setCreateDate(now); | |||
| // pushError.setUpdateDate(now); | |||
| // ttOrderPushErrorMapper.insert(pushError); | |||
| // } | |||
| // } | |||
| // | |||
| // | |||
| package com.iformall.service.msg.impl; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| import com.iformall.domain.po.msg.FmInsideOrderPushMsg; | |||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.msg.MsgSendService; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| * | |||
| * @author Stormeye Wu | |||
| * @date 2019/5/10 | |||
| */ | |||
| @Service | |||
| public class FmInsideOrderPushMsgServiceImpl implements MsgSendService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMallService wxMallService; | |||
| @Autowired | |||
| private WxOrderService orderService; | |||
| @Autowired | |||
| WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| PayServiceFactory payServiceFactory; | |||
| @Autowired | |||
| WxPayOrderService wxPayOrderService; | |||
| @Autowired | |||
| TtCUserMapper ttCUserMapper; | |||
| @Autowired | |||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||
| @Autowired | |||
| WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| WxPayOrderMapper wxPayOrderMapper; | |||
| @Autowired | |||
| TtMerchantPoiMapper ttMerchantPoiMapper; | |||
| @Autowired | |||
| TtOrderPushErrorService ttOrderPushErrorService; | |||
| @Autowired | |||
| private String fmExceptionEmails; | |||
| @Autowired | |||
| private MailService mailService; | |||
| @Autowired | |||
| private MallCooUserInfoService mallCooUserInfoService; | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception{ | |||
| FmInsideOrderPushMsg msg = (FmInsideOrderPushMsg)baseMsg; | |||
| try{ | |||
| Thread.currentThread().sleep(1000);//延时秒 | |||
| }catch(Exception e){} | |||
| WxBatchOrder border = new WxBatchOrder(); | |||
| border.setTenantId(msg.getTenantId()); | |||
| border.setParentTenantId(msg.getParentTenantId()); | |||
| border.setId(msg.getBatchOrderId()); | |||
| WxBatchOrder batchOrder = orderService.batchOrderDetail(border); | |||
| if(batchOrder == null){ | |||
| logger.error("主订单未找到: " + msg.getBatchOrderId()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "主订单未找到" + msg.getBatchOrderId()); | |||
| } | |||
| if(EnumPayWay.PAY_WAY_TT.getCode().equals(batchOrder.getPayVendor()) | |||
| && EnumComposeOrder.SINGLE.getCode().equals(batchOrder.getOrderType()) | |||
| && batchOrder.getOrders().size() == 1){ | |||
| if(msg.getThirdType() == null || EnumThirdPartyConfigType.MALLCOO.getCode().equals(msg.getThirdType())){ | |||
| payOrderMallCooPush(batchOrder); | |||
| } | |||
| } | |||
| } | |||
| // private void payOrderPush(WxAppinfo appinfo, WxBatchOrder batchOrder) throws Exception{ | |||
| // WxPayOrder orderq = new WxPayOrder(); | |||
| // orderq.setOrderId(batchOrder.getId()); | |||
| @@ -180,4 +133,47 @@ | |||
| // throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(), payAdapterResult.getMsg() + batchOrder.getId()); | |||
| // } | |||
| // } | |||
| //} | |||
| private void payOrderMallCooPush(WxBatchOrder batchOrder){ | |||
| try{ | |||
| WxPayOrder orderq = new WxPayOrder(); | |||
| orderq.setOrderId(batchOrder.getId()); | |||
| orderq.updateTenantInfo(batchOrder); | |||
| WxPayOrder payOrder = wxPayOrderService.getByObj(orderq); | |||
| if(payOrder == null){ | |||
| logger.error("支付订单未找到: " + batchOrder.getId()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "支付订单未找到" + batchOrder.getId()); | |||
| } | |||
| if(StringUtils.isBlank(payOrder.getTransactionId())){ | |||
| logger.error("担保支付订单未找到: " + batchOrder.getId()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "担保支付订单未找到" + batchOrder.getId()); | |||
| } | |||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoMapper.selectById(batchOrder.getCUserId(), batchOrder.getFinalTenantId()); | |||
| if(null == basicInfo){ | |||
| logger.error("未找到会员信息"+batchOrder.getCUserId()); | |||
| throw new MallinkException(ErrorCode.USER_NOT_MEMBER.getCode(), "未找到会员信息" + batchOrder.getId()); | |||
| } | |||
| WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | |||
| TenantEntity mallCooPushTenant = mallCooUserInfoService.getMallCooPushTenant(wxOrderCouponVo, basicInfo,wxOrderCouponVo.getFromId()); | |||
| if(StringUtils.isBlank(mallCooPushTenant.getTenantId())){ | |||
| throw new MallinkException(ErrorCode.MALL_INFO_NOT_FOUND.getCode(),"未找到推送商场"); | |||
| } | |||
| logger.info("订单号()"+batchOrder.getId()+"获取推送广场{}"+ JSON.toJSONString(mallCooPushTenant)); | |||
| if (!basicInfo.getTenantId().contains("," + mallCooPushTenant.getTenantId() + ",")) { | |||
| wxCUserBasicInfoService.updateTenantIdMsg(wxOrderCouponVo,mallCooPushTenant,basicInfo.getId()); | |||
| } | |||
| String traceID = mallCooUserInfoService.payOrderMallCooPush(mallCooPushTenant, basicInfo, batchOrder, payOrder); | |||
| ttOrderPushErrorService.deleteSuccess(batchOrder,batchOrder.getId(),EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode(),EnumThirdPartyConfigType.MALLCOO.getCode()); | |||
| }catch(Exception e){ | |||
| logger.error("订单同步猫酷异常batchOrderId"+batchOrder.getId()+"{}"+e.getMessage()); | |||
| ttOrderPushErrorService.saveOrUpdate(batchOrder,batchOrder.getId(),EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode(),EnumThirdPartyConfigType.MALLCOO.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -263,7 +263,7 @@ public class WiwideUtil implements SMSExcutor { | |||
| // String s = queryDataNew("http://140.143.33.245" + "/api/reports/pictures/get_picture", sign, param); | |||
| // System.out.println(DataUtil.unicodeToUtf8(s)); | |||
| Map<String, Object> param = new HashMap<>(); | |||
| // Map<String, Object> param = new HashMap<>(); | |||
| // param.put("pageStart",1); | |||
| // param.put("pageSize",10); | |||
| // param.put("key",0); | |||
| @@ -271,8 +271,8 @@ public class WiwideUtil implements SMSExcutor { | |||
| // param.put("placeStatus",0); | |||
| String s = queryDataNew("https://vap.vision.wiwide.com" + "/api/place/place_list", sign, param); | |||
| System.out.println(DataUtil.unicodeToUtf8(s)); | |||
| // String s = queryDataNew("https://vap.vision.wiwide.com" + "/api/place/place_list", sign, param); | |||
| // System.out.println(DataUtil.unicodeToUtf8(s)); | |||
| } | |||
| } | |||
| @@ -6,6 +6,9 @@ | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="main_id" jdbcType="BIGINT" property="mainId"/> | |||
| <result column="msg_type" jdbcType="INTEGER" property="msgType"/> | |||
| <result column="third_type" jdbcType="INTEGER" property="thirdType"/> | |||
| <result column="err_msg" jdbcType="VARCHAR" property="errMsg"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| @@ -14,7 +17,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`err_msg`, | |||
| `id`,`tenant_id`,`parent_tenant_id`,`main_id`,`msg_type`,`third_type`,`err_msg`, | |||
| `create_date`,`update_date` | |||
| </sql> | |||
| @@ -32,6 +35,16 @@ | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != mainId "> | |||
| and `main_id` = #{mainId} | |||
| </if> | |||
| <if test=" null != msgType "> | |||
| and `msg_type` = #{msgType} | |||
| </if> | |||
| <if test=" null != thirdType "> | |||
| and `third_type` = #{thirdType} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and `id` in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||