Commit c042d5b2 by huluobin

次卡id的set

parent 1ce7c5ae
......@@ -434,23 +434,24 @@ public class MarketServiceImpl implements MarketService {
timesCardUsedRecord.setDepartmentId(orderManage.getDepartmentId());
//次卡折扣的
timesCardUsedRecord.setServeName(orderServe.getServeName());
//次卡作用的订单详情id
timesCardUsedRecord.setOrderServeId(orderServe.getId());
//次卡作用的服务id
timesCardUsedRecord.setOrderServeId(orderServe.getServeId());
timesCardUsedRecord.setServeName(orderServe.getServeName());
//次卡作用的订单id
timesCardUsedRecord.setOrderId(orderId);
//次卡实付金额
timesCardUsedRecord.setActualDiscountAmount(actualDiscountAmount);
// timesCardUsedRecordService.updateById(timesCardUsedRecord);
//在主服务上折扣的钱
TimesCardOrderServeDetail timesCardOrderServeDetail = new TimesCardOrderServeDetail();
timesCardOrderServeDetail.setDiscountAmount(actualDiscountAmount);
timesCardOrderServeDetail.setOrderServeId(orderServe.getId());
timesCardOrderServeDetail.setOrderId(orderId);
timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getId());
//业绩
timesCardOrderServeDetail.setAchievement(timesCardUsedRecord.getPayAmount());
// timesCardOrderServeDetailMapper.insert(timesCardOrderServeDetail);
//订单折扣金额更新
orderServe.setBindTimesCard(1);
......@@ -459,15 +460,7 @@ public class MarketServiceImpl implements MarketService {
//业绩
orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
orderManage.addDiscountPrice(actualDiscountAmount);
//
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} else {
throw new RRException("次卡冲突");
}
......@@ -475,17 +468,9 @@ public class MarketServiceImpl implements MarketService {
});
}
//卡券之前删除订单服务和卡券关联
// couponOrderRelevanceService.remove(new LambdaQueryWrapper<CouponOrderRelevance>()
// .eq(CouponOrderRelevance::getOrderId, orderId));
//3、外部券
if (ListUtil.isNotEmpty(outerCouponCustomerRelevanceServiceList)) {
//删除之前的外部券抵扣情况记录
// couponOrderRelevanceService.remove(new LambdaQueryWrapper<CouponOrderRelevance>()
// .eq(CouponOrderRelevance::getOrderId, orderId)
// .in(CouponOrderRelevance::getCouponCustomerRelevanceId, outerCouponCustomerRelevanceServiceList.stream().map(CouponCustomerRelevance::getId).collect(Collectors.toList())));
outerCouponCustomerRelevanceServiceList
.stream()
.sorted(Comparator.comparing(CouponCustomerRelevance::getDiscountAmount).reversed())
......@@ -543,8 +528,6 @@ public class MarketServiceImpl implements MarketService {
orderServe.addDiscountPrice(actualDiscountAmount);
orderManage.addDiscountPrice(actualDiscountAmount);
orderServe.setBindOuterCoupon(1);
// couponOrderRelevanceService.save(couponOrderRelevance);
} else {
throw new RRException("%s与其他卡券冲突", couponCustomerRelevance.getCouponName());
}
......@@ -554,11 +537,6 @@ public class MarketServiceImpl implements MarketService {
//4、内部券
if (ListUtil.isNotEmpty(innerCouponCustomerRelevanceServiceList)) {
//删除之前的内部券抵扣情况记录
// couponOrderRelevanceService.remove(new LambdaQueryWrapper<CouponOrderRelevance>()
// .eq(CouponOrderRelevance::getOrderId, orderId)
// .in(CouponOrderRelevance::getCouponCustomerRelevanceId, innerCouponCustomerRelevanceServiceList.stream().map(CouponCustomerRelevance::getId).collect(Collectors.toList())));
//免单券Id
List<Integer> discountConfigListCouponId = discountConfigMapper.selectList(new QueryWrapper<>()).stream().map(DiscountConfig::getCouponId).filter(Objects::nonNull).collect(Collectors.toList());
......@@ -621,9 +599,6 @@ public class MarketServiceImpl implements MarketService {
} else {
couponOrderRelevance.setAchievement(couponOrderRelevance.getDiscountAmount());
}
//保存卡券在订单服务上的使用情况
// couponOrderRelevanceService.save(couponOrderRelevance);
System.out.println(orderServe.getAchievement());
//如果不是免单券 业绩就要扣除实际折扣金额
if (!discountConfigListCouponId.contains(couponCustomerRelevance.getCouponId())) {
......@@ -921,8 +896,12 @@ public class MarketServiceImpl implements MarketService {
//次卡折扣的
timesCardUsedRecord.setServeName(orderServe.getServeName());
//次卡作用的服务id
timesCardUsedRecord.setOrderServeId(orderServe.getServeId());
timesCardUsedRecord.setServeId(orderServe.getServeId());
//次卡作用的订单服务详情id
timesCardUsedRecord.setOrderServeId(orderServe.getId());
//次卡作用的订单id
timesCardUsedRecord.setOrderId(orderId);
//
timesCardUsedRecord.setActualDiscountAmount(actualDiscountAmount);
timesCardUsedRecordService.updateById(timesCardUsedRecord);
......@@ -931,7 +910,7 @@ public class MarketServiceImpl implements MarketService {
timesCardOrderServeDetail.setDiscountAmount(actualDiscountAmount);
timesCardOrderServeDetail.setOrderServeId(orderServe.getId());
timesCardOrderServeDetail.setOrderId(orderId);
timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getId());
//业绩
timesCardOrderServeDetail.setAchievement(timesCardUsedRecord.getPayAmount());
timesCardOrderServeDetailMapper.insert(timesCardOrderServeDetail);
......@@ -944,14 +923,6 @@ public class MarketServiceImpl implements MarketService {
orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
orderManage.addDiscountPrice(actualDiscountAmount);
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} else {
throw new RRException("次卡冲突");
}
......@@ -1263,8 +1234,12 @@ public class MarketServiceImpl implements MarketService {
//次卡折扣的
timesCardUsedRecord.setServeName(orderServe.getServeName());
//次卡作用的服务id
timesCardUsedRecord.setOrderServeId(orderServe.getServeId());
timesCardUsedRecord.setServeId(orderServe.getServeId());
//次卡作用的服务id
timesCardUsedRecord.setOrderServeId(orderServe.getId());
//
timesCardUsedRecord.setOrderId(orderId);
//
timesCardUsedRecord.setActualDiscountAmount(actualDiscountAmount);
timesCardUsedRecordService.updateById(timesCardUsedRecord);
......@@ -1273,7 +1248,8 @@ public class MarketServiceImpl implements MarketService {
timesCardOrderServeDetail.setDiscountAmount(actualDiscountAmount);
timesCardOrderServeDetail.setOrderServeId(orderServe.getId());
timesCardOrderServeDetail.setOrderId(orderId);
timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
//
timesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getId());
//业绩
timesCardOrderServeDetail.setAchievement(timesCardUsedRecord.getPayAmount());
timesCardOrderServeDetailMapper.insert(timesCardOrderServeDetail);
......@@ -1286,14 +1262,6 @@ public class MarketServiceImpl implements MarketService {
orderServe.setAchievement(orderServe.getAchievement().subtract(actualDiscountAmount).add(timesCardUsedRecord.getPayAmount()));
orderManage.addDiscountPrice(actualDiscountAmount);
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
} else {
throw new RRException("次卡冲突");
}
......
package com.gogirl.application.order.serve.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gogirl.domain.order.serve.MultiPaymentType;
import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.user.customer.CustomerBalanceRecord;
import com.gogirl.infrastructure.common.util.JsonUtilByFsJson;
import com.gogirl.infrastructure.mapper.order.serve.OrderManageMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/9/21 4:05 下午
*/
@ActiveProfiles("prod")
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class OrderManageServiceImplTest {
@Resource
OrderManageMapper orderManageMapper;
@Resource
CustomerBalanceRecordMapper customerBalanceRecordMapper;
@Test
public void test1() {
List<OrderManage> orderManageList = orderManageMapper.selectList(new LambdaQueryWrapper<OrderManage>()
.eq(OrderManage::getPaymentType, 12)
.isNull(OrderManage::getMultiplePaymentType));
orderManageList.forEach(orderManage -> {
CustomerBalanceRecord customerBalanceRecord = customerBalanceRecordMapper.selectOne(new LambdaQueryWrapper<CustomerBalanceRecord>()
.eq(CustomerBalanceRecord::getOrderId, orderManage.getId()));
BigDecimal cardAmount = new BigDecimal(customerBalanceRecord.getOrderAmount()).divide(new BigDecimal(100), 2, RoundingMode.HALF_DOWN);
BigDecimal wxAmount = orderManage.getTotalPaymentAmount().subtract(cardAmount);
orderManage.setMultiplePaymentType(JsonUtilByFsJson.beanToJson(Lists.newArrayList(
MultiPaymentType.builder()
.type(1)
.price(wxAmount)
.build(),
MultiPaymentType.builder()
.type(2)
.price(cardAmount)
.build()
)));
orderManageMapper.updateById(orderManage);
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment