|
@@ -54,6 +54,7 @@ import com.kmall.common.utils.*;
|
|
|
import com.kmall.common.utils.print.ticket.item.*;
|
|
|
import com.kmall.manager.manager.express.kdn.KdniaoUtil;
|
|
|
import com.kmall.common.utils.wechat.WechatRefundApiResult;
|
|
|
+import com.mysql.cj.util.TimeUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -1697,6 +1698,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
Integer storeId = user.getStoreId();
|
|
|
|
|
|
List<GoodsEntity> goodsEntities = new ArrayList<>();
|
|
|
+
|
|
|
+ BigDecimal totalTax = new BigDecimal(0);
|
|
|
+
|
|
|
// 检查库存和更新库存
|
|
|
for (LinkedHashMap goodsDto : goodsList) {
|
|
|
//
|
|
@@ -1736,26 +1740,26 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return resultObj;
|
|
|
} else {
|
|
|
// 判断销售价是否低于底线价
|
|
|
- if(productInfo.getBottomLinePrice() != null){
|
|
|
- BigDecimal bottomLinePrice = new BigDecimal(productInfo.getBottomLinePrice());
|
|
|
- if (goodsEntity.getStoreRetailPrice().compareTo(bottomLinePrice) <= -1) {
|
|
|
- LOGGER.error("销售价格小于底线价格");
|
|
|
-
|
|
|
- // 记录该信息,到价格过低日志表中,这里没有活动id
|
|
|
- Mall2LowPriceWarningEntity lowPriceWarningEntity = new Mall2LowPriceWarningEntity();
|
|
|
- lowPriceWarningEntity.setSalePrice(goodsEntity.getStoreRetailPrice());
|
|
|
- lowPriceWarningEntity.setWarningPrice(bottomLinePrice);
|
|
|
- lowPriceWarningEntity.setSku(goodsEntity.getGoodsSn());
|
|
|
- lowPriceWarningEntity.setWarningType("00");
|
|
|
- lowPriceWarningEntity.setStoreId(storeId+"");
|
|
|
- lowPriceWarningEntity.setCreateTime(new Date());
|
|
|
-
|
|
|
- lowPriceWarningDao.save(lowPriceWarningEntity);
|
|
|
- resultObj.put("errno", 400);
|
|
|
- resultObj.put("errmsg", "商品"+goodsEntity.getName()+"的销售价格小于底线价格");
|
|
|
- return resultObj;
|
|
|
- }
|
|
|
- }
|
|
|
+// if(productInfo.getBottomLinePrice() != null){
|
|
|
+// BigDecimal bottomLinePrice = new BigDecimal(productInfo.getBottomLinePrice());
|
|
|
+// if (goodsEntity.getStoreRetailPrice().compareTo(bottomLinePrice) <= -1) {
|
|
|
+// LOGGER.error("销售价格小于底线价格");
|
|
|
+//
|
|
|
+// // 记录该信息,到价格过低日志表中,这里没有活动id
|
|
|
+// Mall2LowPriceWarningEntity lowPriceWarningEntity = new Mall2LowPriceWarningEntity();
|
|
|
+// lowPriceWarningEntity.setSalePrice(goodsEntity.getStoreRetailPrice());
|
|
|
+// lowPriceWarningEntity.setWarningPrice(bottomLinePrice);
|
|
|
+// lowPriceWarningEntity.setSku(goodsEntity.getGoodsSn());
|
|
|
+// lowPriceWarningEntity.setWarningType("00");
|
|
|
+// lowPriceWarningEntity.setStoreId(storeId+"");
|
|
|
+// lowPriceWarningEntity.setCreateTime(new Date());
|
|
|
+//
|
|
|
+// lowPriceWarningDao.save(lowPriceWarningEntity);
|
|
|
+// resultObj.put("errno", 400);
|
|
|
+// resultObj.put("errmsg", "商品"+goodsEntity.getName()+"的销售价格小于底线价格");
|
|
|
+// return resultObj;
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
|
|
@@ -1774,22 +1778,54 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
if(goodsDto.get("actualPaymentAmount") instanceof Double){
|
|
|
goodsEntity.setStoreRetailPrice(new BigDecimal((Double)goodsDto.get("actualPaymentAmount")));
|
|
|
- goodsEntity.setRetailPrice(new BigDecimal((Double)goodsDto.get("retailPrice"))); // 单价
|
|
|
- goodsEntity.setDiscountedPrice(new BigDecimal((Double)goodsDto.get("discountedPrice"))); // 优惠金额
|
|
|
- goodsEntity.setActualPaymentAmount(new BigDecimal((Double)goodsDto.get("actualPaymentAmount"))); // 实际支付价格
|
|
|
+
|
|
|
}else if(goodsDto.get("actualPaymentAmount") instanceof Integer){
|
|
|
goodsEntity.setStoreRetailPrice(new BigDecimal((Integer)goodsDto.get("actualPaymentAmount")));
|
|
|
- goodsEntity.setRetailPrice(new BigDecimal((Integer)goodsDto.get("retailPrice")));
|
|
|
- goodsEntity.setDiscountedPrice(new BigDecimal((Integer)goodsDto.get("discountedPrice")));
|
|
|
- goodsEntity.setActualPaymentAmount(new BigDecimal((Integer)goodsDto.get("actualPaymentAmount")));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}else if(goodsDto.get("actualPaymentAmount") instanceof Float){
|
|
|
goodsEntity.setStoreRetailPrice(new BigDecimal((Float)goodsDto.get("actualPaymentAmount")));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(goodsDto.get("retailPrice") instanceof Double){
|
|
|
+ goodsEntity.setRetailPrice(new BigDecimal((Double)goodsDto.get("retailPrice"))); // 单价
|
|
|
+
|
|
|
+ }else if(goodsDto.get("retailPrice") instanceof Integer){
|
|
|
+ goodsEntity.setRetailPrice(new BigDecimal((Integer)goodsDto.get("retailPrice")));
|
|
|
+ }else if(goodsDto.get("retailPrice") instanceof Float){
|
|
|
goodsEntity.setRetailPrice(new BigDecimal((Float)goodsDto.get("retailPrice")));
|
|
|
+ }
|
|
|
+ if(goodsDto.get("discountedPrice") instanceof Double){
|
|
|
+ goodsEntity.setDiscountedPrice(new BigDecimal((Integer)goodsDto.get("discountedPrice"))); // 优惠金额
|
|
|
+ }else if(goodsDto.get("discountedPrice") instanceof Integer){
|
|
|
+ goodsEntity.setDiscountedPrice(new BigDecimal((Integer)goodsDto.get("discountedPrice")));
|
|
|
+ }else if(goodsDto.get("discountedPrice") instanceof Float){
|
|
|
goodsEntity.setDiscountedPrice(new BigDecimal((Float)goodsDto.get("discountedPrice")));
|
|
|
+ }
|
|
|
+ if(goodsDto.get("actualPaymentAmount") instanceof Double){
|
|
|
+ goodsEntity.setActualPaymentAmount(new BigDecimal((Double)goodsDto.get("actualPaymentAmount"))); // 实际支付价格
|
|
|
+ }else if(goodsDto.get("actualPaymentAmount") instanceof Integer){
|
|
|
+ goodsEntity.setActualPaymentAmount(new BigDecimal((Integer)goodsDto.get("actualPaymentAmount")));
|
|
|
+ }else if(goodsDto.get("actualPaymentAmount") instanceof Float){
|
|
|
goodsEntity.setActualPaymentAmount(new BigDecimal((Float)goodsDto.get("actualPaymentAmount")));
|
|
|
}
|
|
|
|
|
|
|
|
|
+ if(goodsDto.get("goodstaxes") instanceof Double){
|
|
|
+ totalTax = totalTax.add(new BigDecimal((Double)goodsDto.get("goodstaxes"))); // 实际支付价格
|
|
|
+ }else if(goodsDto.get("goodstaxes") instanceof Integer){
|
|
|
+ totalTax = totalTax.add(new BigDecimal((Integer)goodsDto.get("goodstaxes")));
|
|
|
+ }else if(goodsDto.get("goodstaxes") instanceof Float){
|
|
|
+ totalTax = totalTax.add(new BigDecimal((Float)goodsDto.get("goodstaxes")));
|
|
|
+ }else if(goodsDto.get("goodstaxes") instanceof String){
|
|
|
+ totalTax = totalTax.add(new BigDecimal((String) goodsDto.get("goodstaxes")));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// goodsEntity.setStoreRetailPrice(productInfo.getRetailPrice());
|
|
|
// 借用这个字段来存储购买数
|
|
@@ -1827,7 +1863,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
// TODO 查询使用的优惠券,并减扣金额
|
|
|
String couponSn = (String) userInfo.get("couponSn");
|
|
|
- MkActivitiesCouponEntity couponEntity = mkActivitiesCouponService.queryByCouponSn(couponSn);
|
|
|
+ // 获取当前时间
|
|
|
+ String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
+ MkActivitiesCouponEntity couponEntity = mkActivitiesCouponService.queryByCouponSn(couponSn,currentTime);
|
|
|
// // 优惠金额
|
|
|
BigDecimal disCountAmount = new BigDecimal(0);
|
|
|
if(couponEntity != null){
|
|
@@ -1852,16 +1890,15 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
// 生成订单
|
|
|
String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
|
|
|
- OrderVo order = setOrderVo(goodsEntities, userEntity,storeId.longValue(), user.getMerchSn(),disCountAmount);
|
|
|
+ OrderVo order = setOrderVo(goodsEntities, userEntity,storeId.longValue(), user.getMerchSn(),disCountAmount,totalTax);
|
|
|
order.setStore_id(storeId.longValue());
|
|
|
// if(storeTopic != null){
|
|
|
// order.setActivity_id(storeTopic.getId().longValue());
|
|
|
// }
|
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
|
-
|
|
|
+ order.setCoupon_name(couponSn); // 借用这个字段来记录是否使用优惠券
|
|
|
//插入订单信息和订单商品
|
|
|
orderDao.saveOrderVo(order);
|
|
|
|
|
@@ -1908,10 +1945,10 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// 支付宝支付
|
|
|
// AliPay(user, parCode , order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
OrderEntity orderEntity = queryObject(order.getId());
|
|
|
- orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
|
|
|
- orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
|
+// orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
|
|
|
+// orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
|
// orderEntity.setPayFlag(payFlag);
|
|
|
- orderEntity.setPayTime(new Date());
|
|
|
+// orderEntity.setPayTime(new Date());
|
|
|
orderDao.update(orderEntity);
|
|
|
resultObj.put("shopName",store.getStoreName()); // 根据门店编号查询
|
|
|
resultObj.put("userName",user.getUsername());
|
|
@@ -2355,28 +2392,40 @@ public class OrderServiceImpl implements OrderService {
|
|
|
* 设置订单数据
|
|
|
* @return
|
|
|
*/
|
|
|
- public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser,Long storeId, String merchSn, BigDecimal disCountAmount){
|
|
|
+ public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser, Long storeId, String merchSn, BigDecimal disCountAmount, BigDecimal totalTax){
|
|
|
OrderVo orderInfo = new OrderVo();
|
|
|
|
|
|
BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
|
+ BigDecimal fullCutCouponDec = Constant.ZERO; // 非现金抵扣 = 各种优惠价格 +优惠券的价格 暂时借用这个字段去,为了不改动ccnet系统
|
|
|
+ BigDecimal couponPrice = disCountAmount;
|
|
|
BigDecimal freightPrice = Constant.ZERO;
|
|
|
+ BigDecimal actualPrice = Constant.ZERO;
|
|
|
+ //订单价格计算:订单的总价+运费
|
|
|
for (GoodsEntity goodsEntity : goodsList) {
|
|
|
-
|
|
|
goodsTotalPrice = goodsTotalPrice
|
|
|
- .add(goodsEntity.getStoreRetailPrice().multiply(new BigDecimal(goodsEntity.getGoodsNumber())));
|
|
|
+ .add(goodsEntity.getRetailPrice().multiply(new BigDecimal(goodsEntity.getGoodsNumber()))).setScale(2,RoundingMode.HALF_UP);
|
|
|
+ fullCutCouponDec = fullCutCouponDec
|
|
|
+ .add(goodsEntity.getDiscountedPrice()).setScale(2,RoundingMode.HALF_UP);
|
|
|
+ actualPrice = actualPrice
|
|
|
+ .add(goodsEntity.getActualPaymentAmount().multiply(new BigDecimal(goodsEntity.getGoodsNumber()))).setScale(2,RoundingMode.HALF_UP);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- //订单价格计算:订单的总价+运费
|
|
|
+
|
|
|
BigDecimal orderTotalPrice = goodsTotalPrice.add(new BigDecimal(0));
|
|
|
- BigDecimal fullCutCouponDec = Constant.ZERO;
|
|
|
- BigDecimal couponPrice = disCountAmount;
|
|
|
- BigDecimal actualPrice = orderTotalPrice.subtract(couponPrice);
|
|
|
+ fullCutCouponDec = fullCutCouponDec.add(couponPrice).setScale(2,RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ // 加上税额
|
|
|
+ goodsTotalPrice = goodsTotalPrice.add(totalTax).setScale(2,RoundingMode.HALF_UP);
|
|
|
+ orderTotalPrice = orderTotalPrice.add(totalTax).setScale(2,RoundingMode.HALF_UP);
|
|
|
|
|
|
- String orderSn = "CW" + CommonUtil.generateOrderNumber();
|
|
|
+
|
|
|
+
|
|
|
+ String orderSn = "ZWCW" + CommonUtil.generateOrderNumber();
|
|
|
orderInfo.setOrder_sn(orderSn);
|
|
|
orderInfo.setMerchSn(merchSn);
|
|
|
orderInfo.setUser_id(loginUser.getId().longValue());
|
|
|
-
|
|
|
+ actualPrice = actualPrice.subtract(couponPrice);
|
|
|
|
|
|
StoreEntity storeEntity = storeDao.queryObject(storeId);
|
|
|
//收货地址和运费
|