|
|
|
@@ -19,16 +19,14 @@ import com.simple.domain.vo.WxCouponOrderCarCVo; |
|
|
|
import com.simple.enums.*; |
|
|
|
import com.simple.exception.MallinkException; |
|
|
|
import com.simple.mapper.*; |
|
|
|
import com.simple.service.WxCouponOrderService; |
|
|
|
import com.simple.service.WxCouponSendService; |
|
|
|
import com.simple.service.WxOrderService; |
|
|
|
import com.simple.service.WxProfitSharingOrderService; |
|
|
|
import com.simple.service.*; |
|
|
|
import com.simple.utils.DateUtils; |
|
|
|
import com.simple.utils.MaUtil; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import org.apache.log4j.Logger; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureOrder; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
@@ -80,6 +78,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
@Autowired |
|
|
|
WxCouponMapper wxCouponMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxAppinfoService wxAppinfoService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxCouponOrder> listAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { |
|
|
|
@@ -392,51 +393,42 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
/** |
|
|
|
* 微信模板消息 |
|
|
|
* |
|
|
|
* @param appInfo, couponOrder, bUser |
|
|
|
* @param couponOrder, bUser |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void sendVerifyMsg(WxAppinfo appInfo, WxCouponOrder couponOrder, WxMerchantBUser bUser) { |
|
|
|
// 1. get template id |
|
|
|
WxTemplateMsg msgQ = new WxTemplateMsg(); |
|
|
|
msgQ.setTenantId(couponOrder.getTenantId()); |
|
|
|
msgQ.setType(EnumTemplateType.VERIFY_FAIL.getCode()); |
|
|
|
WxTemplateMsg msg = null; |
|
|
|
List<WxTemplateMsg> list = wxTemplateMsgMapper.select(msgQ); |
|
|
|
if (list.size() > 0) { |
|
|
|
msg = list.get(0); |
|
|
|
} |
|
|
|
if (msg == null) { |
|
|
|
logger.error("找不到模板Id"); |
|
|
|
throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); |
|
|
|
} |
|
|
|
// 2. get order info |
|
|
|
public void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchantBUser bUser) { |
|
|
|
// 1. get order info |
|
|
|
WxOrder order = wxOrderMapper.selectByPrimaryKey(couponOrder.getOrderId()); |
|
|
|
if (order == null) { |
|
|
|
logger.error("找不到订单信息"); |
|
|
|
throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); |
|
|
|
} |
|
|
|
// 3. get coupon info |
|
|
|
// 2. get coupon info |
|
|
|
WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(couponOrder.getCouponId()); |
|
|
|
if (coupon == null) { |
|
|
|
logger.error("找不到券信息"); |
|
|
|
throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
// 4. merchant info |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(bUser.getId()); |
|
|
|
// 3. merchant info |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(bUser.getMerchantId()); |
|
|
|
if (merchant == null) { |
|
|
|
logger.error("找不到商户信息"); |
|
|
|
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
} |
|
|
|
// 5. get user info |
|
|
|
// 4. get user info |
|
|
|
WxCUser user = wxCUserMapper.selectByPrimaryKey(order.getCUserId()); |
|
|
|
if (user == null) { |
|
|
|
logger.error("找不到C端用户"); |
|
|
|
throw new MallinkException(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
|
|
|
|
// 5. get app info |
|
|
|
WxAppinfo appInfo = wxAppinfoService.getByAppId(user.getAppId()); |
|
|
|
|
|
|
|
// 6. get payOrder info |
|
|
|
WxPayOrder payOrder = null; |
|
|
|
WxPayOrder payOrderQ = new WxPayOrder(); |
|
|
|
payOrderQ.setTenantId(appInfo.getTenantId()); |
|
|
|
payOrderQ.setTenantId(couponOrder.getTenantId()); |
|
|
|
payOrderQ.setOrderId(order.getId()); |
|
|
|
payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); |
|
|
|
List<WxPayOrder> payList = wxPayOrderMapper.select(payOrderQ); |
|
|
|
@@ -452,8 +444,20 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
couponDetail = "满" + coupon.getUsePriceStr() + "减" + coupon.getPriceStr(); |
|
|
|
} |
|
|
|
|
|
|
|
WxTemplateMsg msg = null; |
|
|
|
WxMaTemplateMessage templateMessage = null; |
|
|
|
if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) { |
|
|
|
WxTemplateMsg msgQ = new WxTemplateMsg(); |
|
|
|
msgQ.setTenantId(couponOrder.getTenantId()); |
|
|
|
msgQ.setType(EnumTemplateType.VERIFY_SUCCESS.getCode()); |
|
|
|
List<WxTemplateMsg> list = wxTemplateMsgMapper.select(msgQ); |
|
|
|
if (list.size() > 0) { |
|
|
|
msg = list.get(0); |
|
|
|
} |
|
|
|
if (msg == null) { |
|
|
|
logger.error("找不到模板Id"); |
|
|
|
throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 核销成功 |
|
|
|
* 核销金额 {{keyword1.DATA}} |
|
|
|
@@ -471,12 +475,23 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { |
|
|
|
new WxMaTemplateMessage.Data("keyword2", merchant.getName(), "#173177"), |
|
|
|
new WxMaTemplateMessage.Data("keyword3", coupon.getTitle(), "#173177"), |
|
|
|
new WxMaTemplateMessage.Data("keyword4", dateFormat.format(new Date()), "#173177"), |
|
|
|
new WxMaTemplateMessage.Data("keyword5", merchant.getName(), "#173177")) |
|
|
|
new WxMaTemplateMessage.Data("keyword5", couponDetail, "#173177")) |
|
|
|
) |
|
|
|
.templateId(msg.getTemplateId()) |
|
|
|
.emphasisKeyword("keyword1.DATA") |
|
|
|
.build(); |
|
|
|
} else { |
|
|
|
WxTemplateMsg msgQ = new WxTemplateMsg(); |
|
|
|
msgQ.setTenantId(couponOrder.getTenantId()); |
|
|
|
msgQ.setType(EnumTemplateType.VERIFY_FAIL.getCode()); |
|
|
|
List<WxTemplateMsg> list = wxTemplateMsgMapper.select(msgQ); |
|
|
|
if (list.size() > 0) { |
|
|
|
msg = list.get(0); |
|
|
|
} |
|
|
|
if (msg == null) { |
|
|
|
logger.error("找不到模板Id"); |
|
|
|
throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 核销失败 |
|
|
|
* 商品名称 {{keyword1.DATA}} |
|
|
|
|