|
@@ -6,6 +6,7 @@ import com.caimei.mapper.order.BpUserInfoMapper;
|
|
import com.caimei.mapper.order.CmMallShopOrderMapper;
|
|
import com.caimei.mapper.order.CmMallShopOrderMapper;
|
|
import com.caimei.mapper.order.OrderMapper;
|
|
import com.caimei.mapper.order.OrderMapper;
|
|
import com.caimei.mapper.order.OrderProductMapper;
|
|
import com.caimei.mapper.order.OrderProductMapper;
|
|
|
|
+import com.caimei.mapper.products.DetailsMapper;
|
|
import com.caimei.mapper.products.HomePageMapper;
|
|
import com.caimei.mapper.products.HomePageMapper;
|
|
import com.caimei.mapper.products.OrganizeProductsMapper;
|
|
import com.caimei.mapper.products.OrganizeProductsMapper;
|
|
import com.caimei.mapper.products.ShoppingMapper;
|
|
import com.caimei.mapper.products.ShoppingMapper;
|
|
@@ -21,6 +22,7 @@ import com.caimei.utils.AppUtils;
|
|
import com.caimei.utils.MathUtil;
|
|
import com.caimei.utils.MathUtil;
|
|
import com.caimei.utils.NoUtils;
|
|
import com.caimei.utils.NoUtils;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -61,6 +63,8 @@ public class OrderServiceImpl implements OrderService {
|
|
private CmMallAddressMapper cmMallAddressMapper;
|
|
private CmMallAddressMapper cmMallAddressMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private ShoppingMapper shoppingMapper;
|
|
private ShoppingMapper shoppingMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private DetailsMapper detailsMapper;
|
|
|
|
|
|
@Value("${miniprogram.domain}")
|
|
@Value("${miniprogram.domain}")
|
|
private String domain;
|
|
private String domain;
|
|
@@ -285,6 +289,78 @@ public class OrderServiceImpl implements OrderService {
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取阶梯价格
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Double getLadderPrice(Integer number, List<CmMallProductLadderPrice> productLadderPrice) {
|
|
|
|
+ Double ladderPrice = 0d;
|
|
|
|
+
|
|
|
|
+ //已根据购买期数排序,期数越大价格越低
|
|
|
|
+ Integer buyNum1 = 0;//第一阶梯(价格最高)
|
|
|
|
+ Integer buyNum2 = 0;//第二阶梯
|
|
|
|
+ Integer buyNum3 = 0;//第三阶梯(价格最低)
|
|
|
|
+ if (productLadderPrice.size() == 3) {
|
|
|
|
+ if (null != productLadderPrice.get(0)) buyNum1 = productLadderPrice.get(0).getBuyNum();
|
|
|
|
+ if (null != productLadderPrice.get(1)) buyNum2 = productLadderPrice.get(1).getBuyNum();
|
|
|
|
+ if (null != productLadderPrice.get(2)) buyNum3 = productLadderPrice.get(2).getBuyNum();
|
|
|
|
+ } else if (productLadderPrice.size() == 2) {
|
|
|
|
+ if (null != productLadderPrice.get(0)) buyNum1 = productLadderPrice.get(0).getBuyNum();
|
|
|
|
+ if (null != productLadderPrice.get(1)) buyNum2 = productLadderPrice.get(1).getBuyNum();
|
|
|
|
+ } else if (productLadderPrice.size() == 1) {
|
|
|
|
+ if (null != productLadderPrice.get(0)) buyNum1 = productLadderPrice.get(0).getBuyNum();
|
|
|
|
+ }
|
|
|
|
+ if (null == buyNum1) buyNum1 = 0;
|
|
|
|
+ if (null == buyNum2) buyNum2 = 0;
|
|
|
|
+ if (null == buyNum3) buyNum3 = 0;
|
|
|
|
+
|
|
|
|
+ //判断购买数量在什么阶段内
|
|
|
|
+ if (buyNum3 != 0 && number >= buyNum3) {//3阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(2).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) ladderPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;//购买的阶梯价格
|
|
|
|
+ }
|
|
|
|
+ if ((buyNum3 != 0 && buyNum2 != 0 && (number >= buyNum2 && number < buyNum3)) || (buyNum3 == 0 && buyNum2 != 0 && (number >= buyNum2))) {//2-3阶梯(只存在三个阶梯数据和值存在两个阶梯数据)
|
|
|
|
+ if (productLadderPrice.size() == 1) {//只有一阶梯(一般不存在因为2阶梯已经不为0了)
|
|
|
|
+ Double buyPrice = productLadderPrice.get(0).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;
|
|
|
|
+ } else if (productLadderPrice.size() == 2) {//共有二阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(1).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;
|
|
|
|
+ } else if (productLadderPrice.size() == 3) {//共有三阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(1).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;//购买的阶梯价格
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ((buyNum2 != 0 && buyNum1 != 0 && (number >= buyNum1 && number < buyNum2)) || (buyNum2 == 0 && buyNum1 != 0 && (number >= buyNum1))) {//1-2阶梯(存在两个及以上阶梯数和只存在一个阶梯数据:两种情况)
|
|
|
|
+ if (productLadderPrice.size() == 1) {//只有一阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(0).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;
|
|
|
|
+ } else if (productLadderPrice.size() == 2) {//共有二阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(0).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;
|
|
|
|
+ } else if (productLadderPrice.size() == 3) {//共有三阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(0).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ((buyNum1 != 0 && (number <= buyNum1))) {//1阶梯
|
|
|
|
+ Double buyPrice = productLadderPrice.get(0).getBuyPrice();
|
|
|
|
+ if (null == buyPrice) buyPrice = 0d;
|
|
|
|
+ ladderPrice = buyPrice;
|
|
|
|
+ }
|
|
|
|
+ return ladderPrice;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public CmWxJsonModel saveOrderInfo(CmWxJsonModel cmWxJsonModel, Integer userId, Integer organizeID, String cartType, Integer addressID, Object orderInfo, String balanceDeductionFlag, Double orderShouldPayFee, Integer cmOperationID) {
|
|
public CmWxJsonModel saveOrderInfo(CmWxJsonModel cmWxJsonModel, Integer userId, Integer organizeID, String cartType, Integer addressID, Object orderInfo, String balanceDeductionFlag, Double orderShouldPayFee, Integer cmOperationID) {
|
|
@@ -336,8 +412,21 @@ public class OrderServiceImpl implements OrderService {
|
|
if (null == cmMallOrganizeProducts) return cmWxJsonModel.error("-1", "订单商品数据异常");
|
|
if (null == cmMallOrganizeProducts) return cmWxJsonModel.error("-1", "订单商品数据异常");
|
|
if (null == productNum || productNum == 0) return cmWxJsonModel.error("-1", "商品购买数量异常");
|
|
if (null == productNum || productNum == 0) return cmWxJsonModel.error("-1", "商品购买数量异常");
|
|
CmMallProduct cmCmMallProduct = organizeProductsMapper.selectCmProductById(cmMallOrganizeProducts.getProductID());
|
|
CmMallProduct cmCmMallProduct = organizeProductsMapper.selectCmProductById(cmMallOrganizeProducts.getProductID());
|
|
- Double retailPrice = cmMallOrganizeProducts.getRetailPrice();//售价
|
|
|
|
|
|
+ Double retailPrice = 0d;//售价
|
|
// Integer classifyID = cmMallOrganizeProducts.getClassifyID();
|
|
// Integer classifyID = cmMallOrganizeProducts.getClassifyID();
|
|
|
|
+
|
|
|
|
+ if(StringUtils.equals("1",cmMallOrganizeProducts.getLadderPriceFlag())){
|
|
|
|
+ List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(productId);
|
|
|
|
+ //判断阶梯价格的购买数量校验
|
|
|
|
+ Integer minBuyNumber = getMinBuyNumber(ladderPriceList);
|
|
|
|
+ if(productNum < minBuyNumber){
|
|
|
|
+ return cmWxJsonModel.error("-1", "商品购买量低于最小起订量");
|
|
|
|
+ }
|
|
|
|
+ //更加商品购买数量获取商品对应阶梯价格
|
|
|
|
+ retailPrice = getLadderPrice(productNum, ladderPriceList);
|
|
|
|
+ }else{
|
|
|
|
+ retailPrice = cmMallOrganizeProducts.getRetailPrice();
|
|
|
|
+ }
|
|
double productFee = retailPrice * productNum;//单个商品的金额
|
|
double productFee = retailPrice * productNum;//单个商品的金额
|
|
//统计商品总金额
|
|
//统计商品总金额
|
|
productTotalFee += productFee;
|
|
productTotalFee += productFee;
|
|
@@ -372,11 +461,11 @@ public class OrderServiceImpl implements OrderService {
|
|
cmMallOrderProduct.setSingleShopFee(cmMallOrganizeProducts.getCostPrice());
|
|
cmMallOrderProduct.setSingleShopFee(cmMallOrganizeProducts.getCostPrice());
|
|
cmMallOrderProduct.setOtherFee(0d);
|
|
cmMallOrderProduct.setOtherFee(0d);
|
|
cmMallOrderProduct.setSingleOtherFee(0d);
|
|
cmMallOrderProduct.setSingleOtherFee(0d);
|
|
- cmMallOrderProduct.setCmFee((cmMallOrganizeProducts.getRetailPrice() * productNum) - (cmMallOrganizeProducts.getCostPrice() * productNum));//应付采美=应付金额(应收金额)-应付供应商-应付第三方0-税费0)
|
|
|
|
- cmMallOrderProduct.setSingleCmFee(cmMallOrganizeProducts.getRetailPrice() - cmMallOrganizeProducts.getCostPrice());
|
|
|
|
- cmMallOrderProduct.setTotalAmount(cmMallOrganizeProducts.getRetailPrice() * productNum);
|
|
|
|
- cmMallOrderProduct.setTotalFee(cmMallOrganizeProducts.getRetailPrice() * productNum);
|
|
|
|
- cmMallOrderProduct.setShouldPayFee(cmMallOrganizeProducts.getRetailPrice() * productNum);
|
|
|
|
|
|
+ cmMallOrderProduct.setCmFee((retailPrice * productNum) - (cmMallOrganizeProducts.getCostPrice() * productNum));//应付采美=应付金额(应收金额)-应付供应商-应付第三方0-税费0)
|
|
|
|
+ cmMallOrderProduct.setSingleCmFee(retailPrice - cmMallOrganizeProducts.getCostPrice());
|
|
|
|
+ cmMallOrderProduct.setTotalAmount(retailPrice * productNum);
|
|
|
|
+ cmMallOrderProduct.setTotalFee(retailPrice * productNum);
|
|
|
|
+ cmMallOrderProduct.setShouldPayFee(retailPrice * productNum);
|
|
cmMallOrderProduct.setTotalBeans(0d);
|
|
cmMallOrderProduct.setTotalBeans(0d);
|
|
cmMallOrderProduct.setUseBalanceAmount(0d);
|
|
cmMallOrderProduct.setUseBalanceAmount(0d);
|
|
cmMallOrderProduct.setDiscountFee(0D);//经理折扣 优惠金额
|
|
cmMallOrderProduct.setDiscountFee(0D);//经理折扣 优惠金额
|
|
@@ -384,7 +473,7 @@ public class OrderServiceImpl implements OrderService {
|
|
cmMallOrderProduct.setUseBalanceAmount(0d);
|
|
cmMallOrderProduct.setUseBalanceAmount(0d);
|
|
cmMallOrderProduct.setConfirmProductFlag("0");//订单商品供应商确认标志 0否 1是
|
|
cmMallOrderProduct.setConfirmProductFlag("0");//订单商品供应商确认标志 0否 1是
|
|
cmMallOrderProduct.setDiscount(100d);
|
|
cmMallOrderProduct.setDiscount(100d);
|
|
- cmMallOrderProduct.setDiscountPrice(cmMallOrganizeProducts.getRetailPrice());
|
|
|
|
|
|
+ cmMallOrderProduct.setDiscountPrice(retailPrice);
|
|
cmMallOrderProduct.setShopName(cmMallOrganizeProducts.getShopName());
|
|
cmMallOrderProduct.setShopName(cmMallOrganizeProducts.getShopName());
|
|
cmMallOrderProduct.setName(cmCmMallProduct.getName());
|
|
cmMallOrderProduct.setName(cmCmMallProduct.getName());
|
|
cmMallOrderProduct.setPayStatus("0");
|
|
cmMallOrderProduct.setPayStatus("0");
|
|
@@ -708,6 +797,19 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取阶梯价格最小购买数量
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Integer getMinBuyNumber(List<CmMallProductLadderPrice> ladderPriceList) {
|
|
|
|
+ Integer minBuyNumber = 1;
|
|
|
|
+ //阶梯价格信息
|
|
|
|
+ if (!CollectionUtils.isEmpty(ladderPriceList)) {
|
|
|
|
+ CmMallProductLadderPrice productLadderPrice0 = ladderPriceList.get(0);//第一阶梯
|
|
|
|
+ if (null != productLadderPrice0) minBuyNumber = productLadderPrice0.getBuyNum();
|
|
|
|
+ }
|
|
|
|
+ return minBuyNumber;
|
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<CmMallLogisticsBatch> logistics(Integer orderID) throws Exception {
|
|
public List<CmMallLogisticsBatch> logistics(Integer orderID) throws Exception {
|