From 608f4bd5ff1a0024c04af0973b20ed360d1d16a0 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 09 Nov 2021 11:34:52 +0800
Subject: [PATCH] fix
---
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 270 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 167 insertions(+), 103 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
index eace5b4..f9bc208 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -1,6 +1,7 @@
package com.matrix.system.hive.service.imp;
-import com.matrix.component.rabbitmq.RabiitMqTemplate;
+import cn.hutool.core.collection.CollectionUtil;
+import com.matrix.component.asyncmessage.AsyncMessageManager;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
@@ -31,20 +32,18 @@
import com.matrix.system.score.constant.ScoreSettingConstant;
import com.matrix.system.score.entity.ScoreVipDetail;
import com.matrix.system.score.service.ScoreVipDetailService;
-import com.matrix.system.shopXcx.mqTask.MQTaskRouting;
+import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting;
import com.matrix.system.wechart.templateMsg.UniformMsgParam;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @date 2016-07-03 20:53
@@ -124,11 +123,8 @@
@Autowired
BusParameterSettingsDao parameterSettingsDao;
- @Value("${evn}")
- private String evn;
-
@Autowired
- private RabiitMqTemplate rabiitMqTemplate;
+ private AsyncMessageManager asyncMessageManager;
@Override
@@ -264,6 +260,7 @@
/**
* 取消订单
+ *
* @param id
* @return
*/
@@ -280,7 +277,7 @@
//发送微信公众号提醒
UniformMsgParam uniformMsgParam = new UniformMsgParam(order.getCompanyId(), UniformMsgParam.GZH_DDQX);
uniformMsgParam.put("orderId", order.getId());
- rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString());
+ asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam);
return sysOrderDao.update(order);
@@ -469,7 +466,6 @@
}
-
/**
* jyy 收款
*/
@@ -481,14 +477,12 @@
throw new GlobleException("该订单已经收过款,请刷新页面再试!");
}
- //检查交易限制调整
- checkSealLimit(pageOrder);
+
+ checkOrder(pageOrder);
// 更新收款时间
- pageOrder.setPayTime(new Date());
- pageOrder.setStatu(Dictionary.ORDER_STATU_YFK);
- sysOrderDao.update(pageOrder);
+ updateOrderInfo(pageOrder);
// 获取用户信息
SysVipInfo vipInfo = sysVipInfoDao.selectById(pageOrder.getVipId());
@@ -521,16 +515,78 @@
}
/**
+ * 付款后更新订单信息
+ * @param pageOrder
+ */
+ private void updateOrderInfo(SysOrder pageOrder) {
+ pageOrder.setPayTime(new Date());
+ pageOrder.setStatu(Dictionary.ORDER_STATU_YFK);
+ List<SysOrderFlow> flows = pageOrder.getFlows();
+
+ BigDecimal cashPayAmount = flows.stream()
+ .filter(item -> (!item.getPayMethod().equals("储值卡")) && (!item.getPayMethod().equals("欠款")))
+ .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ BigDecimal cardPayAmount = flows.stream()
+ .filter(item -> item.getPayMethod().equals("储值卡") && item.getIsGift().equals("N"))
+ .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+ pageOrder.setCardPay(cardPayAmount.doubleValue());
+ pageOrder.setCashPay(cashPayAmount.doubleValue());
+ //欠款金额在流水处理中处理了
+
+ sysOrderDao.update(pageOrder);
+ }
+
+ private void checkOrder(SysOrder pageOrder) {
+ //检查交易限制调整
+ checkSealLimit(pageOrder);
+ //检查业绩设置
+ checkOrderAchieve(pageOrder);
+ }
+
+ /**
+ * 检查业绩设置是否合理
+ * 1、每个订单明细都要有至少一个对应的业绩
+ * 2、每个订单明细的同类型业绩金额之和不能大于明细支付金额
+ *
+ * @param pageOrder
+ */
+ private void checkOrderAchieve(SysOrder pageOrder) {
+
+ pageOrder.getItems().forEach(item -> {
+
+ if (CollectionUtil.isEmpty(item.getAchieveList())) {
+ ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId());
+ throw GlobleException.instance(shopGoods.getName() + "缺少设置业绩");
+ }
+
+ //按业绩类型分组后比较支付金额与业绩金额是否相等
+ Map<String, List<AchieveNew>> achieveTypeMap = item.getAchieveList().stream().collect(Collectors.groupingBy(AchieveNew::getAchieveType));
+ Set<Map.Entry<String, List<AchieveNew>>> entries = achieveTypeMap.entrySet();
+ entries.forEach(entrie -> {
+ double sum = entrie.getValue().stream().mapToDouble(AchieveNew::getGoodsCash).sum();
+ //todo 目前使用js计算金额可能存在精度的误差展示用0.1屏蔽
+ if (Math.abs(sum- (item.getZkPrice()*item.getCount()) )>0.1) {
+ ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId());
+ throw GlobleException.instance(shopGoods.getName() + "," + entrie.getKey() + "业绩金额与收款金额不一致");
+ }
+ });
+ });
+
+ }
+
+ /**
* 检查产品销售次数
*/
private void checkSealLimit(SysOrder pageOrder) {
- pageOrder.getItems().forEach(item->{
+ pageOrder.getItems().forEach(item -> {
ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId());
//最大销售次数检测
Integer maxNum = shopGoods.getCarMaxSaleCount();
if (maxNum != null && maxNum != 0) {
- Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(),null);
+ Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(), null);
if ((buyNum + item.getCount()) > maxNum) {
throw new GlobleException(shopGoods.getName() + "已超过最大销售数量");
}
@@ -543,11 +599,11 @@
}
//每人限购次数检测
Integer onceCount = shopGoods.getIsOnce();
- if(onceCount!=null && onceCount!=0){
- Integer buyOnceCount = orderItemDao.selectByGoodsId(shopGoods.getId(),pageOrder.getVipId());
+ if (onceCount != null && onceCount != 0) {
+ Integer buyOnceCount = orderItemDao.selectByGoodsId(shopGoods.getId(), pageOrder.getVipId());
if ((buyOnceCount + item.getCount()) > onceCount) {
- throw new GlobleException(shopGoods.getName() + "每人限购"+onceCount+"次");
+ throw new GlobleException(shopGoods.getName() + "每人限购" + onceCount + "次");
}
}
@@ -556,116 +612,116 @@
}
-
/**
* 设置会员消费积分
+ *
* @param pageOrder
*/
private void addVipScore(SysOrder pageOrder) {
- SysVipInfo vipInfo=sysVipInfoDao.selectById(pageOrder.getVipId());
+ SysVipInfo vipInfo = sysVipInfoDao.selectById(pageOrder.getVipId());
List<SysOrderFlow> flows = pageOrder.getFlows();
- int [] cashScore={0,0,0};
+ int[] cashScore = {0, 0, 0};
//现金支付金额
- BigDecimal cashPayAmount=flows.stream()
- .filter(item->(!item.getPayMethod().equals("储值卡"))&&(!item.getPayMethod().equals("欠款")))
- .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
+ BigDecimal cashPayAmount = flows.stream()
+ .filter(item -> (!item.getPayMethod().equals("储值卡")) && (!item.getPayMethod().equals("欠款")))
+ .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BusParameterSettings cashConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.CASH_CONSUMPTION, vipInfo.getCompanyId());
- if(cashPayAmount!=null
- &&cashPayAmount.compareTo(BigDecimal.ZERO)>0
- &&StringUtils.isNotBlank(cashConsumption.getParamValue())){
+ if (cashPayAmount != null
+ && cashPayAmount.compareTo(BigDecimal.ZERO) > 0
+ && StringUtils.isNotBlank(cashConsumption.getParamValue())) {
BigDecimal scoreSetting0 = new BigDecimal(cashConsumption.getParamValue());
- if(scoreSetting0.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting0.compareTo(BigDecimal.ZERO) > 0) {
cashScore[0] = cashPayAmount.divide(scoreSetting0).intValue();
}
- if(StringUtils.isNotBlank(cashConsumption.getParamValue1())){
+ if (StringUtils.isNotBlank(cashConsumption.getParamValue1())) {
BigDecimal scoreSetting1 = new BigDecimal(cashConsumption.getParamValue1());
- if(scoreSetting1.compareTo(BigDecimal.ZERO)>0){
- cashScore[1]= cashPayAmount.divide(scoreSetting1).intValue();
+ if (scoreSetting1.compareTo(BigDecimal.ZERO) > 0) {
+ cashScore[1] = cashPayAmount.divide(scoreSetting1).intValue();
}
}
- if(StringUtils.isNotBlank(cashConsumption.getParamValue2())){
+ if (StringUtils.isNotBlank(cashConsumption.getParamValue2())) {
BigDecimal scoreSetting2 = new BigDecimal(cashConsumption.getParamValue2());
- if(scoreSetting2.compareTo(BigDecimal.ZERO)>0){
- cashScore[2]= cashPayAmount.divide(scoreSetting2).intValue();
+ if (scoreSetting2.compareTo(BigDecimal.ZERO) > 0) {
+ cashScore[2] = cashPayAmount.divide(scoreSetting2).intValue();
}
}
}
- int [] cardScore={0,0,0};
+ int[] cardScore = {0, 0, 0};
//储值卡本金支付金额
- BigDecimal cardPayAmount=flows.stream()
- .filter(item->item.getPayMethod().equals("储值卡")&&item.getIsGift().equals("N"))
- .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
+ BigDecimal cardPayAmount = flows.stream()
+ .filter(item -> item.getPayMethod().equals("储值卡") && item.getIsGift().equals("N"))
+ .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BusParameterSettings principalBalanceConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.PRINCIPAL_BALANCE_CONSUMPTION, vipInfo.getCompanyId());
- if(cardPayAmount!=null
- &&cardPayAmount.compareTo(BigDecimal.ZERO)>0
- &&StringUtils.isNotBlank(principalBalanceConsumption.getParamValue())){
+ if (cardPayAmount != null
+ && cardPayAmount.compareTo(BigDecimal.ZERO) > 0
+ && StringUtils.isNotBlank(principalBalanceConsumption.getParamValue())) {
BigDecimal scoreSetting0 = new BigDecimal(principalBalanceConsumption.getParamValue());
- if(scoreSetting0.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting0.compareTo(BigDecimal.ZERO) > 0) {
cardScore[0] = cardPayAmount.divide(scoreSetting0).intValue();
}
- if(StringUtils.isNotBlank(principalBalanceConsumption.getParamValue1())){
+ if (StringUtils.isNotBlank(principalBalanceConsumption.getParamValue1())) {
BigDecimal scoreSetting1 = new BigDecimal(principalBalanceConsumption.getParamValue1());
- if(scoreSetting1.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting1.compareTo(BigDecimal.ZERO) > 0) {
cardScore[1] = cardPayAmount.divide(scoreSetting1).intValue();
}
}
- if(StringUtils.isNotBlank(principalBalanceConsumption.getParamValue2())){
+ if (StringUtils.isNotBlank(principalBalanceConsumption.getParamValue2())) {
BigDecimal scoreSetting2 = new BigDecimal(principalBalanceConsumption.getParamValue2());
- if(scoreSetting2.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting2.compareTo(BigDecimal.ZERO) > 0) {
cardScore[2] = cardPayAmount.divide(scoreSetting2).intValue();
}
}
}
- int [] giftScore={0,0,0};
+ int[] giftScore = {0, 0, 0};
//储值卡本赠送付金额
- BigDecimal giftPayAmount=flows.stream()
- .filter(item->item.getPayMethod().equals("储值卡")&&item.getIsGift().equals("Y"))
- .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
+ BigDecimal giftPayAmount = flows.stream()
+ .filter(item -> item.getPayMethod().equals("储值卡") && item.getIsGift().equals("Y"))
+ .map(SysOrderFlow::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BusParameterSettings bonusBalanceConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.BONUS_BALANCE_CONSUMPTION, vipInfo.getCompanyId());
- if(giftPayAmount!=null
- &&giftPayAmount.compareTo(BigDecimal.ZERO)>0
- &&StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue())){
+ if (giftPayAmount != null
+ && giftPayAmount.compareTo(BigDecimal.ZERO) > 0
+ && StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue())) {
BigDecimal scoreSetting0 = new BigDecimal(bonusBalanceConsumption.getParamValue());
- if(scoreSetting0.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting0.compareTo(BigDecimal.ZERO) > 0) {
giftScore[0] = giftPayAmount.divide(scoreSetting0).intValue();
}
- if(StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue1())){
+ if (StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue1())) {
BigDecimal scoreSetting1 = new BigDecimal(bonusBalanceConsumption.getParamValue1());
- if(scoreSetting1.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting1.compareTo(BigDecimal.ZERO) > 0) {
giftScore[1] = giftPayAmount.divide(scoreSetting1).intValue();
}
}
- if(StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue2())){
+ if (StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue2())) {
BigDecimal scoreSetting2 = new BigDecimal(bonusBalanceConsumption.getParamValue2());
- if(scoreSetting2.compareTo(BigDecimal.ZERO)>0) {
+ if (scoreSetting2.compareTo(BigDecimal.ZERO) > 0) {
giftScore[2] = giftPayAmount.divide(scoreSetting2).intValue();
}
}
}
- int selfScore=cashScore[0]+cardScore[0]+giftScore[0];
- int parentScore=cashScore[1]+cardScore[1]+giftScore[1];
- int topParentScore=cashScore[2]+cardScore[2]+giftScore[2];
+ int selfScore = cashScore[0] + cardScore[0] + giftScore[0];
+ int parentScore = cashScore[1] + cardScore[1] + giftScore[1];
+ int topParentScore = cashScore[2] + cardScore[2] + giftScore[2];
//添加自己的积分
- if(selfScore>0){
+ if (selfScore > 0) {
scoreVipDetailService.addScore(
vipInfo.getId(),
pageOrder.getStaffId(),
@@ -677,10 +733,10 @@
);
}
- if(vipInfo.getRecommendId()!=null){
+ if (vipInfo.getRecommendId() != null) {
//推荐注册老带新积分奖励
SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId());
- if(parentScore>0){
+ if (parentScore > 0) {
scoreVipDetailService.addScore(
referrerVip.getId(),
pageOrder.getStaffId(),
@@ -692,9 +748,9 @@
);
}
//推荐注册二级带新积分奖励
- if(referrerVip.getRecommendId()!=null){
+ if (referrerVip.getRecommendId() != null) {
SysVipInfo topVipInfo = sysVipInfoDao.selectById(referrerVip.getRecommendId());
- if(topParentScore>0){
+ if (topParentScore > 0) {
scoreVipDetailService.addScore(
topVipInfo.getId(),
pageOrder.getStaffId(),
@@ -725,7 +781,7 @@
ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId);
flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品");
// 若是退款,则取负数
- if (SysOrder.ORDER_TYPE_REFUND== sourceOrder.getOrderType()) {
+ if (SysOrder.ORDER_TYPE_REFUND == sourceOrder.getOrderType()) {
flow.setFlowType(SysOrderFlow.FLOW_TYPE_REFUND);
flow.setAmount(flow.getAmount().negate());
flow.setOrderId(sourceOrder.getOldOrderId());
@@ -747,7 +803,7 @@
MoneyCardUse moneyCardUse = moneyCardUseDao.selectById(flow.getCardId());
//修改储值卡余额
cardPaySk(moneyCardUse, sourceOrder, flow);
- }else{
+ } else {
throw new GlobleException("无效的储值卡支付方式");
}
}
@@ -759,7 +815,6 @@
sysOrderFlowDao.insert(flow);
flowCount++;
}
-
}
@@ -777,7 +832,7 @@
// 最大发卡数量为0代表不做限制
if (maxNum != null && maxNum != 0) {
// 查询该商品已经被购买的次数
- Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(),null);
+ Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(), null);
buyNum = (buyNum == null ? 0 : buyNum);
if ((buyNum + carItem.getCount()) > maxNum) {
throw new GlobleException(shopGoods.getName() + "已超过最大销售数量");
@@ -1026,11 +1081,10 @@
}
sourceOrder.setArrears(sourceOrder.getArrears() - refundTotal);
- sourceOrder.setCardPay(sourceOrder.getCardPay() + cardPayTotal);
- sourceOrder.setCashPay(sourceOrder.getCashPay() + cashPayTotal);
+ sourceOrder.setCardPay(sourceOrder.getCardPay() == null ? 0 : sourceOrder.getCardPay() + cardPayTotal);
+ sourceOrder.setCashPay(sourceOrder.getCashPay() == null ? 0 : sourceOrder.getCashPay() + cashPayTotal);
sysOrderDao.update(sourceOrder);
}
-
/**
@@ -1042,7 +1096,7 @@
public void addOutStore(SysOrder order) {
BusParameterSettings manageStockSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WAREHOUSE_MANAGE_STOCK, order.getCompanyId());
- if(AppConstance.IS_Y.equals(manageStockSetting.getParamValue())){
+ if (AppConstance.IS_Y.equals(manageStockSetting.getParamValue())) {
List<SysOutStoreItem> storeItemList = new ArrayList<>();
@@ -1143,7 +1197,7 @@
sysOutStoreItemDao.batchInsert(realOutStoreItemList);
}
- }else{
+ } else {
LogUtil.debug("不管理库存");
}
@@ -1188,7 +1242,7 @@
List<ShoppingGoodsAssemble> assembleList = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_XM);
assembleList.forEach(item -> {
//TODO 补综合卡逻辑
- createProjuseByAssemble(order, sysOrderItem, item, null, null,null,0);
+ createProjuseByAssemble(order, sysOrderItem, item, null, null, null, 0);
});
//处理综合卡中包含的套餐
@@ -1209,7 +1263,7 @@
* 通过组合关系创建用户项目余次
*/
private SysProjUse createProjuseByAssemble(SysOrder order, SysOrderItem sysOrderItem,
- ShoppingGoodsAssemble goodsAssemble, Long taocanId, Date failTime,String source,int maxCount) {
+ ShoppingGoodsAssemble goodsAssemble, Long taocanId, Date failTime, String source, Integer maxCount) {
//计算折扣
Double zk = sysOrderItem.getZkPrice() / sysOrderItem.getPrice();
@@ -1217,7 +1271,7 @@
puse.setIsOver(Dictionary.DELETED_N);
puse.setOrderItemId(sysOrderItem.getId());
puse.setProjId(goodsAssemble.getAssembleGoodId());
- puse.setSurplusCount(goodsAssemble.getTotal()==null?maxCount: goodsAssemble.getTotal());
+ puse.setSurplusCount(goodsAssemble.getTotal() == null ? maxCount : goodsAssemble.getTotal());
puse.setDeductionNum(goodsAssemble.getDeductionNum());
puse.setProjName(goodsAssemble.getShoppingGoods().getName());
puse.setVipId(order.getVipId());
@@ -1235,16 +1289,16 @@
//赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗
boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE);
- if(zsConsumeAchieve){
- if(sysOrderItem.getPrice()<=0){
+ if (zsConsumeAchieve) {
+ if (sysOrderItem.getPrice() <= 0) {
//等于0取原价
if (taocanId == null) {
- puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() );
+ puse.setPrice(goodsAssemble.getShoppingGoods().getPrice());
} else {
puse.setPrice(goodsAssemble.getPrice());
}
}
- }else{
+ } else {
puse.setPrice(0D);
}
@@ -1297,7 +1351,7 @@
//创建套餐绑定的项目
List<ShoppingGoodsAssemble> assembleList = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(projId, ShoppingGoods.SHOPPING_GOODS_TYPE_XM);
for (ShoppingGoodsAssemble assemble : assembleList) {
- SysProjUse tempUse = createProjuseByAssemble(order, sysOrderItem, assemble, taocanProjUse.getId(),taocanProjUse.getFailTime(),taocanProjUse.getSource(),taocanShoppingGoods.getCarUseCount());
+ SysProjUse tempUse = createProjuseByAssemble(order, sysOrderItem, assemble, taocanProjUse.getId(), taocanProjUse.getFailTime(), taocanProjUse.getSource(), taocanShoppingGoods.getCarUseCount());
sumBanance += tempUse.getBalance();
surplusCount += tempUse.getSurplusCount();
}
@@ -1346,32 +1400,36 @@
puse.setSource(Dictionary.TAOCAN_SOURCE_ZS);
//赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗
boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE);
- if(zsConsumeAchieve){
- puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice());
- }else{
+ if (zsConsumeAchieve) {
+ //赠送情况下,如果收款金额大于0,就是赠送金额划扣的情况,金额即为划扣的折扣金额
+ if(sysOrderItem.getZkPrice()>0){
+ puse.setPrice(sysOrderItem.getZkPrice());
+ }else{
+ puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice());
+ }
+ } else {
puse.setPrice(0D);
}
-
-
}
// 设置失效时间
Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null);
puse.setFailTime(invalidTime);
- puse.setBalance(sysOrderItem.getShoppingGoods().getSealPice()*puse.getSurplusCount());
+ puse.setBalance(puse.getPrice() * puse.getSurplusCount());
sysProjUseDao.insert(puse);
}
/**
* 全是赠送金额,且配置了赠送金额购买计算为赠送
+ *
* @param order
* @return
*/
private boolean isGiftMoneyPay(SysOrder order) {
BusParameterSettings giftiIsfree = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SHOP_MANAGE_GIFTISFREE, order.getCompanyId());
- if(giftiIsfree.getParamValue().equals("是")){
- return order.getFlows().stream().allMatch(item -> SysOrderFlow.IS_GIFT_Y.equals(item.getIsGift())
- && item.getAmount().doubleValue() >0D);
- }else{
+ if (giftiIsfree.getParamValue().equals("是")) {
+ return order.getFlows().stream().allMatch(item -> SysOrderFlow.IS_GIFT_Y.equals(item.getIsGift())
+ && item.getAmount().doubleValue() > 0D);
+ } else {
return false;
}
@@ -1522,12 +1580,12 @@
SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
//原订单设置为退款状态
- SysOrder sourceOrder=new SysOrder();
+ SysOrder sourceOrder = new SysOrder();
sourceOrder.setId(sysOrder.getOldOrderId());
sourceOrder.setIsHasRefund(SysOrder.IS_HAS_REFUND_Y);
// sourceOrder.setStatu(Dictionary.ORDER_STATU_TK);
sysOrderDao.update(sourceOrder);
- SysOrder oldOrder=sysOrderDao.selectById(sysOrder.getOldOrderId());
+ SysOrder oldOrder = sysOrderDao.selectById(sysOrder.getOldOrderId());
sysOrder.setId(null);
sysOrder.setStaffId(user.getSuId());
@@ -1546,7 +1604,7 @@
for (SysOrderItem item : sysOrder.getItems()) {
//更新原订单明细的可退数量
- SysOrderItem oldItem=new SysOrderItem();
+ SysOrderItem oldItem = new SysOrderItem();
oldItem.setId(item.getId());
oldItem.setRefundCount(item.getCount());
orderItemDao.update(oldItem);
@@ -1590,7 +1648,7 @@
MoneyCardUse moneyCardUse = moneyCardUseDao.selectById(flow.getCardId());
//修改储值卡余额
cardPaySk(moneyCardUse, sourceOrder, flow);
- }else{
+ } else {
throw new GlobleException("无效的储值卡支付方式");
}
}
@@ -1655,6 +1713,7 @@
/**
* 退款退项目,套餐,卡项
+ *
* @param sysOrder
*/
private void refundProjUse(SysOrder sysOrder) {
@@ -1680,7 +1739,7 @@
int sub = sysProjUse.getSurplusCount() - item.getCount();
if (sub < 0) {
throw new GlobleException("项目余次不足");
- }else if(sub==0){
+ } else if (sub == 0) {
sysProjUse.setIsOver(Dictionary.FLAG_YES_Y);
sysProjUse.setStatus(Dictionary.TAOCAN_STATUS_WX);
}
@@ -1741,7 +1800,7 @@
}
BusParameterSettings manageStockSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WAREHOUSE_MANAGE_STOCK, sysOrder.getCompanyId());
- if(AppConstance.IS_Y.equals(manageStockSetting.getParamValue())){
+ if (AppConstance.IS_Y.equals(manageStockSetting.getParamValue())) {
// 家居产品退库存
if (CollectionUtils.isNotEmpty(returnGoodsList)) {
refundInstore(returnGoodsList);
@@ -1794,4 +1853,9 @@
sysInstoreInfoService.check(instoreInfo);
}
+
+ @Override
+ public BigDecimal findVipArrearsByVipId(Long vipId) {
+ return sysOrderDao.selectArrearsByVipId(vipId);
+ }
}
--
Gitblit v1.9.1