|
@@ -4,13 +4,17 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
+import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
+import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
|
|
@@ -26,6 +30,8 @@ import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
import com.zhongzheng.modules.order.service.IOrderService;
|
|
|
import com.zhongzheng.modules.order.vo.OrderGoodsRefundVo;
|
|
|
import com.zhongzheng.modules.order.vo.OrderGoodsVo;
|
|
|
+import com.zhongzheng.modules.order.vo.OrderShareGoodsVo;
|
|
|
+import com.zhongzheng.modules.order.vo.OrderShareToOldVo;
|
|
|
import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
|
|
@@ -33,9 +39,12 @@ import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.domain.UserStudyRecord;
|
|
|
import com.zhongzheng.modules.user.service.IUserExamGoodsService;
|
|
|
import com.zhongzheng.modules.user.service.IUserExamRecordService;
|
|
|
+import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
+import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
import com.zhongzheng.modules.wx.service.IWxPayService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -43,10 +52,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -74,7 +82,10 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
private IUserStudyRecordService iUserStudyRecordService;
|
|
|
@Autowired
|
|
|
private IUserExamGoodsService iUserExamGoodsService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IUserService iUserService;
|
|
|
+ @Value("${oldStudySys.shareCanclePath}")
|
|
|
+ private String SHARE_CANCLE_PATH;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -205,7 +216,10 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
}
|
|
|
Map<String, String> payResult = iWxPayService.refund(out_trade_no,order.getTransid(),add.getRefundFee(),order.getPayPrice());
|
|
|
if("OK".equals(payResult.get("return_msg"))&&Validator.isNotEmpty(payResult.get("refund_id"))){
|
|
|
- return refundCall(payResult.get("refund_id"),add.getRefundId(),orderGoods.getOrderGoodsId(),order,goods.getGoodsType(),orderGoods.getGradeId(),bo.getUserId(),goods.getGoodsId());
|
|
|
+ refundCall(payResult.get("refund_id"),add.getRefundId(),orderGoods.getOrderGoodsId(),order,goods.getGoodsType(),orderGoods.getGradeId(),bo.getUserId(),goods.getGoodsId());
|
|
|
+ //关闭C端用户的分销返利
|
|
|
+ shareClientCancelOldSys(order,orderGoods,add.getRefundFee());
|
|
|
+ return true;
|
|
|
}else{
|
|
|
throw new CustomException("退款错误"+ JSON.toJSONString(payResult));
|
|
|
}
|
|
@@ -339,6 +353,43 @@ public class OrderGoodsRefundServiceImpl extends ServiceImpl<OrderGoodsRefundMap
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 关闭C端用户的分销返利
|
|
|
+ * @param order
|
|
|
+ * @param orderGoods
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean shareClientCancelOldSys(Order order, OrderGoods orderGoods, BigDecimal refund_fee) {
|
|
|
+ if (Validator.isNotEmpty(order)) {
|
|
|
+ UserVo user = iUserService.queryById(order.getUserId());
|
|
|
+ if(Validator.isNotEmpty(user.getShareCode())){
|
|
|
+ OrderShareToOldVo vo = new OrderShareToOldVo();
|
|
|
+ vo.setOrderId(order.getOrderId());
|
|
|
+ vo.setCanceamount(refund_fee);
|
|
|
+ List<OrderShareGoodsVo> shareGoodsVoList = new ArrayList<>();
|
|
|
+ OrderShareGoodsVo shareGoodsVo = new OrderShareGoodsVo();
|
|
|
+ shareGoodsVo.setGoodsId(orderGoods.getGoodsId());
|
|
|
+ shareGoodsVoList.add(shareGoodsVo);
|
|
|
+ vo.setGoodsList(shareGoodsVoList);
|
|
|
+ //分销下单
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ String sign = ToolsUtils.EncoderByMd5(nowTime.toString()+"pubilc2022");
|
|
|
+ params.put("stamp", nowTime.toString());
|
|
|
+ params.put("sign", sign);
|
|
|
+ params.put("jsonstr", JSONObject.toJSONString(vo));
|
|
|
+ String respone = "";
|
|
|
+ try {
|
|
|
+ respone = HttpUtils.postFormBody(SHARE_CANCLE_PATH, params);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new CustomException("同步请求错误"+e.getMessage());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 退款清除数据
|
|
|
* @param gradeId
|