Skip to content

Commit

Permalink
修复店铺结算单结算金额对于积分商品和砍价商品重复计算问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Jan 10, 2022
1 parent ad1f086 commit d2cab9f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.mapper.StoreDetailMapper;
import cn.lili.modules.store.service.BillService;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.timetask.handler.EveryDayExecute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
Expand All @@ -29,8 +28,8 @@ public class BillExecute implements EveryDayExecute {
/**
* 店铺详情
*/
@Resource
private StoreDetailMapper storeDetailMapper;
@Autowired
private StoreDetailService storeDetailService;

/**
* 1.查询今日待结算的商家
Expand All @@ -44,18 +43,18 @@ public void execute() {
int day = DateUtil.date().dayOfMonth();

//获取待结算商家列表
List<StoreSettlementDay> storeList = storeDetailMapper.getSettlementStore(day);
List<StoreSettlementDay> storeList = storeDetailService.getSettlementStore(day);

//获取当前时间
DateTime endTime =DateUtil.date();
DateTime endTime = DateUtil.date();
//批量商家结算
for (StoreSettlementDay storeSettlementDay : storeList) {

//生成结算单
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(),endTime);
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime);

//修改店铺结算时间
storeDetailMapper.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
}
}
}
61 changes: 61 additions & 0 deletions consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cn.lili.buyer.test.bill;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.service.BillService;
import cn.lili.modules.store.service.StoreDetailService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.util.List;

/**
* @author paulG
* @since 2022/1/10
**/
@ExtendWith(SpringExtension.class)
@SpringBootTest
public class BillTest {


/**
* 结算单
*/
@Autowired
private BillService billService;

/**
* 店铺详情
*/
@Autowired
private StoreDetailService storeDetailService;

@Test
void createBillTest() {
//获取当前天数
int day = DateUtil.date().dayOfMonth();

//获取待结算商家列表
List<StoreSettlementDay> storeList = storeDetailService.getSettlementStore(day);

//获取当前时间
DateTime endTime = DateUtil.date();
//批量商家结算
for (StoreSettlementDay storeSettlementDay : storeList) {

//生成结算单
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime);

//修改店铺结算时间
storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
}
Assertions.assertTrue(true);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void createBill(String storeId, Date startTime, DateTime endTime) {
.eq("store_id", storeId)
.eq("flow_type", FlowTypeEnum.PAY.name())
.between("create_time", startTime, endTime));
Double orderPrice = 0D;
double orderPrice = 0D;
if (orderBill != null) {
bill.setOrderPrice(orderBill.getOrderPrice());
bill.setCommissionPrice(orderBill.getCommissionPrice());
Expand All @@ -99,8 +99,7 @@ public void createBill(String storeId, Date startTime, DateTime endTime) {
bill.setPointSettlementPrice(orderBill.getPointSettlementPrice());
bill.setKanjiaSettlementPrice(orderBill.getKanjiaSettlementPrice());
//入账金额=订单金额+积分商品+砍价商品
orderPrice = CurrencyUtil.add(CurrencyUtil.add(orderBill.getBillPrice(), orderBill.getPointSettlementPrice()),
orderBill.getKanjiaSettlementPrice());
orderPrice = orderBill.getBillPrice();
}


Expand Down

0 comments on commit d2cab9f

Please sign in to comment.