|
@@ -11,12 +11,12 @@ 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;
|
|
import com.caimei.mapper.user.CmMallAddressMapper;
|
|
import com.caimei.mapper.user.CmMallAddressMapper;
|
|
|
|
+import com.caimei.mapper.user.CmMallUserMapper;
|
|
import com.caimei.mapper.user.LoginMapper;
|
|
import com.caimei.mapper.user.LoginMapper;
|
|
import com.caimei.mapper.user.PersonalMapper;
|
|
import com.caimei.mapper.user.PersonalMapper;
|
|
-import com.caimei.mapper.user.CmMallUserMapper;
|
|
|
|
-import com.caimei.entity.CmMallOrganizeProducts;
|
|
|
|
-import com.caimei.entity.CmMallProduct;
|
|
|
|
-import com.caimei.entity.CmMallShop;
|
|
|
|
|
|
+import com.caimei.module.base.entity.vo.DiscernReceiptVo;
|
|
|
|
+import com.caimei.module.base.entity.vo.OrderRelationVo;
|
|
|
|
+import com.caimei.module.pay.dao.PayDao;
|
|
import com.caimei.service.order.OrderService;
|
|
import com.caimei.service.order.OrderService;
|
|
import com.caimei.utils.AppUtils;
|
|
import com.caimei.utils.AppUtils;
|
|
import com.caimei.utils.MathUtil;
|
|
import com.caimei.utils.MathUtil;
|
|
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -64,6 +65,8 @@ public class OrderServiceImpl implements OrderService {
|
|
private ShoppingMapper shoppingMapper;
|
|
private ShoppingMapper shoppingMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private DetailsMapper detailsMapper;
|
|
private DetailsMapper detailsMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private PayDao payDao;
|
|
|
|
|
|
@Value("${miniprogram.domain}")
|
|
@Value("${miniprogram.domain}")
|
|
private String domain;
|
|
private String domain;
|
|
@@ -93,13 +96,13 @@ public class OrderServiceImpl implements OrderService {
|
|
productsList = orderMapper.findAllCommodity(params);
|
|
productsList = orderMapper.findAllCommodity(params);
|
|
for (CmMallOrganizeProducts products : productsList) {
|
|
for (CmMallOrganizeProducts products : productsList) {
|
|
products.setMainImage(AppUtils.getImageURL("product", products.getMainImage(), 0, domain));
|
|
products.setMainImage(AppUtils.getImageURL("product", products.getMainImage(), 0, domain));
|
|
- if(StringUtils.equals("1",products.getLadderPriceFlag())){//阶梯价格
|
|
|
|
|
|
+ if (StringUtils.equals("1", products.getLadderPriceFlag())) {//阶梯价格
|
|
List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(products.getId());
|
|
List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(products.getId());
|
|
//更加商品购买数量获取商品对应阶梯价格
|
|
//更加商品购买数量获取商品对应阶梯价格
|
|
retailPrice = getLadderPrice(products.getProductCount(), ladderPriceList);
|
|
retailPrice = getLadderPrice(products.getProductCount(), ladderPriceList);
|
|
totalPrice += retailPrice * products.getProductCount();
|
|
totalPrice += retailPrice * products.getProductCount();
|
|
products.setRetailPrice(retailPrice);//重置阶梯价格售价
|
|
products.setRetailPrice(retailPrice);//重置阶梯价格售价
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
totalPrice += products.getRetailPrice() * products.getProductCount();
|
|
totalPrice += products.getRetailPrice() * products.getProductCount();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -108,13 +111,13 @@ public class OrderServiceImpl implements OrderService {
|
|
CmMallOrganizeProducts products = orderMapper.findCommodity(productIDs, cmMallShop.getShopID());
|
|
CmMallOrganizeProducts products = orderMapper.findCommodity(productIDs, cmMallShop.getShopID());
|
|
products.setMainImage(AppUtils.getImageURL("product", products.getMainImage(), 0, domain));
|
|
products.setMainImage(AppUtils.getImageURL("product", products.getMainImage(), 0, domain));
|
|
products.setProductCount(count);
|
|
products.setProductCount(count);
|
|
- if(StringUtils.equals("1",products.getLadderPriceFlag())){//阶梯价格
|
|
|
|
|
|
+ if (StringUtils.equals("1", products.getLadderPriceFlag())) {//阶梯价格
|
|
List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(products.getId());
|
|
List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(products.getId());
|
|
//更加商品购买数量获取商品对应阶梯价格
|
|
//更加商品购买数量获取商品对应阶梯价格
|
|
retailPrice = getLadderPrice(products.getProductCount(), ladderPriceList);
|
|
retailPrice = getLadderPrice(products.getProductCount(), ladderPriceList);
|
|
totalPrice = retailPrice * products.getProductCount();
|
|
totalPrice = retailPrice * products.getProductCount();
|
|
products.setRetailPrice(retailPrice);//重置阶梯价格售价
|
|
products.setRetailPrice(retailPrice);//重置阶梯价格售价
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
totalPrice = products.getRetailPrice() * products.getProductCount();
|
|
totalPrice = products.getRetailPrice() * products.getProductCount();
|
|
}
|
|
}
|
|
productsList.add(products);
|
|
productsList.add(products);
|
|
@@ -290,6 +293,15 @@ public class OrderServiceImpl implements OrderService {
|
|
//退款总金额
|
|
//退款总金额
|
|
order.setReturnedPurchaseFee(BigDecimal.valueOf(returnedPurchaseFee));
|
|
order.setReturnedPurchaseFee(BigDecimal.valueOf(returnedPurchaseFee));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //判断是否可以走线上支付
|
|
|
|
+ DiscernReceiptVo discernReceipt = orderMapper.findOfflinePayment(orderID);
|
|
|
|
+ if (null == discernReceipt) {
|
|
|
|
+ order.setOnlinePayFlag("0");
|
|
|
|
+ } else {
|
|
|
|
+ order.setOnlinePayFlag("1");
|
|
|
|
+ }
|
|
|
|
+
|
|
//客服热线号码
|
|
//客服热线号码
|
|
String cellPhone = loginMapper.cellPhone(order.getOrganizeID());
|
|
String cellPhone = loginMapper.cellPhone(order.getOrganizeID());
|
|
//分享码
|
|
//分享码
|
|
@@ -431,16 +443,16 @@ public class OrderServiceImpl implements OrderService {
|
|
Double retailPrice = 0d;//售价
|
|
Double retailPrice = 0d;//售价
|
|
// Integer classifyID = cmMallOrganizeProducts.getClassifyID();
|
|
// Integer classifyID = cmMallOrganizeProducts.getClassifyID();
|
|
|
|
|
|
- if(StringUtils.equals("1",cmMallOrganizeProducts.getLadderPriceFlag())){
|
|
|
|
|
|
+ if (StringUtils.equals("1", cmMallOrganizeProducts.getLadderPriceFlag())) {
|
|
List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(productId);
|
|
List<CmMallProductLadderPrice> ladderPriceList = detailsMapper.findLadderPrice(productId);
|
|
//判断阶梯价格的购买数量校验
|
|
//判断阶梯价格的购买数量校验
|
|
Integer minBuyNumber = getMinBuyNumber(ladderPriceList);
|
|
Integer minBuyNumber = getMinBuyNumber(ladderPriceList);
|
|
- if(productNum < minBuyNumber){
|
|
|
|
|
|
+ if (productNum < minBuyNumber) {
|
|
return cmWxJsonModel.error("-1", "商品购买量低于最小起订量");
|
|
return cmWxJsonModel.error("-1", "商品购买量低于最小起订量");
|
|
}
|
|
}
|
|
//更加商品购买数量获取商品对应阶梯价格
|
|
//更加商品购买数量获取商品对应阶梯价格
|
|
retailPrice = getLadderPrice(productNum, ladderPriceList);
|
|
retailPrice = getLadderPrice(productNum, ladderPriceList);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
retailPrice = cmMallOrganizeProducts.getRetailPrice();
|
|
retailPrice = cmMallOrganizeProducts.getRetailPrice();
|
|
}
|
|
}
|
|
double productFee = retailPrice * productNum;//单个商品的金额
|
|
double productFee = retailPrice * productNum;//单个商品的金额
|
|
@@ -644,6 +656,29 @@ public class OrderServiceImpl implements OrderService {
|
|
cmMallUserBalanceRecord.setOrderId(cmMallOrder.getOrderID().intValue());
|
|
cmMallUserBalanceRecord.setOrderId(cmMallOrder.getOrderID().intValue());
|
|
cmMallUserBalanceRecord.setDelFlag("0");
|
|
cmMallUserBalanceRecord.setDelFlag("0");
|
|
cmMallUserMapper.insertUserBalanceRecord(cmMallUserBalanceRecord);
|
|
cmMallUserMapper.insertUserBalanceRecord(cmMallUserBalanceRecord);
|
|
|
|
+
|
|
|
|
+ //添加余额支付记录
|
|
|
|
+ DiscernReceiptVo discernReceipt = new DiscernReceiptVo();
|
|
|
|
+ discernReceipt.setPayWay("3");
|
|
|
|
+ discernReceipt.setPayType("16");
|
|
|
|
+ discernReceipt.setReceiptType("1");
|
|
|
|
+ discernReceipt.setReceiptStatus("3");
|
|
|
|
+ discernReceipt.setReceiptAmount(BigDecimal.valueOf(balancePayFee));
|
|
|
|
+ discernReceipt.setConfirmType("4");
|
|
|
|
+ discernReceipt.setReceiptDate(dateStr);
|
|
|
|
+ discernReceipt.setConfirmDate(dateStr);
|
|
|
|
+ discernReceipt.setReviewDate(dateStr);
|
|
|
|
+ discernReceipt.setUpdateDate(dateStr);
|
|
|
|
+ discernReceipt.setDelFlag("0");
|
|
|
|
+ payDao.insertDiscernReceipt(discernReceipt);
|
|
|
|
+ OrderRelationVo relation = new OrderRelationVo();
|
|
|
|
+ relation.setReceiptID(discernReceipt.getId().intValue());
|
|
|
|
+ relation.setOrderID(cmMallOrder.getOrderID().intValue());
|
|
|
|
+ relation.setAssociateAmount(BigDecimal.valueOf(balancePayFee));
|
|
|
|
+ relation.setRelationType("2");
|
|
|
|
+ relation.setDelFlag("0");
|
|
|
|
+ payDao.insertOrderRelation(relation);
|
|
|
|
+ logger.info(">>>>>>>>>>>>>>>>>>>>>>>保存余额到收款记录," + balancePayFee);
|
|
}
|
|
}
|
|
|
|
|
|
/**保存订单商品*/
|
|
/**保存订单商品*/
|
|
@@ -815,6 +850,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取阶梯价格最小购买数量
|
|
* 获取阶梯价格最小购买数量
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private Integer getMinBuyNumber(List<CmMallProductLadderPrice> ladderPriceList) {
|
|
private Integer getMinBuyNumber(List<CmMallProductLadderPrice> ladderPriceList) {
|
|
@@ -881,6 +917,13 @@ public class OrderServiceImpl implements OrderService {
|
|
shopOrder.setShopLogo(AppUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
|
|
shopOrder.setShopLogo(AppUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
|
|
}
|
|
}
|
|
order.setShopOrderList(shopOrderList);
|
|
order.setShopOrderList(shopOrderList);
|
|
|
|
+ //判断是否可以走线上支付
|
|
|
|
+ DiscernReceiptVo discernReceipt = orderMapper.findOfflinePayment(order.getOrderID().intValue());
|
|
|
|
+ if (null == discernReceipt) {
|
|
|
|
+ order.setOnlinePayFlag("0");
|
|
|
|
+ } else {
|
|
|
|
+ order.setOnlinePayFlag("1");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return orderList;
|
|
return orderList;
|
|
}
|
|
}
|
|
@@ -960,7 +1003,9 @@ public class OrderServiceImpl implements OrderService {
|
|
@Override
|
|
@Override
|
|
public void cancelOrder(Integer orderID) throws Exception {
|
|
public void cancelOrder(Integer orderID) throws Exception {
|
|
CmMallOrder order = orderMapper.findOrder(orderID);
|
|
CmMallOrder order = orderMapper.findOrder(orderID);
|
|
- if (order == null) { throw new Exception("订单不存在"); }
|
|
|
|
|
|
+ if (order == null) {
|
|
|
|
+ throw new Exception("订单不存在");
|
|
|
|
+ }
|
|
if (!("11".equals(order.getStatus()))) {
|
|
if (!("11".equals(order.getStatus()))) {
|
|
throw new Exception("订单异常");
|
|
throw new Exception("订单异常");
|
|
}
|
|
}
|
|
@@ -971,7 +1016,9 @@ public class OrderServiceImpl implements OrderService {
|
|
@Override
|
|
@Override
|
|
public void affirmCargo(Integer orderID) throws Exception {
|
|
public void affirmCargo(Integer orderID) throws Exception {
|
|
CmMallOrder order = orderMapper.findOrder(orderID);
|
|
CmMallOrder order = orderMapper.findOrder(orderID);
|
|
- if (order == null) { throw new Exception("订单不存在"); }
|
|
|
|
|
|
+ if (order == null) {
|
|
|
|
+ throw new Exception("订单不存在");
|
|
|
|
+ }
|
|
if ("33".equals(order.getStatus()) && "3".equals(order.getPayStatus())) {
|
|
if ("33".equals(order.getStatus()) && "3".equals(order.getPayStatus())) {
|
|
//已付款供应商,订单完成
|
|
//已付款供应商,订单完成
|
|
order.setStatus("5");
|
|
order.setStatus("5");
|