|
@@ -23,8 +23,12 @@ import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.company.util.WechatApi;
|
|
import com.fs.company.util.WechatApi;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
|
|
+import com.fs.event.TemplateBean;
|
|
|
|
|
+import com.fs.event.TemplateEvent;
|
|
|
|
|
+import com.fs.event.TemplateListenEnum;
|
|
|
import com.fs.his.domain.*;
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.enums.BusinessTypeEnum;
|
|
import com.fs.his.enums.BusinessTypeEnum;
|
|
|
|
|
+import com.fs.his.enums.FsInquiryOrderStatusEnum;
|
|
|
import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
|
import com.fs.his.enums.PaymentMethodEnum;
|
|
import com.fs.his.enums.PaymentMethodEnum;
|
|
|
import com.fs.his.mapper.*;
|
|
import com.fs.his.mapper.*;
|
|
@@ -35,6 +39,9 @@ import com.fs.his.vo.FsIntegralOrderListUVO;
|
|
|
import com.fs.his.vo.FsIntegralOrderListVO;
|
|
import com.fs.his.vo.FsIntegralOrderListVO;
|
|
|
import com.fs.his.vo.FsIntegralOrderPVO;
|
|
import com.fs.his.vo.FsIntegralOrderPVO;
|
|
|
import com.fs.his.vo.FsStoreProductDeliverExcelVO;
|
|
import com.fs.his.vo.FsStoreProductDeliverExcelVO;
|
|
|
|
|
+import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
|
|
|
+import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
|
|
+import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
import com.fs.tzBankPay.doman.PayType;
|
|
import com.fs.tzBankPay.doman.PayType;
|
|
@@ -44,13 +51,17 @@ import com.fs.ybPay.service.IPayService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.redisson.api.RObjectAsync;
|
|
import org.redisson.api.RObjectAsync;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.context.ApplicationEventPublisher;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -66,6 +77,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Service
|
|
@Service
|
|
|
public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
{
|
|
{
|
|
|
|
|
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsIntegralOrderMapper fsIntegralOrderMapper;
|
|
private FsIntegralOrderMapper fsIntegralOrderMapper;
|
|
|
|
|
|
|
@@ -94,6 +106,8 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsStorePaymentService storePaymentService;
|
|
private IFsStorePaymentService storePaymentService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ private FsStorePaymentMapper storePaymentMapper;
|
|
|
|
|
+ @Autowired
|
|
|
private IFsIntegralCartService cartService;
|
|
private IFsIntegralCartService cartService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyUserService companyUserService;
|
|
private ICompanyUserService companyUserService;
|
|
@@ -103,6 +117,12 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserService userService;
|
|
private IFsUserService userService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ HuiFuService huiFuService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ApplicationEventPublisher publisher;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询积分商品订单
|
|
* 查询积分商品订单
|
|
|
*
|
|
*
|
|
@@ -512,7 +532,6 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
logs.setBusinessId(order.getOrderId().toString());
|
|
logs.setBusinessId(order.getOrderId().toString());
|
|
|
logs.setCreateTime(new Date());
|
|
logs.setCreateTime(new Date());
|
|
|
fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
|
-
|
|
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -679,7 +698,46 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsUserIntegralLogs.setBusinessType(2);
|
|
fsUserIntegralLogs.setBusinessType(2);
|
|
|
fsUserIntegralLogs.setStatus(0);
|
|
fsUserIntegralLogs.setStatus(0);
|
|
|
i = fsUserIntegralLogsMapper.insertFsUserIntegralLogs(fsUserIntegralLogs);
|
|
i = fsUserIntegralLogsMapper.insertFsUserIntegralLogs(fsUserIntegralLogs);
|
|
|
|
|
+ //还原库存
|
|
|
|
|
+ if (fsIntegralOrder.getItemJson().startsWith("[") && fsIntegralOrder.getItemJson().endsWith("]")){
|
|
|
|
|
+ List<FsIntegralGoods> goodsItem = JSONUtil.toBean(fsIntegralOrder.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
|
|
+ goodsItem.forEach(goods -> fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ FsIntegralGoods integralGoods = JSONUtil.toBean(fsIntegralOrder.getItemJson(), FsIntegralGoods.class);
|
|
|
|
|
+ fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ //还原金额
|
|
|
|
|
+ List<FsStorePayment> payments = storePaymentMapper.selectFsStorePaymentByPay(6,fsIntegralOrder.getOrderId());
|
|
|
|
|
+ if(payments!=null&&payments.size()==1){
|
|
|
|
|
+ FsStorePayment payment=payments.get(0);
|
|
|
|
|
+ V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
|
|
+ request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
|
|
+ request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
|
|
+ Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
|
|
+ extendInfoMap.put("org_req_seq_id", "integral-"+payment.getPayCode());
|
|
|
|
|
+ request.setExtendInfo(extendInfoMap);
|
|
|
|
|
+ HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
|
|
+ logger.info("积分退款返回结果:积分订单id:"+fsIntegralOrder.getOrderId()+refund);
|
|
|
|
|
+ if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
|
|
+ FsStorePayment paymentMap=new FsStorePayment();
|
|
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
|
|
+ storePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
|
|
+ TemplateBean templateBean = TemplateBean.builder()
|
|
|
|
|
+ .orderId(fsIntegralOrder.getOrderId().toString())
|
|
|
|
|
+ .title("订单已取消")
|
|
|
|
|
+ .remark("您的订单已取消")
|
|
|
|
|
+ .uid(fsIntegralOrder.getUserId())
|
|
|
|
|
+ .templateType(TemplateListenEnum.TYPE_1.getValue())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ publisher.publishEvent(new TemplateEvent(this, templateBean));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return i;
|
|
return i;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -713,7 +771,44 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsUserIntegralLogs.setBusinessType(2);
|
|
fsUserIntegralLogs.setBusinessType(2);
|
|
|
fsUserIntegralLogs.setStatus(0);
|
|
fsUserIntegralLogs.setStatus(0);
|
|
|
i = fsUserIntegralLogsMapper.insertFsUserIntegralLogs(fsUserIntegralLogs);
|
|
i = fsUserIntegralLogsMapper.insertFsUserIntegralLogs(fsUserIntegralLogs);
|
|
|
- //todo:库存是否需要退还,待定
|
|
|
|
|
|
|
+ //还原库存
|
|
|
|
|
+ if (fsIntegralOrder.getItemJson().startsWith("[") && fsIntegralOrder.getItemJson().endsWith("]")){
|
|
|
|
|
+ List<FsIntegralGoods> goodsItem = JSONUtil.toBean(fsIntegralOrder.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
|
|
+ goodsItem.forEach(goods -> fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ FsIntegralGoods integralGoods = JSONUtil.toBean(fsIntegralOrder.getItemJson(), FsIntegralGoods.class);
|
|
|
|
|
+ fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ //还原金额
|
|
|
|
|
+ List<FsStorePayment> payments = storePaymentMapper.selectFsStorePaymentByPay(6,fsIntegralOrder.getOrderId());
|
|
|
|
|
+ if(payments!=null&&payments.size()==1){
|
|
|
|
|
+ FsStorePayment payment=payments.get(0);
|
|
|
|
|
+ V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
|
|
+ request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
|
|
+ request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
|
|
+ Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
|
|
+ extendInfoMap.put("org_req_seq_id", "integral-"+payment.getPayCode());
|
|
|
|
|
+ request.setExtendInfo(extendInfoMap);
|
|
|
|
|
+ HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
|
|
+ logger.info("积分退款返回结果:积分订单id:"+fsIntegralOrder.getOrderId()+refund);
|
|
|
|
|
+ if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
|
|
+ FsStorePayment paymentMap=new FsStorePayment();
|
|
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
|
|
+ storePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
|
|
+ TemplateBean templateBean = TemplateBean.builder()
|
|
|
|
|
+ .orderId(fsIntegralOrder.getOrderId().toString())
|
|
|
|
|
+ .title("订单已取消")
|
|
|
|
|
+ .remark("您的订单已取消")
|
|
|
|
|
+ .uid(fsIntegralOrder.getUserId())
|
|
|
|
|
+ .templateType(TemplateListenEnum.TYPE_1.getValue())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ publisher.publishEvent(new TemplateEvent(this, templateBean));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return i;
|
|
return i;
|
|
|
}
|
|
}
|