|
@@ -26,6 +26,8 @@ import com.pj.tb_fee_item_record.TbFeeItemRecordService;
|
|
import com.pj.tb_goods_demand.TbGoodsDemand;
|
|
import com.pj.tb_goods_demand.TbGoodsDemand;
|
|
import com.pj.tb_goods_demand.TbGoodsDemandService;
|
|
import com.pj.tb_goods_demand.TbGoodsDemandService;
|
|
import com.pj.tb_goods_demand.vo.GoodsDemandVo;
|
|
import com.pj.tb_goods_demand.vo.GoodsDemandVo;
|
|
|
|
+import com.pj.tb_item_rules.TbItemRules;
|
|
|
|
+import com.pj.tb_item_rules.TbItemRulesService;
|
|
import com.pj.tb_orders_cart.TbOrdersCart;
|
|
import com.pj.tb_orders_cart.TbOrdersCart;
|
|
import com.pj.tb_orders_cart.TbOrdersCartMapper;
|
|
import com.pj.tb_orders_cart.TbOrdersCartMapper;
|
|
import com.pj.tb_purchaser.TbPurchaser;
|
|
import com.pj.tb_purchaser.TbPurchaser;
|
|
@@ -37,6 +39,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -67,7 +70,9 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
TbOrdersCartMapper tbOrdersCartMapper;
|
|
TbOrdersCartMapper tbOrdersCartMapper;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- TbFeeItemService tbFeeItemService;
|
|
|
|
|
|
+ private TbFeeItemService tbFeeItemService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TbItemRulesService tbItemRulesService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
TbFeeItemRecordService tbFeeItemRecordService;
|
|
TbFeeItemRecordService tbFeeItemRecordService;
|
|
@@ -336,6 +341,33 @@ public class TbOrdersService extends ServiceImpl<TbOrdersMapper, TbOrders> imple
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Double countPrice(SoMap so) {
|
|
|
|
+ OrderDto orderDto = levelOneServerInterface.getOrderDtoById(so.getLong("id"));
|
|
|
|
+ if (null == orderDto) throw new RuntimeException("当前一级市场订单为空,请联系管理员!");
|
|
|
|
+
|
|
|
|
+ List<TbItemRules> ruleList = new ArrayList<>();
|
|
|
|
+ List<TbFeeItem> feeItemList = tbFeeItemService.getFeeItems();
|
|
|
|
+ feeItemList.forEach(feeItem -> {
|
|
|
|
+ ruleList.addAll(tbItemRulesService.getList(new SoMap().set("itemId", feeItem.getId())));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ GoodsDto goods = levelOneServerInterface.getByGoodsId(orderDto.getGoodsId());
|
|
|
|
+ List<TbItemRules> newRuleList = ruleList.stream().filter(rule -> rule.getGoodsCodes().contains(goods.getCode())).collect(Collectors.toList());
|
|
|
|
+ AtomicReference<Float> sum= new AtomicReference<>(0.00F);
|
|
|
|
+ newRuleList.forEach(ruleItem -> {
|
|
|
|
+ //类型(1=按交易额收取,2=按次收取,3=按吨)
|
|
|
|
+ if("1".equals(ruleItem.getFeeType())) {
|
|
|
|
+ sum.updateAndGet(v -> new Float((float) (v + (orderDto.getTotalPrice() * ruleItem.getPercent()/100) )));
|
|
|
|
+ } else if("2".equals(ruleItem.getFeeType())) {
|
|
|
|
+ sum.updateAndGet(v -> new Float((float) (v + ruleItem.getFeeMoney().doubleValue() )));
|
|
|
|
+ } else if("3".equals(ruleItem.getFeeType())) {
|
|
|
|
+ sum.updateAndGet(v -> new Float((float) (v + (orderDto.getTotalPrice() * ruleItem.getPercent() /100) )));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ Double sumPrice = sum.get() + orderDto.getTotalPrice() + 50;//50为利润,暂时写死
|
|
|
|
+ return sumPrice;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据一级市场id查询二级市场订单
|
|
* 根据一级市场id查询二级市场订单
|
|
*/
|
|
*/
|