|
|
@@ -17,8 +17,6 @@ import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
import com.ruoyi.web.pcApi.domain.TCommodityCoupon;
|
|
|
import com.ruoyi.web.pcApi.domain.TCommoditySchedul;
|
|
|
import com.ruoyi.web.pcApi.domain.TCustomerCoupon;
|
|
|
-import com.ruoyi.web.pcApi.domain.TCustomerDistributionRecord;
|
|
|
-import com.ruoyi.web.pcApi.domain.TCustomerDistributionSet;
|
|
|
import com.ruoyi.web.pcApi.domain.TCustomerIntegralRecord;
|
|
|
import com.ruoyi.web.pcApi.domain.TCustomerIntegralSet;
|
|
|
import com.ruoyi.web.pcApi.domain.TCustomerManage;
|
|
|
@@ -28,8 +26,6 @@ import com.ruoyi.web.pcApi.domain.TOrderManageTotal;
|
|
|
import com.ruoyi.web.pcApi.service.ITCommodityCouponService;
|
|
|
import com.ruoyi.web.pcApi.service.ITCommoditySchedulService;
|
|
|
import com.ruoyi.web.pcApi.service.ITCustomerCouponService;
|
|
|
-import com.ruoyi.web.pcApi.service.ITCustomerDistributionRecordService;
|
|
|
-import com.ruoyi.web.pcApi.service.ITCustomerDistributionSetService;
|
|
|
import com.ruoyi.web.pcApi.service.ITCustomerIntegralRecordService;
|
|
|
import com.ruoyi.web.pcApi.service.ITCustomerIntegralSetService;
|
|
|
import com.ruoyi.web.pcApi.service.ITCustomerManageService;
|
|
|
@@ -53,8 +49,6 @@ public class PayApi implements Serializable {
|
|
|
@Autowired
|
|
|
private ITCustomerCouponService customerCouponService;
|
|
|
@Autowired
|
|
|
- private ITCustomerDistributionRecordService customerDistributionRecordService;
|
|
|
- @Autowired
|
|
|
private ITCommoditySchedulService commoditySchedulService;
|
|
|
@Autowired
|
|
|
private ITOrderManageService orderManageService;
|
|
|
@@ -63,8 +57,6 @@ public class PayApi implements Serializable {
|
|
|
@Autowired
|
|
|
private ITCustomerIntegralSetService customerIntegralSetService;
|
|
|
@Autowired
|
|
|
- private ITCustomerDistributionSetService customerDistributionSetService;
|
|
|
- @Autowired
|
|
|
private ITOrderManageTotalService orderManageTotalService;
|
|
|
@Autowired
|
|
|
private LineMessagingClient lineMessagingClient;
|
|
|
@@ -92,52 +84,47 @@ public class PayApi implements Serializable {
|
|
|
TCustomerManage customerManage = customerManageService.selectTCustomerManageById(orderManage.getCustomerId());
|
|
|
// 取得下单时的积分记录
|
|
|
TCustomerIntegralRecord tCustomerIntegral = new TCustomerIntegralRecord();
|
|
|
- tCustomerIntegral.setOrderId(orderManage.getOrderTotalId());
|
|
|
+ tCustomerIntegral.setOrderId(orderManage.getId());
|
|
|
List<TCustomerIntegralRecord> lst = customerIntegralRecordService.selectTCustomerIntegralRecordList(tCustomerIntegral);
|
|
|
- //
|
|
|
- //是否有积分变化
|
|
|
- boolean isHasChange = false;
|
|
|
//原始积分
|
|
|
long jifen = customerManage.getIntegral();
|
|
|
- //退款钱和积分合计
|
|
|
- long ret = 0;
|
|
|
+
|
|
|
for (TCustomerIntegralRecord recd : lst) {
|
|
|
//下订单是的积分
|
|
|
- Long val = Long.valueOf(recd.getIntegralNum());
|
|
|
+ Long val = Long.valueOf(recd.getIntegralNum());
|
|
|
//如果是下单记录则则退款减算
|
|
|
if ("1".equals(recd.getIntegralType())) {
|
|
|
- //用户积分更新 减算
|
|
|
- customerManage.setIntegral(customerManage.getIntegral() - val);
|
|
|
- ret = ret + val;
|
|
|
- isHasChange = true;
|
|
|
+// //用户积分更新 减算
|
|
|
+// customerManage.setIntegral(customerManage.getIntegral() - val);
|
|
|
+ // 记录减去用户积分
|
|
|
+ customerIntegralRecordService.insertTCustomerIntegralRecord(TCustomerIntegralRecord.builder().
|
|
|
+ supIntegral(String.valueOf(jifen)).integralNum(recd.getIntegralNum()).integralType("9")// 退款类型
|
|
|
+ .createBy(userName).orderId(orderManage.getOrderTotalId()).customerId(customerManage.getId()).deptId(deptId)
|
|
|
+ .build());
|
|
|
} else if ("4".equals(recd.getIntegralType())) {
|
|
|
//如果是利用积分记录退款则加算
|
|
|
//用户积分更新 加算
|
|
|
customerManage.setIntegral(customerManage.getIntegral() + val);
|
|
|
- ret = ret + val;
|
|
|
- isHasChange = true;
|
|
|
+ // 记录减去用户积分
|
|
|
+ customerIntegralRecordService.insertTCustomerIntegralRecord(TCustomerIntegralRecord.builder().
|
|
|
+ supIntegral(String.valueOf(jifen)).integralNum(recd.getIntegralNum()).integralType("5")// 积分还原
|
|
|
+ .createBy(userName).orderId(orderManage.getOrderTotalId()).customerId(customerManage.getId()).deptId(deptId)
|
|
|
+ .build());
|
|
|
+ //用户积分更新
|
|
|
+ customerManageService.updateTCustomerManage(customerManage);
|
|
|
}
|
|
|
}
|
|
|
- //有积分变化
|
|
|
- if (isHasChange) {
|
|
|
- // 记录减去用户积分
|
|
|
- customerIntegralRecordService.insertTCustomerIntegralRecord(TCustomerIntegralRecord.builder().
|
|
|
- supIntegral(String.valueOf(jifen)).integralNum(String.valueOf(ret)).integralType("9")// 退款类型
|
|
|
- .createBy(userName).orderId(orderManage.getOrderTotalId()).customerId(customerManage.getId()).deptId(deptId)
|
|
|
- .build());
|
|
|
-
|
|
|
- customerManageService.updateTCustomerManage(customerManage);
|
|
|
- }
|
|
|
+
|
|
|
//分销返还
|
|
|
- TCustomerDistributionRecord distribution = new TCustomerDistributionRecord();
|
|
|
- distribution.setOrderId(orderManage.getOrderTotalId());
|
|
|
- List<TCustomerDistributionRecord> distributionLst = customerDistributionRecordService.selectTCustomerDistributionRecordList(distribution);
|
|
|
- for (TCustomerDistributionRecord recd : distributionLst) {
|
|
|
- //这里不是删除,进行减算
|
|
|
- customerDistributionRecordService.insertTCustomerDistributionRecord(
|
|
|
- TCustomerDistributionRecord.builder().customerId(recd.getCustomerId()).deptId(deptId)
|
|
|
- .distributionIntegral("-" + recd.getDistributionIntegral()).createBy(userName).orderId(orderManage.getOrderTotalId()).build());
|
|
|
- }
|
|
|
+// TCustomerDistributionRecord distribution = new TCustomerDistributionRecord();
|
|
|
+// distribution.setOrderId(orderManage.getId());
|
|
|
+// List<TCustomerDistributionRecord> distributionLst = customerDistributionRecordService.selectTCustomerDistributionRecordList(distribution);
|
|
|
+// for (TCustomerDistributionRecord recd : distributionLst) {
|
|
|
+// //这里不是删除,进行减算
|
|
|
+// customerDistributionRecordService.insertTCustomerDistributionRecord(
|
|
|
+// TCustomerDistributionRecord.builder().customerId(recd.getCustomerId()).deptId(deptId)
|
|
|
+// .distributionIntegral("-" + recd.getDistributionIntegral()).createBy(userName).orderId(orderManage.getId()).build());
|
|
|
+// }
|
|
|
// 重置用户商品优惠券
|
|
|
if(orderManage.getIsCoupon().equals("1")){
|
|
|
List<TCommodityCoupon> commodityCouponList =
|
|
|
@@ -162,30 +149,23 @@ public class PayApi implements Serializable {
|
|
|
* @param loginuser Login用户
|
|
|
*/
|
|
|
public void pay(TOrderManageTotal orderManageTotal, LoginUser loginuser) {
|
|
|
- //set order list
|
|
|
- TOrderManage orderPram = new TOrderManage();
|
|
|
- orderPram.setOrderTotalId(orderManageTotal.getId());
|
|
|
-
|
|
|
- List<TOrderManage> orderList = orderManageService.selectTOrderManageList(orderPram);
|
|
|
-
|
|
|
- orderManageTotal.setOrderList(orderList);
|
|
|
TCustomerManage customer = customerManageService.selectTCustomerManageById(loginuser.getLoginCustomer().getId());
|
|
|
// 多/单订单支付
|
|
|
for (TOrderManage order : orderManageTotal.getOrderList()) {
|
|
|
TOrderManage orderManage = orderManageService.selectTOrderManageById(order.getId());
|
|
|
/** 通知待使用*/
|
|
|
- customerNoticeService.insertTCustomerNotice(TCustomerNotice.builder().customerId(customer.getId()).commodityId(order.getId())
|
|
|
+ customerNoticeService.insertTCustomerNotice(TCustomerNotice.builder().customerId(customer.getId()).commodityId(orderManage.getId())
|
|
|
.content("您有一张" + orderManage.getCommodityName() + "商品待使用。").title("订单信息")
|
|
|
.createBy(orderManage.getCreateBy()).status("0")
|
|
|
.build());
|
|
|
// 若使用积分 则订单金额减去积分金额
|
|
|
if(orderManageTotal.getIntegralDeduction().compareTo(BigDecimal.ZERO) > 0 && orderManageTotal.getIntegralDeduction() != null){
|
|
|
- order.setOrderMoney(orderManage.getOrderMoney().subtract(orderManageTotal.getIntegralDeduction()));
|
|
|
- order.setIntegralDeduction(orderManageTotal.getIntegralDeduction());
|
|
|
+ orderManage.setOrderMoney(orderManage.getOrderMoney().subtract(orderManageTotal.getIntegralDeduction()));
|
|
|
+ orderManage.setIntegralDeduction(orderManageTotal.getIntegralDeduction());
|
|
|
}
|
|
|
- order.setStatus("1");// 已支付 支付状态,若接入支付回调,则变更为支付中状态-9,支付回调成功后变更为1-已支付
|
|
|
- order.setPayDate(new Date());
|
|
|
- orderManageService.updateTOrderManage(order);
|
|
|
+ orderManage.setStatus("1");// 已支付 支付状态,若接入支付回调,则变更为支付中状态-9,支付回调成功后变更为1-已支付
|
|
|
+ orderManage.setPayDate(new Date());
|
|
|
+ orderManageService.updateTOrderManage(orderManage);
|
|
|
}
|
|
|
|
|
|
// 获取场馆积分获取比例
|
|
|
@@ -194,59 +174,41 @@ public class PayApi implements Serializable {
|
|
|
|
|
|
//只有有积分奖励的才可以积分
|
|
|
if (tCustomerIntegralSets.size() > 0) {
|
|
|
- // 计算积分奖励
|
|
|
- BigDecimal orderIntegral = orderManageTotal.getOrderMoney();
|
|
|
-
|
|
|
- BigDecimal proportion = new BigDecimal(tCustomerIntegralSets.get(0).getProportion()).divide(new BigDecimal("100"));
|
|
|
- orderIntegral= (orderManageTotal.getOrderMoney().multiply(proportion)).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
-
|
|
|
- if (orderIntegral.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- // 记录用户积分
|
|
|
- customerIntegralRecordService.insertTCustomerIntegralRecord(TCustomerIntegralRecord.builder().
|
|
|
- supIntegral(customer.getIntegral()==null?"0":customer.getIntegral().toString()).integralNum(String.valueOf(orderIntegral.longValue())).integralType("1")
|
|
|
- .createBy(loginuser.getLoginCustomer().getUsername()).orderId(orderManageTotal.getId()).customerId(customer.getId()).deptId(loginuser.getDeptId())
|
|
|
- .build());
|
|
|
- /** 增加用户积分*/
|
|
|
- customer.setIntegral(customer.getIntegral()==null?0:customer.getIntegral() + orderIntegral.longValue());
|
|
|
- customerManageService.updateTCustomerManage(customer);
|
|
|
- }
|
|
|
+ for (TOrderManage order : orderManageTotal.getOrderList()) {
|
|
|
+ // 计算积分奖励
|
|
|
+ BigDecimal orderIntegral = order.getOrderMoney();
|
|
|
+
|
|
|
+ BigDecimal proportion = new BigDecimal(tCustomerIntegralSets.get(0).getProportion()).divide(new BigDecimal("100"));
|
|
|
+ orderIntegral= (order.getOrderMoney().multiply(proportion)).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
+
|
|
|
+ if (orderIntegral.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ // 记录用户积分
|
|
|
+ customerIntegralRecordService.insertTCustomerIntegralRecord(TCustomerIntegralRecord.builder().
|
|
|
+ supIntegral(customer.getIntegral()==null?"0":customer.getIntegral().toString()).integralNum(String.valueOf(orderIntegral.longValue())).integralType("1")
|
|
|
+ .createBy(loginuser.getLoginCustomer().getUsername()).orderId(order.getId()).customerId(customer.getId()).deptId(loginuser.getDeptId())
|
|
|
+ .build());
|
|
|
+ /** 增加用户积分*/
|
|
|
+ //customer.setIntegral(customer.getIntegral()==null?0:customer.getIntegral() + orderIntegral.longValue());
|
|
|
+ //customerManageService.updateTCustomerManage(customer);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 会员减去积分
|
|
|
- if(orderManageTotal.getIntegralDeduction() != null &&
|
|
|
- orderManageTotal.getIntegralDeduction().compareTo(BigDecimal.ZERO) > 0){
|
|
|
- customer.setIntegral(customer.getIntegral() - orderManageTotal.getIntegralDeduction().longValue());
|
|
|
+ for (TOrderManage order : orderManageTotal.getOrderList()) {
|
|
|
+ TOrderManage orderManage = orderManageService.selectTOrderManageById(order.getId());
|
|
|
+ if (orderManage.getIntegralDeduction().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ customer.setIntegral(customer.getIntegral() - orderManage.getIntegralDeduction().longValue());
|
|
|
customerManageService.updateTCustomerManage(customer);
|
|
|
// 记录减去用户积分
|
|
|
customerIntegralRecordService.insertTCustomerIntegralRecord(TCustomerIntegralRecord.builder().
|
|
|
- supIntegral(customer.getIntegral().toString()).integralNum(String.valueOf(orderManageTotal.getIntegralDeduction().longValue())).integralType("4")
|
|
|
- .createBy(loginuser.getLoginCustomer().getUsername()).orderId(orderManageTotal.getId()).customerId(
|
|
|
+ supIntegral(customer.getIntegral().toString()).integralNum(String.valueOf(orderManage.getIntegralDeduction().longValue())).integralType("4")
|
|
|
+ .createBy(loginuser.getLoginCustomer().getUsername()).orderId(orderManage.getId()).customerId(
|
|
|
customer.getId()).deptId(loginuser.getDeptId())
|
|
|
.build());
|
|
|
- }
|
|
|
-
|
|
|
- // 是否有分销
|
|
|
- if (orderManageTotal.getDistributionId() != null) {
|
|
|
- // 获取场馆分销比例
|
|
|
- List<TCustomerDistributionSet> tCustomerDistributionSets = customerDistributionSetService.selectTCustomerDistributionSetList(
|
|
|
- TCustomerDistributionSet.builder().deptId(
|
|
|
- loginuser.getLoginCustomer().getDeptId()).build());
|
|
|
- if (tCustomerDistributionSets.size() > 0) {
|
|
|
- // 计算分销人员奖励
|
|
|
- BigDecimal proportion = new BigDecimal(tCustomerDistributionSets.get(0).getProportion()).divide(new BigDecimal("100"));
|
|
|
- BigDecimal integral = (orderManageTotal.getOrderMoney().multiply(proportion)).setScale(0, BigDecimal.ROUND_DOWN);
|
|
|
-
|
|
|
- // 增加用户积分
|
|
|
- TCustomerManage customerManage = customerManageService.selectTCustomerManageById(orderManageTotal.getDistributionId());
|
|
|
- customerManage.setIntegral(customerManage.getIntegral() + integral.longValue());
|
|
|
- customerManageService.updateTCustomerManage(customerManage);
|
|
|
-
|
|
|
- // 记录分销
|
|
|
- customerDistributionRecordService.insertTCustomerDistributionRecord(
|
|
|
- TCustomerDistributionRecord.builder().customerId(orderManageTotal.getDistributionId()).deptId(loginuser.getLoginCustomer().getDeptId())
|
|
|
- .distributionIntegral(integral.toString()).createBy(loginuser.getLoginCustomer().getUsername()).orderId(orderManageTotal.getId()).build());
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
// 查询总订单下-是否还有未支付的信息
|
|
|
List<TOrderManage> orderManageList = orderManageService.selectTOrderManageList(TOrderManage.builder().
|