|
@@ -4,15 +4,23 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import com.kmall.admin.dao.*;
|
|
import com.kmall.admin.dao.*;
|
|
|
|
+import com.kmall.admin.dao.mk.Mk2GoodsTopicPriceDao;
|
|
|
|
+import com.kmall.admin.dao.mk.Mk2MemberBirthdayDao;
|
|
import com.kmall.admin.dao.mk.store.MkStorePromOrderRealDao;
|
|
import com.kmall.admin.dao.mk.store.MkStorePromOrderRealDao;
|
|
|
|
+import com.kmall.admin.dao.mk.store.MkStorePromTypeDao;
|
|
|
|
+import com.kmall.admin.dao.mk.store.StoreTopicDao;
|
|
|
|
+import com.kmall.admin.dao.vip.Mall2MemberConsumptionRecordsDao;
|
|
|
|
+import com.kmall.admin.dao.vip.Mall2MemberPointsDao;
|
|
|
|
+import com.kmall.admin.dao.vip.Mall2PointsRulesDao;
|
|
import com.kmall.admin.dto.OrderExpressDto;
|
|
import com.kmall.admin.dto.OrderExpressDto;
|
|
import com.kmall.admin.dto.OrderRecognitionDto;
|
|
import com.kmall.admin.dto.OrderRecognitionDto;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.OrderProcessRecordEntity;
|
|
import com.kmall.admin.entity.OrderProcessRecordEntity;
|
|
-import com.kmall.admin.entity.mk.store.MkStoreCampMinusEntity;
|
|
|
|
-import com.kmall.admin.entity.mk.store.MkStoreCampMinusLevelEntity;
|
|
|
|
-import com.kmall.admin.entity.mk.store.MkStorePromOrderRealEntity;
|
|
|
|
-import com.kmall.admin.entity.mk.store.MkStoreTicketDiscountEntity;
|
|
|
|
|
|
+import com.kmall.admin.entity.mk.Mk2GoodsTopicPriceEntity;
|
|
|
|
+import com.kmall.admin.entity.mk.store.*;
|
|
|
|
+import com.kmall.admin.entity.vip.Mall2MemberConsumptionRecordsEntity;
|
|
|
|
+import com.kmall.admin.entity.vip.Mall2MemberPointsEntity;
|
|
|
|
+import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
import com.kmall.admin.service.*;
|
|
import com.kmall.admin.service.*;
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
@@ -118,8 +126,24 @@ public class OrderServiceImpl implements OrderService {
|
|
@Autowired
|
|
@Autowired
|
|
private MkStoreTicketDiscountService mkStoreTicketDiscountService;
|
|
private MkStoreTicketDiscountService mkStoreTicketDiscountService;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private CashierDao cashierDao; // 收银机查询
|
|
|
|
+ @Autowired
|
|
|
|
+ private CashierLoginRecordDao cashierLoginRecordDao; // 收银员登录记录
|
|
|
|
+ @Autowired
|
|
|
|
+ private StoreTopicDao storeTopicDao; // 查询是否有门店活动
|
|
|
|
+ @Autowired
|
|
|
|
+ private Mk2GoodsTopicPriceDao mk2GoodsTopicPriceDao; // 门店商品价格
|
|
|
|
+ @Autowired
|
|
|
|
+ private Mall2PointsRulesDao pointsRulesDao; // 积分规则
|
|
|
|
+ @Autowired
|
|
|
|
+ private Mall2MemberPointsDao memberPointsDao; // 用户积分
|
|
|
|
+ @Autowired
|
|
|
|
+ private Mall2MemberConsumptionRecordsDao memberConsumptionRecordsDao; // 会员消费记录
|
|
|
|
+ @Autowired
|
|
|
|
+ private MkStorePromTypeDao storePromTypeDao; // 优惠类型
|
|
|
|
+ @Autowired
|
|
|
|
+ private Mk2MemberBirthdayDao memberBirthdayDao; // 生日优惠
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public OrderEntity queryObject(Long id) {
|
|
public OrderEntity queryObject(Long id) {
|
|
@@ -1599,8 +1623,12 @@ public class OrderServiceImpl implements OrderService {
|
|
String parCode = (String) param.get("payCode");
|
|
String parCode = (String) param.get("payCode");
|
|
// 解析sessionId(WebSocket) String
|
|
// 解析sessionId(WebSocket) String
|
|
String sessionId = (String) param.get("sessionId");
|
|
String sessionId = (String) param.get("sessionId");
|
|
|
|
+ // machineCode
|
|
|
|
+ String machineCode = (String) param.get("machineCode");
|
|
|
|
|
|
Map resultObj = Maps.newHashMap();
|
|
Map resultObj = Maps.newHashMap();
|
|
|
|
+
|
|
|
|
+
|
|
try {
|
|
try {
|
|
if (user == null) {
|
|
if (user == null) {
|
|
resultObj.put("errno", 400);
|
|
resultObj.put("errno", 400);
|
|
@@ -1630,6 +1658,9 @@ public class OrderServiceImpl implements OrderService {
|
|
resultObj.put("errmsg", "订单提交失败:商品不存在");
|
|
resultObj.put("errmsg", "订单提交失败:商品不存在");
|
|
return resultObj;
|
|
return resultObj;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
Integer sellVolume = (Integer)goodsDto.get("sellVolume");
|
|
Integer sellVolume = (Integer)goodsDto.get("sellVolume");
|
|
|
|
|
|
goodsDto.put("goodsId",goodsEntity.getId());
|
|
goodsDto.put("goodsId",goodsEntity.getId());
|
|
@@ -1648,6 +1679,9 @@ public class OrderServiceImpl implements OrderService {
|
|
resultObj.put("errmsg", "库存不足,仅剩余" + productInfo.getStockNum());
|
|
resultObj.put("errmsg", "库存不足,仅剩余" + productInfo.getStockNum());
|
|
return resultObj;
|
|
return resultObj;
|
|
} else {
|
|
} else {
|
|
|
|
+
|
|
|
|
+ // TODO 判断销售价是否低于底线价
|
|
|
|
+
|
|
productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
|
|
productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
|
|
productInfo.setStoreId(Long.valueOf(storeId));
|
|
productInfo.setStoreId(Long.valueOf(storeId));
|
|
productInfo.addSellVolume();
|
|
productInfo.addSellVolume();
|
|
@@ -1658,6 +1692,7 @@ public class OrderServiceImpl implements OrderService {
|
|
goodsDao.update(goodsEntity);
|
|
goodsDao.update(goodsEntity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 借用这个字段来存储购买数
|
|
goodsEntity.setGoodsNumber(sellVolume);
|
|
goodsEntity.setGoodsNumber(sellVolume);
|
|
goodsEntities.add(goodsEntity);
|
|
goodsEntities.add(goodsEntity);
|
|
}
|
|
}
|
|
@@ -1678,88 +1713,59 @@ public class OrderServiceImpl implements OrderService {
|
|
userDao.save(userEntity);
|
|
userDao.save(userEntity);
|
|
}
|
|
}
|
|
|
|
|
|
- // TODO 生成订单之前,先查询是否有优惠券或者满减
|
|
|
|
- // TODO 20200610 要修改成全部商品
|
|
|
|
- // 优惠券的集合
|
|
|
|
- List<MkStoreTicketDiscountEntity> mkStoreTicketDiscountEntities = new ArrayList<>();
|
|
|
|
- // 满减的集合
|
|
|
|
- List<MkStoreCampMinusLevelEntity> mkStoreCampMinusEntities = new ArrayList<>();
|
|
|
|
- // 存商品跟金额的关系
|
|
|
|
- Map<Long,BigDecimal> moneyMap = new HashMap<>();
|
|
|
|
- // 商品总价
|
|
|
|
- BigDecimal totalPrice = new BigDecimal(0);
|
|
|
|
-
|
|
|
|
- for(GoodsEntity goodsEntity : goodsEntities){
|
|
|
|
- Long goodsId = goodsEntity.getId();
|
|
|
|
- // 计算该商品的价格
|
|
|
|
- BigDecimal goodsPrice = goodsEntity.getStoreRetailPrice().multiply(new BigDecimal(goodsEntity.getGoodsNumber())).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
- moneyMap.put(goodsId,goodsPrice);
|
|
|
|
- totalPrice = totalPrice.add(goodsPrice);
|
|
|
|
- // 查询该商品id是否有优惠券
|
|
|
|
- List<MkStoreTicketDiscountEntity> mkStoreTicketDiscountEntity = mkStoreTicketDiscountService.queryByGoodsId(goodsId);
|
|
|
|
- if(mkStoreTicketDiscountEntity != null) {
|
|
|
|
- mkStoreTicketDiscountEntities.addAll(mkStoreTicketDiscountEntity);
|
|
|
|
- }
|
|
|
|
- // 查询该商品id是否有满减
|
|
|
|
- List<MkStoreCampMinusLevelEntity> mkStoreCampMinusEntity = mkStoreCampMinusService.queryByGoodsId(goodsId);
|
|
|
|
- if(mkStoreCampMinusEntity != null) {
|
|
|
|
- mkStoreCampMinusEntities.addAll(mkStoreCampMinusEntity);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // 满减优惠的金额
|
|
|
|
- BigDecimal campDisCountAmount = new BigDecimal(0);
|
|
|
|
- if(mkStoreCampMinusEntities.size() > 0){
|
|
|
|
- // 上一次所需金额,用于取最大的优惠力度
|
|
|
|
- BigDecimal lastAmount = new BigDecimal(0);
|
|
|
|
- for (int i = 0 ; i < mkStoreCampMinusEntities.size() ; i++){
|
|
|
|
- MkStoreCampMinusLevelEntity mkStoreCampMinusLevelEntity = mkStoreCampMinusEntities.get(i);
|
|
|
|
- // TODO 20200610还有满多少件,跟满多少元打折的,逻辑复杂,下次开发
|
|
|
|
- BigDecimal discCond = mkStoreCampMinusLevelEntity.getYuanMinusCond();
|
|
|
|
- // 判断这次金额是否大于上次金额,如果不大于,直接continue
|
|
|
|
- if(discCond.compareTo(lastAmount) > 0){
|
|
|
|
- // 如果总金额大于所需金额,则可以使用该优惠券,记录该优惠券的角标,金额跟优惠的钱
|
|
|
|
- if(totalPrice.compareTo(discCond) > 0){
|
|
|
|
- // 记录上一次金额
|
|
|
|
- lastAmount = discCond;
|
|
|
|
- campDisCountAmount = mkStoreCampMinusLevelEntity.getYuanMinusPref();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 优惠金额
|
|
|
|
+ BigDecimal disCountAmount = new BigDecimal(0);
|
|
|
|
+ // 活动id
|
|
|
|
+ Integer topicId = 0;
|
|
|
|
+ // 查询活动类别id
|
|
|
|
+ MkStorePromTypeEntity mkStorePromEntity = storePromTypeDao.queryByName("周活动");
|
|
|
|
+ // 根据门店id和活动类别查询该门店是否有活动
|
|
|
|
+ StoreTopicEntity storeTopic = storeTopicDao.queryByStoreIdAndType(storeId,mkStorePromEntity.getPromTypeId());
|
|
|
|
+ // 判断是否启用了活动,如果启用了活动。则去查询活动价
|
|
|
|
+ if(storeTopic != null){
|
|
|
|
+ for(GoodsEntity goodsEntity :goodsEntities){
|
|
|
|
+ // 根据活动id跟商品id,查询该商品的价格
|
|
|
|
+ Mk2GoodsTopicPriceEntity goodsTopicPriceEntity =
|
|
|
|
+ mk2GoodsTopicPriceDao.queryByTopicIdAndGoodsId(storeTopic.getId(),goodsEntity.getSku());
|
|
|
|
+ if (goodsEntity.getStoreRetailPrice().compareTo(goodsTopicPriceEntity.getTopicPrice()) <= -1) {
|
|
|
|
+ LOGGER.error("销售价格小于活动价格");
|
|
|
|
+ throw new RuntimeException("商品"+goodsEntity.getName()+"的销售价格小于活动价格");
|
|
}
|
|
}
|
|
|
|
+ goodsEntity.setStoreRetailPrice(goodsTopicPriceEntity.getTopicPrice());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ disCountAmount = getDisCountAmout(goodsEntities);
|
|
}
|
|
}
|
|
|
|
|
|
- // 优惠券优惠的金额
|
|
|
|
- BigDecimal ticketDisCountAmount = new BigDecimal(0);
|
|
|
|
- if(mkStoreTicketDiscountEntities.size() > 0){
|
|
|
|
- // 上一次所需金额,用于取最大的优惠力度
|
|
|
|
- BigDecimal lastAmount = new BigDecimal(0);
|
|
|
|
- for (int i = 0 ; i < mkStoreTicketDiscountEntities.size() ; i++){
|
|
|
|
- MkStoreTicketDiscountEntity mkStoreTicketDiscountEntity = mkStoreTicketDiscountEntities.get(i);
|
|
|
|
- // 代金券所需金额
|
|
|
|
- // TODO 20200610还有折扣券的,逻辑较为复杂,下次在开发
|
|
|
|
- BigDecimal discCond = mkStoreTicketDiscountEntity.getVoucherCond();
|
|
|
|
-
|
|
|
|
- // 判断这次金额是否大于上次金额,如果不大于,直接continue
|
|
|
|
- if(discCond.compareTo(lastAmount) > 0){
|
|
|
|
- // 如果总金额大于所需金额,则可以使用该优惠券,记录该优惠券的角标,金额跟优惠的钱
|
|
|
|
- if(totalPrice.compareTo(discCond) > 0){
|
|
|
|
- // 记录上一次金额
|
|
|
|
- lastAmount = discCond;
|
|
|
|
- ticketDisCountAmount = mkStoreTicketDiscountEntity.getVoucherMoney();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // 判断该用户是否是生日
|
|
|
|
+ Boolean isBirth = false;
|
|
|
|
+ String birthday = "";
|
|
|
|
+ if(userEntity.getIdNo().length() == 15){
|
|
|
|
+ birthday = userEntity.getIdNo().substring(8,10) + "-" + userEntity.getIdNo().substring(10,12);
|
|
|
|
+ }else if(userEntity.getIdNo().length() == 18){
|
|
|
|
+ birthday = userEntity.getIdNo().substring(10,12) + "-" + userEntity.getIdNo().substring(12,14);
|
|
}
|
|
}
|
|
|
|
|
|
- // 判断两个优惠金额
|
|
|
|
- BigDecimal disCountAmount = ticketDisCountAmount.compareTo(campDisCountAmount) > 0 ? ticketDisCountAmount : campDisCountAmount;
|
|
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("MM-dd");
|
|
|
|
+ String today = format.format(new Date());
|
|
|
|
+ if(birthday.equalsIgnoreCase(today)){
|
|
|
|
+ isBirth = true;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成订单
|
|
// 生成订单
|
|
String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
|
|
String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
|
|
- OrderVo order = setOrderVo(goodsList, userEntity,storeId.longValue(), user.getMerchSn(),disCountAmount);
|
|
|
|
|
|
+ OrderVo order = setOrderVo(goodsEntities, userEntity,storeId.longValue(), user.getMerchSn(),disCountAmount);
|
|
order.setStore_id(storeId.longValue());
|
|
order.setStore_id(storeId.longValue());
|
|
|
|
+ if(storeTopic != null){
|
|
|
|
+ order.setActivity_id(storeTopic.getId().longValue());
|
|
|
|
+ }
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
|
|
|
|
//插入订单信息和订单商品
|
|
//插入订单信息和订单商品
|
|
@@ -1821,6 +1827,54 @@ public class OrderServiceImpl implements OrderService {
|
|
pickUpCodeEntity.setOrderSn(order.getOrder_sn());
|
|
pickUpCodeEntity.setOrderSn(order.getOrder_sn());
|
|
pickUpCodeService.save(pickUpCodeEntity);
|
|
pickUpCodeService.save(pickUpCodeEntity);
|
|
|
|
|
|
|
|
+ // 生成销售记录
|
|
|
|
+ SaleRecordEntity saleRecordEntity = new SaleRecordEntity();
|
|
|
|
+
|
|
|
|
+ // 根据收银机机器码,查询收银机
|
|
|
|
+ CashierEntity cashierEntity = cashierDao.queryByMachineCode(machineCode);
|
|
|
|
+ if(cashierEntity != null){
|
|
|
|
+ saleRecordEntity.setCashierSn(cashierEntity.getCashierSn());
|
|
|
|
+ saleRecordEntity.setOrderSn(order.getOrder_sn());
|
|
|
|
+ saleRecordEntity.setSallerId(userId+"");
|
|
|
|
+ saleRecordEntity.setSalesTime(new Date());
|
|
|
|
+ saleRecordEntity.setDiscountId(topicId + "");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查询积分规则 ,默认先按消费金额1:1积分
|
|
|
|
+ Mall2PointsRulesEntity pointsRules = null;
|
|
|
|
+
|
|
|
|
+ // 增加该会员的积分
|
|
|
|
+ Mall2MemberPointsEntity memberPointsEntity = memberPointsDao.queryByUserId(userEntity.getId());
|
|
|
|
+ if(memberPointsEntity == null){
|
|
|
|
+ memberPointsEntity = new Mall2MemberPointsEntity();
|
|
|
|
+ memberPointsEntity.setUserId(userEntity.getId()+"");
|
|
|
|
+ memberPointsEntity.setPoints(order.getActual_price().intValue());
|
|
|
|
+ memberPointsEntity.setCreaterSn(userId+"");
|
|
|
|
+ memberPointsEntity.setCreateTime(new Date());
|
|
|
|
+ memberPointsDao.save(memberPointsEntity);
|
|
|
|
+ }else{
|
|
|
|
+ memberPointsEntity.setPoints(order.getActual_price().add(new BigDecimal(memberPointsEntity.getPoints())).intValue());
|
|
|
|
+ memberPointsEntity.setModerSn(userId+"");
|
|
|
|
+ memberPointsEntity.setModTime(new Date());
|
|
|
|
+ memberPointsDao.update(memberPointsEntity);
|
|
|
|
+ }
|
|
|
|
+ // 增加该会员的消费记录
|
|
|
|
+ Mall2MemberConsumptionRecordsEntity consumptionRecords = new Mall2MemberConsumptionRecordsEntity();
|
|
|
|
+ consumptionRecords.setUserId(userEntity.getId()+"");
|
|
|
|
+ consumptionRecords.setOrderSn(order.getOrder_sn());
|
|
|
|
+ consumptionRecords.setConsumptionTime(new Date());
|
|
|
|
+ consumptionRecords.setShopSn(storeId+"");
|
|
|
|
+ // TODO 判断是否有使用生日优惠
|
|
|
|
+ if(isBirth){
|
|
|
|
+ consumptionRecords.setIsUseBirthdayOffer("0"); // 使用生日优惠
|
|
|
|
+ }else{
|
|
|
|
+ consumptionRecords.setIsUseBirthdayOffer("1"); // 没使用生日优惠
|
|
|
|
+ }
|
|
|
|
+ consumptionRecords.setCreaterSn(userId+"");
|
|
|
|
+ consumptionRecords.setCreateTime(new Date());
|
|
|
|
+ memberConsumptionRecordsDao.save(consumptionRecords);
|
|
|
|
+
|
|
resultObj.put("code",pickUpCodeEntity.getPickUpCodeSn()); // 系统中累加
|
|
resultObj.put("code",pickUpCodeEntity.getPickUpCodeSn()); // 系统中累加
|
|
|
|
|
|
resultObj.put("time",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
resultObj.put("time",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
@@ -1842,6 +1896,86 @@ public class OrderServiceImpl implements OrderService {
|
|
return resultObj;
|
|
return resultObj;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private BigDecimal getDisCountAmout(List<GoodsEntity> goodsEntities) {
|
|
|
|
+ BigDecimal disCountAmount;
|
|
|
|
+ // TODO 生成订单之前,先查询是否有优惠券或者满减
|
|
|
|
+ // TODO 20200610 要修改成全部商品
|
|
|
|
+ // 优惠券的集合
|
|
|
|
+ List<MkStoreTicketDiscountEntity> mkStoreTicketDiscountEntities = new ArrayList<>();
|
|
|
|
+ // 满减的集合
|
|
|
|
+ List<MkStoreCampMinusLevelEntity> mkStoreCampMinusEntities = new ArrayList<>();
|
|
|
|
+ // 存商品跟金额的关系
|
|
|
|
+ Map<Long,BigDecimal> moneyMap = new HashMap<>();
|
|
|
|
+ // 商品总价
|
|
|
|
+ BigDecimal totalPrice = new BigDecimal(0);
|
|
|
|
+
|
|
|
|
+ for(GoodsEntity goodsEntity : goodsEntities){
|
|
|
|
+ Long goodsId = goodsEntity.getId();
|
|
|
|
+ // 计算该商品的价格
|
|
|
|
+ BigDecimal goodsPrice = goodsEntity.getStoreRetailPrice().multiply(new BigDecimal(goodsEntity.getGoodsNumber())).setScale(2, RoundingMode.HALF_UP);
|
|
|
|
+ moneyMap.put(goodsId,goodsPrice);
|
|
|
|
+ totalPrice = totalPrice.add(goodsPrice);
|
|
|
|
+ // 查询该商品id是否有优惠券
|
|
|
|
+ List<MkStoreTicketDiscountEntity> mkStoreTicketDiscountEntity = mkStoreTicketDiscountService.queryByGoodsId(goodsId);
|
|
|
|
+ if(mkStoreTicketDiscountEntity != null) {
|
|
|
|
+ mkStoreTicketDiscountEntities.addAll(mkStoreTicketDiscountEntity);
|
|
|
|
+ }
|
|
|
|
+ // 查询该商品id是否有满减
|
|
|
|
+ List<MkStoreCampMinusLevelEntity> mkStoreCampMinusEntity = mkStoreCampMinusService.queryByGoodsId(goodsId);
|
|
|
|
+ if(mkStoreCampMinusEntity != null) {
|
|
|
|
+ mkStoreCampMinusEntities.addAll(mkStoreCampMinusEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 满减优惠的金额
|
|
|
|
+ BigDecimal campDisCountAmount = new BigDecimal(0);
|
|
|
|
+ if(mkStoreCampMinusEntities.size() > 0){
|
|
|
|
+ // 上一次所需金额,用于取最大的优惠力度
|
|
|
|
+ BigDecimal lastAmount = new BigDecimal(0);
|
|
|
|
+ for (int i = 0 ; i < mkStoreCampMinusEntities.size() ; i++){
|
|
|
|
+ MkStoreCampMinusLevelEntity mkStoreCampMinusLevelEntity = mkStoreCampMinusEntities.get(i);
|
|
|
|
+ // TODO 20200610还有满多少件,跟满多少元打折的,逻辑复杂,下次开发
|
|
|
|
+ BigDecimal discCond = mkStoreCampMinusLevelEntity.getYuanMinusCond();
|
|
|
|
+ // 判断这次金额是否大于上次金额,如果不大于,直接continue
|
|
|
|
+ if(discCond.compareTo(lastAmount) > 0){
|
|
|
|
+ // 如果总金额大于所需金额,则可以使用该优惠券,记录该优惠券的角标,金额跟优惠的钱
|
|
|
|
+ if(totalPrice.compareTo(discCond) > 0){
|
|
|
|
+ // 记录上一次金额
|
|
|
|
+ lastAmount = discCond;
|
|
|
|
+ campDisCountAmount = mkStoreCampMinusLevelEntity.getYuanMinusPref();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 优惠券优惠的金额
|
|
|
|
+ BigDecimal ticketDisCountAmount = new BigDecimal(0);
|
|
|
|
+ if(mkStoreTicketDiscountEntities.size() > 0){
|
|
|
|
+ // 上一次所需金额,用于取最大的优惠力度
|
|
|
|
+ BigDecimal lastAmount = new BigDecimal(0);
|
|
|
|
+ for (int i = 0 ; i < mkStoreTicketDiscountEntities.size() ; i++){
|
|
|
|
+ MkStoreTicketDiscountEntity mkStoreTicketDiscountEntity = mkStoreTicketDiscountEntities.get(i);
|
|
|
|
+ // 代金券所需金额
|
|
|
|
+ // TODO 20200610还有折扣券的,逻辑较为复杂,下次在开发
|
|
|
|
+ BigDecimal discCond = mkStoreTicketDiscountEntity.getVoucherCond();
|
|
|
|
+
|
|
|
|
+ // 判断这次金额是否大于上次金额,如果不大于,直接continue
|
|
|
|
+ if(discCond.compareTo(lastAmount) > 0){
|
|
|
|
+ // 如果总金额大于所需金额,则可以使用该优惠券,记录该优惠券的角标,金额跟优惠的钱
|
|
|
|
+ if(totalPrice.compareTo(discCond) > 0){
|
|
|
|
+ // 记录上一次金额
|
|
|
|
+ lastAmount = discCond;
|
|
|
|
+ ticketDisCountAmount = mkStoreTicketDiscountEntity.getVoucherMoney();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ disCountAmount = ticketDisCountAmount.compareTo(campDisCountAmount) > 0 ? ticketDisCountAmount : campDisCountAmount;
|
|
|
|
+ return disCountAmount;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void AliPay(SysUserEntity user, String parCode, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws Exception {
|
|
private void AliPay(SysUserEntity user, String parCode, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws Exception {
|
|
|
|
|
|
AliPayRequestParams params = new AliPayRequestParams();
|
|
AliPayRequestParams params = new AliPayRequestParams();
|
|
@@ -2069,15 +2203,15 @@ public class OrderServiceImpl implements OrderService {
|
|
* 设置订单数据
|
|
* 设置订单数据
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public OrderVo setOrderVo(List<LinkedHashMap> goodsList, UserEntity loginUser,Long storeId, String merchSn, BigDecimal disCountAmount){
|
|
|
|
|
|
+ public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser,Long storeId, String merchSn, BigDecimal disCountAmount){
|
|
OrderVo orderInfo = new OrderVo();
|
|
OrderVo orderInfo = new OrderVo();
|
|
|
|
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
BigDecimal freightPrice = Constant.ZERO;
|
|
BigDecimal freightPrice = Constant.ZERO;
|
|
- for (LinkedHashMap goods : goodsList) {
|
|
|
|
|
|
+ for (GoodsEntity goodsEntity : goodsList) {
|
|
|
|
|
|
goodsTotalPrice = goodsTotalPrice
|
|
goodsTotalPrice = goodsTotalPrice
|
|
- .add(new BigDecimal(goods.get("retailPrice").toString()).multiply(new BigDecimal(goods.get("sellVolume").toString())));
|
|
|
|
|
|
+ .add(goodsEntity.getStoreRetailPrice().multiply(new BigDecimal(goodsEntity.getGoodsNumber())));
|
|
}
|
|
}
|
|
|
|
|
|
//订单价格计算:订单的总价+运费
|
|
//订单价格计算:订单的总价+运费
|