diff --git a/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java b/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java index f197ab070..958402dbd 100644 --- a/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java +++ b/consumer/src/main/java/cn/lili/timetask/handler/impl/bill/BillExecute.java @@ -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; /** @@ -29,8 +28,8 @@ public class BillExecute implements EveryDayExecute { /** * 店铺详情 */ - @Resource - private StoreDetailMapper storeDetailMapper; + @Autowired + private StoreDetailService storeDetailService; /** * 1.查询今日待结算的商家 @@ -44,18 +43,18 @@ public void execute() { int day = DateUtil.date().dayOfMonth(); //获取待结算商家列表 - List storeList = storeDetailMapper.getSettlementStore(day); + List 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); } } } diff --git a/consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java b/consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java new file mode 100644 index 000000000..969fa7fc0 --- /dev/null +++ b/consumer/src/test/java/cn/lili/buyer/test/bill/BillTest.java @@ -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 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); + } + + +} diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java index 6597bf567..eab78d76f 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/BillServiceImpl.java @@ -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()); @@ -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(); }