|
@@ -73,6 +73,10 @@ public class WebsitSalesLogic {
|
|
|
AdminWebsitPayConfigService adminWebsitPayConfigService;
|
|
|
@Resource
|
|
|
WebsitSalesPayMapService websitSalesPayMapService;
|
|
|
+ @Resource
|
|
|
+ MaterialConfigService materialConfigService;
|
|
|
+ @Resource
|
|
|
+ WorkerGoodsRelaService workerGoodsRelaService;
|
|
|
|
|
|
public IPage<SalesOrderBean> buyList(String flag, Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
|
CurrentCompanyWechat wechat = commonLogic.getCurrentCompanyWechat(request);
|
|
@@ -157,6 +161,29 @@ public class WebsitSalesLogic {
|
|
|
goodsList = materialMapper.existStockGoods(wechat.getCurrentCompanyWechatId(), websitId, type, categoryId, goodsName);
|
|
|
} else {
|
|
|
goodsList = materialMapper.notStockGoods(wechat.getCurrentCompanyWechatId(), websitId, type, categoryId, goodsName);
|
|
|
+ if (CollectionUtil.isNotEmpty(goodsList)) {
|
|
|
+ final MaterialConfig config = materialConfigService.lambdaQuery()
|
|
|
+ .eq(MaterialConfig::getCompanyWechatId, wechat.getUser().getCompanyWechatId())
|
|
|
+ .one();
|
|
|
+ // 市场价乘于倍率
|
|
|
+ for (WebsitSalesGoodsVO vo : goodsList) {
|
|
|
+ BigDecimal afterPrice;
|
|
|
+ switch (vo.getPartType()) {
|
|
|
+ case "空调":
|
|
|
+ afterPrice = vo.getPrice().multiply(config.getPriceRate1());
|
|
|
+ break;
|
|
|
+ case "冰箱":
|
|
|
+ afterPrice = vo.getPrice().multiply(config.getPriceRate2());
|
|
|
+ break;
|
|
|
+ case "生活电器":
|
|
|
+ afterPrice = vo.getPrice().multiply(config.getPriceRate3());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new RemoteServiceException("未找到对应配件类型倍率");
|
|
|
+ }
|
|
|
+ vo.setPrice(afterPrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -281,13 +308,8 @@ public class WebsitSalesLogic {
|
|
|
shoppingCart.setGoodsStockUnit(goods.getGoodsStockUnit());
|
|
|
shoppingCart.setGoodsSpecification(goods.getGoodsSpecification());
|
|
|
|
|
|
- BigDecimal convertQty = shoppingCart.getSalesQty().divide(goods.getGoodsSalesConvertQty(), goods.getConvertBitScale(), BigDecimal.ROUND_UP);
|
|
|
-
|
|
|
- if (shoppingCart.getGoodsType().equals(WebsitGoodsTypeEnum.P.toString()) || goods.getGoodsSalesConvertQty().compareTo(BigDecimal.ONE) == 0) {
|
|
|
- convertQty = shoppingCart.getSalesQty();
|
|
|
- }
|
|
|
+ this.goodsConditionHandle(shoppingCart, goods);
|
|
|
|
|
|
- shoppingCart.setConvertQty(convertQty);
|
|
|
shoppingCart.setCreateTime(DateUtil.date());
|
|
|
|
|
|
shoppingCarts.add(shoppingCart);
|
|
@@ -297,6 +319,57 @@ public class WebsitSalesLogic {
|
|
|
return this.queryShoppingCart(wechat.getUserId(), websitId, shoppingCartBean.getGoodsType());
|
|
|
}
|
|
|
|
|
|
+ private void goodsConditionHandle(WebsitShoppingCart shoppingCart, WebsitGoods goods) {
|
|
|
+ // 商品类型为配件时单价要先乘倍率
|
|
|
+ if (shoppingCart.getGoodsType().equals(WebsitGoodsTypeEnum.P.toString())) {
|
|
|
+ final MaterialConfig config = materialConfigService.lambdaQuery()
|
|
|
+ .eq(MaterialConfig::getCompanyWechatId, goods.getCompanyWechatId())
|
|
|
+ .one();
|
|
|
+ BigDecimal afterPrice;
|
|
|
+ switch (goods.getPartType()) {
|
|
|
+ case "空调":
|
|
|
+ afterPrice = goods.getMarketPrice().multiply(config.getPriceRate1());
|
|
|
+ break;
|
|
|
+ case "冰箱":
|
|
|
+ afterPrice = goods.getMarketPrice().multiply(config.getPriceRate2());
|
|
|
+ break;
|
|
|
+ case "生活电器":
|
|
|
+ afterPrice = goods.getMarketPrice().multiply(config.getPriceRate3());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new RemoteServiceException("未找到对应配件类型倍率");
|
|
|
+ }
|
|
|
+ shoppingCart.setPrice(afterPrice);
|
|
|
+ shoppingCart.setOrigPartsPrice(goods.getMarketPrice());
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal convertQty = shoppingCart.getSalesQty().divide(goods.getGoodsSalesConvertQty(), 1, BigDecimal.ROUND_UP);
|
|
|
+ BigDecimal totalSaleValue = shoppingCart.getSalesQty().multiply(shoppingCart.getPrice());
|
|
|
+ BigDecimal convertPrice = totalSaleValue.divide(convertQty, 2, BigDecimal.ROUND_DOWN);
|
|
|
+
|
|
|
+ if (shoppingCart.getGoodsType().equals(WebsitGoodsTypeEnum.P.toString()) || goods.getGoodsSalesConvertQty().compareTo(BigDecimal.ONE) == 0) {
|
|
|
+ convertQty = shoppingCart.getSalesQty();
|
|
|
+ convertPrice = shoppingCart.getPrice();
|
|
|
+ shoppingCart.setSaleAmount(totalSaleValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 类型为辅材时注入师傅辅材id
|
|
|
+ if (shoppingCart.getGoodsType().equals(WebsitGoodsTypeEnum.M.toString())
|
|
|
+ && (StringUtils.isBlank(shoppingCart.getManageWorkerStock()) || shoppingCart.getManageWorkerStock().equals(IsYesNoEnum.YES.getKey()))) {
|
|
|
+ final WorkerGoodsRela goodsRela = workerGoodsRelaService.lambdaQuery()
|
|
|
+ .eq(WorkerGoodsRela::getCompanyWechatId, goods.getCompanyWechatId())
|
|
|
+ .eq(WorkerGoodsRela::getWebsitGoodsId, goods.getGoodsId())
|
|
|
+ .one();
|
|
|
+ if (Objects.nonNull(goodsRela)) {
|
|
|
+ shoppingCart.setWorkerGoodsId(goodsRela.getWorkerGoodsId())
|
|
|
+ .setWorkerGoodsName(goodsRela.getWorkerGoodsName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ shoppingCart.setConvertQty(convertQty)
|
|
|
+ .setConvertPrice(convertPrice);
|
|
|
+ }
|
|
|
+
|
|
|
public void clearShoppingCart(String workerId, String websitId, String goodsType) {
|
|
|
websitShoppingCartService.lambdaUpdate()
|
|
|
.eq(WebsitShoppingCart::getWorkerId, workerId)
|
|
@@ -378,6 +451,11 @@ public class WebsitSalesLogic {
|
|
|
detail.setConvertBitScale(bean.getConvertBitScale());
|
|
|
detail.setManageWorkerStock(bean.getManageWorkerStock());
|
|
|
detail.setConvertQty(bean.getConvertQty());
|
|
|
+ detail.setConvertPrice(bean.getConvertPrice());
|
|
|
+ detail.setWorkerGoodsId(bean.getWorkerGoodsId());
|
|
|
+ detail.setWorkerGoodsName(bean.getWorkerGoodsName());
|
|
|
+ detail.setOrigPartsPrice(bean.getOrigPartsPrice());
|
|
|
+
|
|
|
orderDetails.add(detail);
|
|
|
|
|
|
sales.setCompanyWechatId(bean.getCompanyWechatId());
|