|
@@ -1,10 +1,12 @@
|
|
|
package com.kmall.admin.service.impl.compared;
|
|
|
|
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
|
+import com.kmall.admin.dao.MallPaymentOrderDataDao;
|
|
|
import com.kmall.admin.dao.compared.PayOrderInfoDao;
|
|
|
import com.kmall.admin.dto.AliPaymentOrderDto;
|
|
|
import com.kmall.admin.dto.PayOrderDto;
|
|
|
import com.kmall.admin.dto.WxPaymentOrderDto;
|
|
|
+import com.kmall.admin.entity.MallPaymentOrderDataEntity;
|
|
|
import com.kmall.admin.entity.compared.PayOrderInfoEntity;
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
import com.kmall.admin.service.compared.PayOrderInfoService;
|
|
@@ -33,6 +35,8 @@ import java.util.Map;
|
|
|
public class PayOrderInfoServiceImpl implements PayOrderInfoService {
|
|
|
@Autowired
|
|
|
private PayOrderInfoDao payOrderInfoDao;
|
|
|
+ @Autowired
|
|
|
+ private MallPaymentOrderDataDao mallPaymentOrderDataDao;
|
|
|
|
|
|
@Override
|
|
|
public PayOrderInfoEntity queryObject(Integer mpoiId) {
|
|
@@ -264,4 +268,106 @@ public class PayOrderInfoServiceImpl implements PayOrderInfoService {
|
|
|
public void updateBatch(List<PayOrderInfoEntity> payOrderInfoEntities) {
|
|
|
payOrderInfoDao.updateBatch(payOrderInfoEntities);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String comparedTime(Map<String, Object> params) {
|
|
|
+ String comparedDate = params.get("comparedDate").toString();
|
|
|
+ String msg = null;
|
|
|
+ if (!StringUtils.isNotEmpty(comparedDate)) {
|
|
|
+ throw new RRException("日期不能为空!");
|
|
|
+ }
|
|
|
+ List<MallPaymentOrderDataEntity> mallPaymentOrderDataEntityList = mallPaymentOrderDataDao.queryListTime(params);
|
|
|
+ List<PayOrderInfoEntity> payOrderInfoEntityList = payOrderInfoDao.queryTimeAndPayType(params);
|
|
|
+ if (mallPaymentOrderDataEntityList.size() == 0) {
|
|
|
+ msg = "支付订单详情暂无【" + comparedDate + "】数据";
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+// if (payOrderInfoEntityList.size()>0) {
|
|
|
+// msg = "支付单对比详情【" + comparedDate + "】数据已同步,请勿重复操作!";
|
|
|
+// return msg;
|
|
|
+// }
|
|
|
+ comparedTime(mallPaymentOrderDataEntityList,payOrderInfoEntityList);
|
|
|
+ msg = "日期【" + comparedDate + "】数据同步成功!";
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void comparedTime(List<MallPaymentOrderDataEntity> mallPaymentOrderDataEntityList,List<PayOrderInfoEntity> payOrderInfoEntityList) {
|
|
|
+
|
|
|
+ List<PayOrderInfoEntity> insertList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (mallPaymentOrderDataEntityList != null && mallPaymentOrderDataEntityList.size() > 0) {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ SysUserEntity userEntity = ShiroUtils.getUserEntity();
|
|
|
+ for (MallPaymentOrderDataEntity payOrderDto : mallPaymentOrderDataEntityList) {
|
|
|
+ String payFlag = payOrderDto.getPayFlag();
|
|
|
+ String timeStr = payOrderDto.getTimeStr();
|
|
|
+ String outTradeNo = payOrderDto.getOutTradeNo();
|
|
|
+ String payMoney = payOrderDto.getPayMoney();
|
|
|
+ //支付宝退款金额
|
|
|
+ String refundMoney = payOrderDto.getRefundMoney();
|
|
|
+ //微信退款金额
|
|
|
+ String applyRefundAmount = payOrderDto.getApplyRefundAmount();
|
|
|
+ if (Dict.payFlag.item_alipay.getItem().equals(payFlag)) {
|
|
|
+ String style = payOrderDto.getPayType();
|
|
|
+ if (style == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!style.equals("在线支付") && !style.equals("退款(交易退款)")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (payOrderInfoEntityList != null && payOrderInfoEntityList.size() > 0) {
|
|
|
+ PayOrderInfoEntity merchOrderSn = payOrderInfoDao.queryByMerchOrderSn(outTradeNo);
|
|
|
+ if (merchOrderSn != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PayOrderInfoEntity payOrderInfoEntity = new PayOrderInfoEntity();
|
|
|
+ payOrderInfoEntity.setImporter(userEntity.getUserId() + ""); // 导入者id
|
|
|
+ payOrderInfoEntity.setImportTime(format.format(new Date())); // 导入时间
|
|
|
+ if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
|
+ if (StringUtils.isNotEmpty(payMoney) && !"0.00".equals(payMoney)) {
|
|
|
+ payOrderInfoEntity.setOrderStatus("300"); // 订单状态
|
|
|
+ payOrderInfoEntity.setOrderAmount(new BigDecimal(payMoney)); // 订单金额
|
|
|
+ } else {
|
|
|
+ payOrderInfoEntity.setOrderStatus("401"); // 订单状态
|
|
|
+ payOrderInfoEntity.setOrderAmount(new BigDecimal(0)); // 订单金额
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(applyRefundAmount) && !"0.00".equals(applyRefundAmount)) {
|
|
|
+ payOrderInfoEntity.setPayStatus("5"); // 支付状态
|
|
|
+ payOrderInfoEntity.setRefundAmount(new BigDecimal(applyRefundAmount)); // 退款金额
|
|
|
+ } else {
|
|
|
+ payOrderInfoEntity.setPayStatus("2"); // 支付状态
|
|
|
+ payOrderInfoEntity.setRefundAmount(new BigDecimal(0)); // 退款金额
|
|
|
+ }
|
|
|
+ } else if (Dict.payFlag.item_alipay.getItem().equals(payFlag)) {
|
|
|
+ if (StringUtils.isNotEmpty(payMoney)) {
|
|
|
+ payOrderInfoEntity.setOrderStatus("300"); // 订单状态
|
|
|
+ payOrderInfoEntity.setOrderAmount(new BigDecimal(payMoney)); // 订单金额
|
|
|
+ } else {
|
|
|
+ payOrderInfoEntity.setOrderStatus("401"); // 订单状态
|
|
|
+ payOrderInfoEntity.setOrderAmount(new BigDecimal(0)); // 订单金额
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(refundMoney)) {
|
|
|
+ payOrderInfoEntity.setPayStatus("5"); // 支付状态
|
|
|
+ payOrderInfoEntity.setRefundAmount(new BigDecimal(refundMoney)); // 退款金额
|
|
|
+ } else {
|
|
|
+ payOrderInfoEntity.setPayStatus("2"); // 支付状态
|
|
|
+ payOrderInfoEntity.setRefundAmount(new BigDecimal(0)); // 退款金额
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ payOrderInfoEntity.setPayFlag(payFlag); // 支付方式
|
|
|
+ payOrderInfoEntity.setPayTime(timeStr); // 交易时间
|
|
|
+
|
|
|
+ payOrderInfoEntity.setMerchOrderSn(outTradeNo); // 订单号
|
|
|
+ payOrderInfoEntity.setCompared("0"); // 是否对比过
|
|
|
+ insertList.add(payOrderInfoEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (insertList.size() > 0) {
|
|
|
+ payOrderInfoDao.saveBatch(insertList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|