|
@@ -20,6 +20,19 @@ import com.dk.oauth.feign.service.StaffFeign;
|
|
|
import com.dk.oauth.mapper.CompanyMapper;
|
|
import com.dk.oauth.mapper.CompanyMapper;
|
|
|
import com.dk.oauth.mapper.TradeMapper;
|
|
import com.dk.oauth.mapper.TradeMapper;
|
|
|
import com.dk.oauth.mapper.UserMapper;
|
|
import com.dk.oauth.mapper.UserMapper;
|
|
|
|
|
+import com.dk.oauth.mapper.integral.CouponUseMapper;
|
|
|
|
|
+import com.dk.oauth.mapper.integral.IntegralItemMapper;
|
|
|
|
|
+import com.dk.oauth.mapper.integral.IntegralMapper;
|
|
|
|
|
+import com.dk.oauth.mapper.integral.IntegralTacticMapper;
|
|
|
|
|
+import com.dk.oauth.model.pojo.integral.CouponUse;
|
|
|
|
|
+import com.dk.oauth.model.pojo.integral.Integral;
|
|
|
|
|
+import com.dk.oauth.model.pojo.integral.IntegralItem;
|
|
|
|
|
+import com.dk.oauth.model.pojo.integral.IntegralTactic;
|
|
|
|
|
+import com.dk.oauth.model.query.integral.IntegralQuery;
|
|
|
|
|
+import com.dk.oauth.model.query.integral.IntegralTacticQuery;
|
|
|
|
|
+import com.dk.oauth.model.response.integral.CouponUseResponse;
|
|
|
|
|
+import com.dk.oauth.model.response.integral.IntegralResponse;
|
|
|
|
|
+import com.dk.oauth.model.response.integral.IntegralTacticResponse;
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
|
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
|
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
@@ -76,6 +89,15 @@ public class WechatPayService {
|
|
|
private XxlJobUtils xxlJobUtils;
|
|
private XxlJobUtils xxlJobUtils;
|
|
|
@Resource
|
|
@Resource
|
|
|
StaffFeign staffFeign;
|
|
StaffFeign staffFeign;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CouponUseMapper couponUseMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ //积分策略
|
|
|
|
|
+ private IntegralTacticMapper integralTacticMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IntegralMapper integralMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IntegralItemMapper integralItemMapper;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商户 下单选取旗舰版或专业版的订单
|
|
* 商户 下单选取旗舰版或专业版的订单
|
|
@@ -156,6 +178,45 @@ public class WechatPayService {
|
|
|
trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
|
|
trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
|
|
|
tradeMapper.updateById(trade);
|
|
tradeMapper.updateById(trade);
|
|
|
|
|
|
|
|
|
|
+ // 交易的 优惠券id 使用
|
|
|
|
|
+ if (tradeResponse.getCouponUseId() != null) {
|
|
|
|
|
+ // 更新优惠券的状态
|
|
|
|
|
+ //类型转换
|
|
|
|
|
+ CouponUse couponUse = new CouponUse();
|
|
|
|
|
+ //优惠券使用id
|
|
|
|
|
+ couponUse.setUseId(tradeResponse.getCouponUseId());
|
|
|
|
|
+ //优惠券状态
|
|
|
|
|
+ couponUse.setCouponStatus(Constant.couponStatus.YI_SHI_YONG.getName());
|
|
|
|
|
+ //核销日期
|
|
|
|
|
+ couponUse.setUseDate(LocalDateTime.now());
|
|
|
|
|
+ //更新
|
|
|
|
|
+ couponUseMapper.update(couponUse,
|
|
|
|
|
+ new UpdateWrapper<CouponUse>().lambda()
|
|
|
|
|
+ .eq(CouponUse::getUseId, java.util.UUID.fromString(couponUse.getUseId())));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 使用员工
|
|
|
|
|
+ if (tradeResponse.getIntegral() > 0) {
|
|
|
|
|
+ CouponUseResponse couponUseResponse = couponUseMapper.selectById(tradeResponse.getCouponUseId());
|
|
|
|
|
+ String staffName = couponUseResponse.getUseStaff();
|
|
|
|
|
+ // 积分的使用
|
|
|
|
|
+ // 积分明细
|
|
|
|
|
+ IntegralItem integralItem = new IntegralItem();
|
|
|
|
|
+ integralItem.setIntegralType(Constant.IntegralType.INTEGRAL_TYPE_USE.getName());
|
|
|
|
|
+ integralItem.setIntegral(-1 * tradeResponse.getIntegral());
|
|
|
|
|
+ integralItem.setCpId(tradeResponse.getCpId());
|
|
|
|
|
+ integralItem.setAccDate(LocalDateTime.now());
|
|
|
|
|
+ integralItem.setUserId(trade.getWxUserId());
|
|
|
|
|
+ integralItem.setStaffName(staffName);
|
|
|
|
|
+ integralItemMapper.insert(integralItem);
|
|
|
|
|
+ // 积分 总积分
|
|
|
|
|
+ Integral integral = new Integral();
|
|
|
|
|
+ integral.setCpId(tradeResponse.getCpId());
|
|
|
|
|
+ integral.setIntegral(-1 * tradeResponse.getIntegral());
|
|
|
|
|
+ integralMapper.updateById(integral);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 交易类型-续费- 将该公司的 生成一个job的任务
|
|
// 交易类型-续费- 将该公司的 生成一个job的任务
|
|
|
if (Constant.TradeType.RENEW.getName().equals(trade.getTradeType())) {
|
|
if (Constant.TradeType.RENEW.getName().equals(trade.getTradeType())) {
|
|
|
log.error("交易类型-续费插入任务数据-getTradeType:" + trade.getTradeType());
|
|
log.error("交易类型-续费插入任务数据-getTradeType:" + trade.getTradeType());
|
|
@@ -256,7 +317,7 @@ public class WechatPayService {
|
|
|
log.info("@XxlJob(\"renewReminder\")id: {}", XxlJobHelper.getJobParam());
|
|
log.info("@XxlJob(\"renewReminder\")id: {}", XxlJobHelper.getJobParam());
|
|
|
try {
|
|
try {
|
|
|
// Integer cpid = 382;
|
|
// Integer cpid = 382;
|
|
|
- Company company = companyMapper.selectById( XxlJobHelper.getJobParam());
|
|
|
|
|
|
|
+ Company company = companyMapper.selectById(XxlJobHelper.getJobParam());
|
|
|
// 解析license信息
|
|
// 解析license信息
|
|
|
String licenseStr = AESUtil.desEncrypt(company.getLicense());
|
|
String licenseStr = AESUtil.desEncrypt(company.getLicense());
|
|
|
log.error("续费的公司提醒回调-licenseStr:" + licenseStr);
|
|
log.error("续费的公司提醒回调-licenseStr:" + licenseStr);
|