| @@ -188,7 +188,7 @@ public class WxPayOrderController extends BaseController { | |||||
| if (payOrderId<=0) { | if (payOrderId<=0) { | ||||
| logger.error("/api/pay/updatePayOrder error : payOrderId不能为空: " + paramMap.toString()); | logger.error("/api/pay/updatePayOrder error : payOrderId不能为空: " + paramMap.toString()); | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId非法"+payOrderId+"[payOrderIdStr:"+payOrderIdStr+"]"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId非法"+payOrderId+"[payOrderIdStr:"+payOrderIdStr+"]"); | ||||
| } | |||||
| } | |||||
| payOrder = wxPayOrderService.getById(payOrderId,payOrder.getTenantId()); | payOrder = wxPayOrderService.getById(payOrderId,payOrder.getTenantId()); | ||||
| if (null == payOrder) { | if (null == payOrder) { | ||||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到payOrder."); | return new ResultData(ErrorCode.PAY_ORDER_ERROR, "未查询到payOrder."); | ||||
| @@ -37,6 +37,8 @@ public class MqBaseConsumer { | |||||
| @Autowired | @Autowired | ||||
| private FmInsideOrderRefundMsgServiceImpl fmInsideOrderRefundMsgService; | private FmInsideOrderRefundMsgServiceImpl fmInsideOrderRefundMsgService; | ||||
| @Autowired | @Autowired | ||||
| private FmInsideOrderPushMsgServiceImpl fmInsideOrderPushMsgService; | |||||
| @Autowired | |||||
| private FmInsideCLoginMsgServiceImpl fmInsideCLoginMsgService; | private FmInsideCLoginMsgServiceImpl fmInsideCLoginMsgService; | ||||
| @Autowired | @Autowired | ||||
| private MqBaseProducer mqBaseProducer; | private MqBaseProducer mqBaseProducer; | ||||
| @@ -101,7 +103,12 @@ public class MqBaseConsumer { | |||||
| // 内部消息 - c端登录 | // 内部消息 - c端登录 | ||||
| FmInsideCLoginMsg msg = (FmInsideCLoginMsg)JsonUtil.readValue(message,FmInsideCLoginMsg.class); | FmInsideCLoginMsg msg = (FmInsideCLoginMsg)JsonUtil.readValue(message,FmInsideCLoginMsg.class); | ||||
| fmInsideCLoginMsgService.send(msg); | fmInsideCLoginMsgService.send(msg); | ||||
| } | |||||
| } | |||||
| else if(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode().equals(baseMsg.getMsgType())) { | |||||
| // 内部消息 - 订单同步 | |||||
| FmInsideOrderPushMsg msg = (FmInsideOrderPushMsg)JsonUtil.readValue(message,FmInsideOrderPushMsg.class); | |||||
| fmInsideOrderPushMsgService.send(msg); | |||||
| } | |||||
| //else if(EnumMsgRecordType.INSIDE_NOTIFY_PAY_SUCCESS.getCode().equals(baseMsg.getMsgType())) { | //else if(EnumMsgRecordType.INSIDE_NOTIFY_PAY_SUCCESS.getCode().equals(baseMsg.getMsgType())) { | ||||
| // 内部消息 - 微信支付通知 | // 内部消息 - 微信支付通知 | ||||
| //FmInsideNotifyPaySuccessMsg msg = (FmInsideNotifyPaySuccessMsg)JsonUtil.readValue(message,FmInsideNotifyPaySuccessMsg.class); | //FmInsideNotifyPaySuccessMsg msg = (FmInsideNotifyPaySuccessMsg)JsonUtil.readValue(message,FmInsideNotifyPaySuccessMsg.class); | ||||
| @@ -111,7 +118,7 @@ public class MqBaseConsumer { | |||||
| // 内部消息 - 微信退款通知 | // 内部消息 - 微信退款通知 | ||||
| FmInsideNotifyRefundSuccessMsg msg = (FmInsideNotifyRefundSuccessMsg)JsonUtil.readValue(message,FmInsideNotifyRefundSuccessMsg.class); | FmInsideNotifyRefundSuccessMsg msg = (FmInsideNotifyRefundSuccessMsg)JsonUtil.readValue(message,FmInsideNotifyRefundSuccessMsg.class); | ||||
| fmInsideNotifyRefundSuccessMsgService.send(msg); | fmInsideNotifyRefundSuccessMsgService.send(msg); | ||||
| } | |||||
| } | |||||
| else if(EnumMsgRecordType.CASH_OUT.getCode().equals(baseMsg.getMsgType())) { | else if(EnumMsgRecordType.CASH_OUT.getCode().equals(baseMsg.getMsgType())) { | ||||
| // 内部消息 - 商户提现通知 | // 内部消息 - 商户提现通知 | ||||
| FmInsideCashOutMsg msg = (FmInsideCashOutMsg)JsonUtil.readValue(message,FmInsideCashOutMsg.class); | FmInsideCashOutMsg msg = (FmInsideCashOutMsg)JsonUtil.readValue(message,FmInsideCashOutMsg.class); | ||||
| @@ -6,7 +6,11 @@ import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.msg.FmInsideOrderPushMsg; | |||||
| import com.iformall.enums.*; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.mq.MqBaseProducer; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.aop.framework.AopContext; | import org.springframework.aop.framework.AopContext; | ||||
| @@ -20,13 +24,6 @@ import org.springframework.transaction.annotation.Transactional; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.enums.EnumAppType; | |||||
| import com.iformall.enums.EnumComposeOrder; | |||||
| import com.iformall.enums.EnumOrderStatus; | |||||
| import com.iformall.enums.EnumOrderType; | |||||
| import com.iformall.enums.EnumPayStatus; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.enums.EnumRefundStatus; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxOrderService; | import com.iformall.service.WxOrderService; | ||||
| @@ -90,6 +87,9 @@ public class OrderExpiringSchedule { | |||||
| @Autowired | @Autowired | ||||
| OrderFactory orderFactory; | OrderFactory orderFactory; | ||||
| @Autowired | |||||
| MqBaseProducer mqBaseProducer; | |||||
| private List<WxMall> getMalls() { | private List<WxMall> getMalls() { | ||||
| WxMall wxMall =new WxMall(); | WxMall wxMall =new WxMall(); | ||||
| @@ -353,6 +353,8 @@ public class OrderExpiringSchedule { | |||||
| wxOrderMapper.updateById(updateOrder); | wxOrderMapper.updateById(updateOrder); | ||||
| logger.info("券订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + new Date()); | logger.info("券订单: " + order.getId() + " create at " + order.getCreateDate() + " expired at " + new Date()); | ||||
| sendInsideOrderPushMsg(order,order.getComposeOrderId()); | |||||
| } | } | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| @@ -464,4 +466,19 @@ public class OrderExpiringSchedule { | |||||
| } | } | ||||
| } | } | ||||
| public void sendInsideOrderPushMsg(TenantEntity tenantEntity, Long mainOrderId) { | |||||
| try{ | |||||
| FmInsideOrderPushMsg orderPush = new FmInsideOrderPushMsg(); | |||||
| orderPush.setDelayTimeLevel(5); | |||||
| orderPush.setMsgType(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode()); | |||||
| orderPush.updateTenantInfo(tenantEntity); | |||||
| orderPush.setBatchOrderId(mainOrderId); | |||||
| 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()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.WxOrderCouponVo; | import com.iformall.domain.vo.WxOrderCouponVo; | ||||
| import com.iformall.enums.EnumAppPlat; | |||||
| import com.iformall.utils.Constant; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -40,4 +42,13 @@ public class WxBatchOrder extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "订单集合", name = "orders") | @io.swagger.annotations.ApiModelProperty(value = "订单集合", name = "orders") | ||||
| private List<WxOrderCouponVo> orders; | private List<WxOrderCouponVo> orders; | ||||
| public String getWeappOrderPath(EnumAppPlat appPlat){ | |||||
| if(EnumAppPlat.WX.equals(appPlat)){ | |||||
| }else if (EnumAppPlat.TOUTIAO.equals(appPlat)){ | |||||
| return Constant.mainPageUrl + "?type=dd&couponOrderId=" + id; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -173,13 +173,4 @@ public class WxOrder extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="配送类型 0:默认(无) 1:自提 2:配送",name="shippingType") | @io.swagger.annotations.ApiModelProperty(value="配送类型 0:默认(无) 1:自提 2:配送",name="shippingType") | ||||
| private Integer shippingType; | private Integer shippingType; | ||||
| public String getWeappOrderPath(EnumAppPlat appPlat){ | |||||
| if(EnumAppPlat.WX.equals(appPlat)){ | |||||
| }else if (EnumAppPlat.TOUTIAO.equals(appPlat)){ | |||||
| return Constant.mainPageUrl + "?type=cd&couponId=" + productId; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,19 @@ | |||||
| package com.iformall.domain.po.msg; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class FmInsideOrderPushMsg extends BaseMsg{ | |||||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="父租户id",name="parentTenantId") | |||||
| private String parentTenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "composeOrderId") | |||||
| private Long batchOrderId; | |||||
| } | |||||
| @@ -100,6 +100,9 @@ public class WxOrderCouponVo extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | ||||
| private String remark; | private String remark; | ||||
| @io.swagger.annotations.ApiModelProperty(value="内容类型(0:小程序页面类型,1:富文本类型)",name="contentType") | |||||
| private Integer contentType; | |||||
| /** 发券商户信息 */ | /** 发券商户信息 */ | ||||
| @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList") | @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList") | ||||
| private List<WxMerchantVo> merchantVoList; | private List<WxMerchantVo> merchantVoList; | ||||
| @@ -197,6 +200,7 @@ public class WxOrderCouponVo extends TenantEntity { | |||||
| this.setValidEndDate(c.getValidEndDate()); | this.setValidEndDate(c.getValidEndDate()); | ||||
| this.setPickStartDate(c.getPickStartDate()); | this.setPickStartDate(c.getPickStartDate()); | ||||
| this.setPickEndDate(c.getPickEndDate()); | this.setPickEndDate(c.getPickEndDate()); | ||||
| this.setContentType(c.getContentType()); | |||||
| if (hasDetail) { | if (hasDetail) { | ||||
| this.setDetail(c.getDetail()); | this.setDetail(c.getDetail()); | ||||
| this.setRemark(c.getRemark()); | this.setRemark(c.getRemark()); | ||||
| @@ -7,7 +7,7 @@ public enum EnumMsgRecordType { | |||||
| SMS(1, "短信"), | SMS(1, "短信"), | ||||
| SMS_CALLBACK(2, "业务短信"), | SMS_CALLBACK(2, "业务短信"), | ||||
| EMAIL(3, "邮件"), | EMAIL(3, "邮件"), | ||||
| SMART_APP(4, "小程序"),//模板消息作废 | |||||
| // SMART_APP(4, "小程序"),//模板消息作废 | |||||
| SMART_APP_TO(44, "小程序"),//订阅消息 | SMART_APP_TO(44, "小程序"),//订阅消息 | ||||
| PUBLIC(5, "公众号"), | PUBLIC(5, "公众号"), | ||||
| SYSTEM(6, "系统通知"), | SYSTEM(6, "系统通知"), | ||||
| @@ -21,6 +21,7 @@ public enum EnumMsgRecordType { | |||||
| COUPON_STOCK(105, "券库存更新"), | COUPON_STOCK(105, "券库存更新"), | ||||
| CASH_OUT(106,"商户提现"), | CASH_OUT(106,"商户提现"), | ||||
| INSIDE_ORDER_REFUND(107, "退款提交成功"), | INSIDE_ORDER_REFUND(107, "退款提交成功"), | ||||
| INSIDE_ORDER_PUSH(108, "订单同步"), | |||||
| ; | ; | ||||
| public static EnumMsgRecordType getEnum(Integer code) { | public static EnumMsgRecordType getEnum(Integer code) { | ||||
| @@ -243,6 +243,8 @@ public interface WxOrderService { | |||||
| ResultData composeSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<OrderComposeSaveDto> composeOrderSaveDto,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity); | ResultData composeSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<OrderComposeSaveDto> composeOrderSaveDto,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity); | ||||
| void sendInsideOrderPushMsg(WxComposeOrder composeOrder); | |||||
| PageInfo<WxOrderCouponVo> listGoodsCAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); | PageInfo<WxOrderCouponVo> listGoodsCAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); | ||||
| PageInfo<WxBatchOrder> listBatchOrderAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); | PageInfo<WxBatchOrder> listBatchOrderAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); | ||||
| @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.msg.FmInsideOrderPushMsg; | |||||
| import com.iformall.domain.po.msg.WxMsgRecord; | import com.iformall.domain.po.msg.WxMsgRecord; | ||||
| import com.iformall.domain.vo.*; | import com.iformall.domain.vo.*; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -28,6 +29,7 @@ import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||||
| import com.iformall.service.order.entity.WxComposeOrder; | import com.iformall.service.order.entity.WxComposeOrder; | ||||
| import com.iformall.service.order.util.OrderHelper; | import com.iformall.service.order.util.OrderHelper; | ||||
| import com.iformall.service.pay.PayServiceFactory; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -210,6 +212,9 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| @Autowired | @Autowired | ||||
| OrderFactory orderFactory; | OrderFactory orderFactory; | ||||
| @Autowired | |||||
| PayServiceFactory payServiceFactory; | |||||
| @Lazy | @Lazy | ||||
| @Autowired | @Autowired | ||||
| @@ -2053,6 +2058,14 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| logger.error("订单状态更新失败, e:" + e.getMessage(),e); | logger.error("订单状态更新失败, e:" + e.getMessage(),e); | ||||
| throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); | throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); | ||||
| } | } | ||||
| if(ret == 1){ | |||||
| //订单同步 | |||||
| WxComposeOrder composeOrder = new WxComposeOrder(); | |||||
| composeOrder.updateTenantInfo(oldOrder); | |||||
| composeOrder.setMainOrderId(oldOrder.getComposeOrderId()); | |||||
| sendInsideOrderPushMsg(composeOrder); | |||||
| } | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -2562,8 +2575,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| throw new MallinkException(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | throw new MallinkException(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | ||||
| } | } | ||||
| cUserBasicInfoRedisTemplate.opsForValue().set(key, user, 1000, TimeUnit.MILLISECONDS); | cUserBasicInfoRedisTemplate.opsForValue().set(key, user, 1000, TimeUnit.MILLISECONDS); | ||||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrderType.getCode()); | OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrderType.getCode()); | ||||
| WxComposeOrder composeOrder = orderAdapterService.createDBMainOrder(tenantEntity,user, orderSave, payWay); | WxComposeOrder composeOrder = orderAdapterService.createDBMainOrder(tenantEntity,user, orderSave, payWay); | ||||
| WxOrder lastOrder = null; | WxOrder lastOrder = null; | ||||
| @@ -3051,6 +3063,8 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy(); | WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy(); | ||||
| try { | try { | ||||
| WxComposeOrder order = proxy.saveOrderForCoupon(tenantEntity,allowUnPayOrder,composeOrderType,wxCUserBasicInfo, composeOrderSaveDto, payWay); | WxComposeOrder order = proxy.saveOrderForCoupon(tenantEntity,allowUnPayOrder,composeOrderType,wxCUserBasicInfo, composeOrderSaveDto, payWay); | ||||
| //订单同步消息 | |||||
| sendInsideOrderPushMsg(order); | |||||
| return new ResultData(order); | return new ResultData(order); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("saveOrderForCoupon error.",e); | logger.error("saveOrderForCoupon error.",e); | ||||
| @@ -3066,8 +3080,23 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| logger.error("composeSaveOrder error.",e); | logger.error("composeSaveOrder error.",e); | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | ||||
| } | } | ||||
| } | |||||
| @Override | |||||
| public void sendInsideOrderPushMsg(WxComposeOrder composeOrder) { | |||||
| try{ | |||||
| FmInsideOrderPushMsg orderPush = new FmInsideOrderPushMsg(); | |||||
| orderPush.setDelayTimeLevel(5); | |||||
| orderPush.setMsgType(EnumMsgRecordType.INSIDE_ORDER_PUSH.getCode()); | |||||
| orderPush.updateTenantInfo(composeOrder); | |||||
| orderPush.setBatchOrderId(composeOrder.getMainOrderId()); | |||||
| 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()); | |||||
| } | |||||
| } | } | ||||
| //TODO 待优化重做 | //TODO 待优化重做 | ||||
| @@ -172,6 +172,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| //订单同步消息 | |||||
| wxOrderService.sendInsideOrderPushMsg(composeOrder); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,81 @@ | |||||
| package com.iformall.service.msg.impl; | |||||
| 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.domain.po.msg.FmInsideOrderRefundMsg; | |||||
| import com.iformall.enums.EnumPayWay; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.TtCUserMapper; | |||||
| import com.iformall.mapper.WxBatchOrderMapper; | |||||
| import com.iformall.mapper.WxCUserMapper; | |||||
| import com.iformall.mapper.WxPayOrderMapper; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.service.msg.MsgSendService; | |||||
| import com.iformall.service.pay.PayServiceFactory; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| 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; | |||||
| @Override | |||||
| public void send(BaseMsg baseMsg) throws Exception{ | |||||
| FmInsideOrderPushMsg msg = (FmInsideOrderPushMsg)baseMsg; | |||||
| 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())){ | |||||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(batchOrder,EnumPayWay.PAY_WAY_TT.getPlat()); | |||||
| WxPayOrder orderq = new WxPayOrder(); | |||||
| orderq.setOrderId(batchOrder.getId()); | |||||
| orderq.updateTenantInfo(batchOrder); | |||||
| WxPayOrder payOrder = wxPayOrderService.getByObj(orderq); | |||||
| if(payOrder == null){ | |||||
| logger.error("支付订单未找到: " + msg.getBatchOrderId()); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "支付订单未找到" + msg.getBatchOrderId()); | |||||
| } | |||||
| List<String> openIds = ttCUserMapper.findOpenIdList(batchOrder.getCUserId(),batchOrder.getTenantId()); | |||||
| if(openIds == null || openIds.size() > 1){ | |||||
| logger.error("支付订单找到多个用户 同步失败: " + msg.getBatchOrderId()); | |||||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND.getCode(), "支付订单找到多个用户" + msg.getBatchOrderId()); | |||||
| } | |||||
| payServiceFactory.getPayAdapterService(EnumPayWay.PAY_WAY_TT.getCode()).payOrderPush(openIds.get(0),appinfo,batchOrder,payOrder); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -10,6 +10,7 @@ import com.iformall.service.order.entity.WxComposeOrder; | |||||
| import com.iformall.service.pay.entity.PayExtraParam; | import com.iformall.service.pay.entity.PayExtraParam; | ||||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | ||||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | ||||
| import org.springframework.scheduling.annotation.Async; | |||||
| public interface PayAdapterService { | public interface PayAdapterService { | ||||
| @@ -86,7 +87,8 @@ public interface PayAdapterService { | |||||
| * @return | * @return | ||||
| * @throws Exception | * @throws Exception | ||||
| */ | */ | ||||
| public PayAdapterResult payOrderPush(WxAppinfo appInfo, WxOrder order, WxPayOrder record, WxCoupon coupon) throws Exception; | |||||
| @Async | |||||
| public PayAdapterResult payOrderPush(String openId,WxAppinfo appInfo, WxBatchOrder batchOrder,WxPayOrder payOrder) throws Exception; | |||||
| /** | /** | ||||
| * 获取二维码 | * 获取二维码 | ||||
| @@ -0,0 +1,44 @@ | |||||
| package com.iformall.service.pay.service.pay.douyin.miniApp; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumTtOrderStatus { | |||||
| // 0-待付款;1-已支付;2-已取消(限定时间内未付款);3-待退款;4-已退款;5-退款失败 | |||||
| ORDER_STATUS_0(0, "待支付"), | |||||
| ORDER_STATUS_1(1, "已支付"), | |||||
| ORDER_STATUS_2(2, "已取消"), | |||||
| ORDER_STATUS_3(3, "已超时"), | |||||
| ORDER_STATUS_4(4,"已核销"),//核销状态是整单核销(即一笔订单买了 3 个券,核销是指 3 个券核销的整单) | |||||
| ORDER_STATUS_5(5, "退款中"), | |||||
| ORDER_STATUS_6(6, "已退款"), | |||||
| ORDER_STATUS_8(8, "退款失败"), | |||||
| ORDER_STATUS_9(9, "已预订"),// 所有预售券类订单开发者必须通过订单同步接口回传已预订状态(order_status=9) 顺序在已核销之前 | |||||
| ; | |||||
| public static EnumTtOrderStatus getEnum(Integer code) { | |||||
| for (EnumTtOrderStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumTtOrderStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -3,6 +3,7 @@ package com.iformall.service.pay.service.pay.douyin.miniApp; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.vo.WxOrderCouponVo; | |||||
| import com.iformall.douyin.miniapp.api.TtMaService; | import com.iformall.douyin.miniapp.api.TtMaService; | ||||
| import com.iformall.douyin.pay.DouYinPayHelper; | import com.iformall.douyin.pay.DouYinPayHelper; | ||||
| import com.iformall.douyin.pay.preOrder.CreatePreOrderResult; | import com.iformall.douyin.pay.preOrder.CreatePreOrderResult; | ||||
| @@ -88,31 +89,45 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| } | } | ||||
| @Override | @Override | ||||
| public PayAdapterResult payOrderPush(WxAppinfo appInfo, WxOrder order, WxPayOrder record, WxCoupon coupon) throws Exception { | |||||
| public PayAdapterResult payOrderPush(String openId,WxAppinfo appInfo, WxBatchOrder batchOrder,WxPayOrder payOrder) throws Exception { | |||||
| TtMaService ttappService = maUtil.getTtappService(appInfo); | TtMaService ttappService = maUtil.getTtappService(appInfo); | ||||
| Map<String,Object> map = new HashMap<>(); | Map<String,Object> map = new HashMap<>(); | ||||
| // map.put("client_key","");//第三方在开放平台申请的 ClientKey(生活服务订单必传) | |||||
| map.put("access_token",appInfo.getAccessToken()); | map.put("access_token",appInfo.getAccessToken()); | ||||
| // map.put("ext_shop_id","");//生活服务外部商户 id,购买店铺 id (生活服务订单必传) | |||||
| map.put("app_name","douyin"); | map.put("app_name","douyin"); | ||||
| map.put("open_id",record.getOpenId()); | |||||
| map.put("open_id",openId); | |||||
| WxOrderCouponVo wxOrderCouponVo = batchOrder.getOrders().get(0); | |||||
| Map<String,Object> orderDetail = new HashMap<>(); | Map<String,Object> orderDetail = new HashMap<>(); | ||||
| orderDetail.put("order_id",order.getId().toString()); | |||||
| orderDetail.put("create_time",order.getCreateDate().getTime()); | |||||
| orderDetail.put("status", EnumOrderStatus.getEnum(order.getOrderStatus()).getMessage()); | |||||
| orderDetail.put("total_price",order.getPayment()); | |||||
| orderDetail.put("detail_url",order.getWeappOrderPath(EnumAppPlat.TOUTIAO)); | |||||
| orderDetail.put("order_id",batchOrder.getId().toString()); | |||||
| orderDetail.put("create_time",batchOrder.getCreateDate().getTime()); | |||||
| orderDetail.put("status", getTtOrderStatus(wxOrderCouponVo.getOrderStatus()).getMessage()); | |||||
| orderDetail.put("total_price",batchOrder.getPayment()); | |||||
| orderDetail.put("detail_url",batchOrder.getWeappOrderPath(EnumAppPlat.TOUTIAO)); | |||||
| List<Map> itemList = new ArrayList<>(); | List<Map> itemList = new ArrayList<>(); | ||||
| Map<String,Object> item = new HashMap<>(); | |||||
| item.put("img",coupon.getCoverImg()); | |||||
| item.put("title",coupon.getTitle()); | |||||
| item.put("sub_title",coupon.getSubTitle()); | |||||
| item.put("price",coupon.getSalePrice()); | |||||
| itemList.add(item); | |||||
| for (WxOrderCouponVo orderVo:batchOrder.getOrders()) { | |||||
| Map<String,Object> item = new HashMap<>(); | |||||
| item.put("img",orderVo.getCoverImg()); | |||||
| item.put("title",orderVo.getTitle()); | |||||
| item.put("sub_title",orderVo.getSubTitle()); | |||||
| item.put("price",orderVo.getSalePrice()); | |||||
| itemList.add(item); | |||||
| } | |||||
| orderDetail.put("item_list",itemList); | orderDetail.put("item_list",itemList); | ||||
| map.put("order_detail", JSON.toJSONString(orderDetail)); | map.put("order_detail", JSON.toJSONString(orderDetail)); | ||||
| map.put("order_type",0); | map.put("order_type",0); | ||||
| map.put("update_time", order.getPaymentTime().getTime()); | |||||
| map.put("update_time", wxOrderCouponVo.getUpdateDate().getTime()); | |||||
| // map.put("extra","");//自定义字段,用于关联具体业务场景下的特殊参数 | |||||
| // map.put("scene","");//小程序场景值 | |||||
| // map.put("location","");//小程序场景值 | |||||
| // map.put("launch_from","");//小程序场景值 | |||||
| map.put("order_status", getTtOrderStatus(wxOrderCouponVo.getOrderStatus()).getCode()); | |||||
| map.put("payment_order_no", payOrder.getTransactionId()); | |||||
| try { | try { | ||||
| String response = ttappService.post(ttappService.ORDER_PUSH, map); | String response = ttappService.post(ttappService.ORDER_PUSH, map); | ||||
| JSONObject jsonObject = JSON.parseObject(response); | JSONObject jsonObject = JSON.parseObject(response); | ||||
| @@ -130,6 +145,30 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| } | } | ||||
| } | } | ||||
| private EnumTtOrderStatus getTtOrderStatus(Integer code) throws Exception { | |||||
| if(EnumOrderStatus.getEnum(code).equals(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT)){ | |||||
| return EnumTtOrderStatus.ORDER_STATUS_0; | |||||
| } | |||||
| else if(EnumOrderStatus.getEnum(code).equals(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS)){ | |||||
| return EnumTtOrderStatus.ORDER_STATUS_1; | |||||
| } | |||||
| else if(EnumOrderStatus.getEnum(code).equals(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL)){ | |||||
| return EnumTtOrderStatus.ORDER_STATUS_2; | |||||
| } | |||||
| else if(EnumOrderStatus.getEnum(code).equals(EnumOrderStatus.ORDER_STATUS_PENDING_REFUND)){ | |||||
| return EnumTtOrderStatus.ORDER_STATUS_5; | |||||
| } | |||||
| else if(EnumOrderStatus.getEnum(code).equals(EnumOrderStatus.ORDER_STATUS_REFUND_SUCCESS)){ | |||||
| return EnumTtOrderStatus.ORDER_STATUS_6; | |||||
| } | |||||
| else if(EnumOrderStatus.getEnum(code).equals(EnumOrderStatus.ORDER_STATUS_REFUND_FAILD)){ | |||||
| return EnumTtOrderStatus.ORDER_STATUS_8; | |||||
| } | |||||
| log.error("订单状态异常 。。。"); | |||||
| throw new Exception("订单状态异常"); | |||||
| } | |||||
| @Override | @Override | ||||
| public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception{ | public File getQrcode(WxAppinfo appinfo,String pageUrl,int type,String sceneParam) throws Exception{ | ||||
| return super.getQrCode(appinfo, pageUrl, type, sceneParam); | return super.getQrCode(appinfo, pageUrl, type, sceneParam); | ||||
| @@ -57,7 +57,7 @@ public class WxH5PayService extends BaseWxPayAdapterService implements CDriving | |||||
| } | } | ||||
| @Override | @Override | ||||
| public PayAdapterResult payOrderPush(WxAppinfo appInfo, WxOrder order, WxPayOrder record, WxCoupon coupon) throws Exception { | |||||
| public PayAdapterResult payOrderPush(String openId,WxAppinfo appInfo, WxBatchOrder batchOrder,WxPayOrder payOrder) throws Exception { | |||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -265,7 +265,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||||
| } | } | ||||
| @Override | @Override | ||||
| public PayAdapterResult payOrderPush(WxAppinfo appInfo, WxOrder order, WxPayOrder record, WxCoupon coupon) throws Exception { | |||||
| public PayAdapterResult payOrderPush(String openId,WxAppinfo appInfo, WxBatchOrder batchOrder,WxPayOrder payOrder) throws Exception { | |||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -250,7 +250,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||||
| } | } | ||||
| @Override | @Override | ||||
| public PayAdapterResult payOrderPush(WxAppinfo appInfo, WxOrder order, WxPayOrder record, WxCoupon coupon) throws Exception { | |||||
| public PayAdapterResult payOrderPush(String openId,WxAppinfo appInfo, WxBatchOrder batchOrder,WxPayOrder payOrder) throws Exception { | |||||
| return null; | return null; | ||||
| } | } | ||||