| | |
| | | import com.matrix.system.app.vo.OrderDetailItemVo; |
| | | import com.matrix.system.app.vo.OrderDetailVo; |
| | | import com.matrix.system.app.vo.RankingVo; |
| | | import com.matrix.system.common.bean.BusParameterSettings; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.SysUsersDao; |
| | |
| | | import com.matrix.system.hive.pojo.ShoppingCarItem; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; |
| | | import com.matrix.system.hive.service.*; |
| | | 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.wechart.templateMsg.UniformMsgParam; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | 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; |
| | |
| | | @Autowired |
| | | MoneyCardUseFlowDao moneyCardUseFlowDao; |
| | | |
| | | @Autowired |
| | | ScoreVipDetailService scoreVipDetailService; |
| | | |
| | | @Autowired |
| | | BusParameterSettingsDao busParameterSettingsDao; |
| | | @Autowired |
| | | SysVipLevelDao sysVipLevelDao; |
| | | |
| | |
| | | // 删除收款记录 |
| | | sysOrderFlowDao.deleteByOrderId(id); |
| | | |
| | | //删除积分 |
| | | scoreVipDetailService.removeByBusinessId(null,order.getVipId(), order.getId()); |
| | | |
| | | // 取消订单 |
| | | order.setStatu(Dictionary.ORDER_STATU_YQX); |
| | | return sysOrderDao.update(order); |
| | |
| | | |
| | | setShopSelCount(pageOrder); |
| | | |
| | | //设置会员积分 |
| | | addVipScore(pageOrder); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置会员消费积分 |
| | | * @param pageOrder |
| | | */ |
| | | private void addVipScore(SysOrder pageOrder) { |
| | | |
| | | SysVipInfo vipInfo=sysVipInfoDao.selectById(pageOrder.getVipId()); |
| | | |
| | | List<SysOrderFlow> flows = pageOrder.getFlows(); |
| | | 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); |
| | | BusParameterSettings cashConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.CASH_CONSUMPTION, vipInfo.getCompanyId()); |
| | | if(cashPayAmount!=null |
| | | &&cashPayAmount.compareTo(BigDecimal.ZERO)>0 |
| | | &&StringUtils.isNotBlank(cashConsumption.getParamValue())){ |
| | | |
| | | BigDecimal scoreSetting0 = new BigDecimal(cashConsumption.getParamValue()); |
| | | cashScore[0]= cashPayAmount.divide(scoreSetting0).intValue(); |
| | | |
| | | if(StringUtils.isNotBlank(cashConsumption.getParamValue1())){ |
| | | BigDecimal scoreSetting1 = new BigDecimal(cashConsumption.getParamValue1()); |
| | | cashScore[1]= cashPayAmount.divide(scoreSetting1).intValue(); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(cashConsumption.getParamValue2())){ |
| | | BigDecimal scoreSetting2 = new BigDecimal(cashConsumption.getParamValue2()); |
| | | cashScore[2]= cashPayAmount.divide(scoreSetting2).intValue(); |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | |
| | | BusParameterSettings principalBalanceConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.PRINCIPAL_BALANCE_CONSUMPTION, vipInfo.getCompanyId()); |
| | | if(cardPayAmount!=null |
| | | &&cardPayAmount.compareTo(BigDecimal.ZERO)>0 |
| | | &&StringUtils.isNotBlank(principalBalanceConsumption.getParamValue())){ |
| | | |
| | | BigDecimal scoreSetting0 = new BigDecimal(principalBalanceConsumption.getParamValue()); |
| | | cardScore[0]= cardPayAmount.divide(scoreSetting0).intValue(); |
| | | |
| | | if(StringUtils.isNotBlank(principalBalanceConsumption.getParamValue1())){ |
| | | BigDecimal scoreSetting1 = new BigDecimal(principalBalanceConsumption.getParamValue1()); |
| | | cardScore[1]= cardPayAmount.divide(scoreSetting1).intValue(); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(principalBalanceConsumption.getParamValue2())){ |
| | | BigDecimal scoreSetting2 = new BigDecimal(principalBalanceConsumption.getParamValue2()); |
| | | cardScore[2]= cardPayAmount.divide(scoreSetting2).intValue(); |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | BusParameterSettings bonusBalanceConsumption = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.BONUS_BALANCE_CONSUMPTION, vipInfo.getCompanyId()); |
| | | if(giftPayAmount!=null |
| | | &&giftPayAmount.compareTo(BigDecimal.ZERO)>0 |
| | | &&StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue())){ |
| | | |
| | | BigDecimal scoreSetting0 = new BigDecimal(bonusBalanceConsumption.getParamValue()); |
| | | giftScore[0]= giftPayAmount.divide(scoreSetting0).intValue(); |
| | | |
| | | if(StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue1())){ |
| | | BigDecimal scoreSetting1 = new BigDecimal(bonusBalanceConsumption.getParamValue1()); |
| | | giftScore[1]= giftPayAmount.divide(scoreSetting1).intValue(); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue2())){ |
| | | BigDecimal scoreSetting2 = new BigDecimal(bonusBalanceConsumption.getParamValue2()); |
| | | 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]; |
| | | |
| | | |
| | | //添加自己的积分 |
| | | if(selfScore>0){ |
| | | scoreVipDetailService.addScore(null, |
| | | vipInfo.getId(), |
| | | pageOrder.getStaffId(), |
| | | pageOrder.getShopId(), |
| | | selfScore, |
| | | pageOrder.getId(), |
| | | ScoreVipDetail.SCORE_VIP_TYPE_CASH, |
| | | "消费奖励" |
| | | ); |
| | | } |
| | | |
| | | if(vipInfo.getRecommendId()!=null){ |
| | | //推荐注册老带新积分奖励 |
| | | SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); |
| | | if(parentScore>0){ |
| | | scoreVipDetailService.addScore(null, |
| | | referrerVip.getId(), |
| | | pageOrder.getStaffId(), |
| | | pageOrder.getShopId(), |
| | | parentScore, |
| | | pageOrder.getId(), |
| | | ScoreVipDetail.SCORE_VIP_TYPE_CASH, |
| | | "推荐消费奖励" |
| | | ); |
| | | } |
| | | //推荐注册二级带新积分奖励 |
| | | if(referrerVip.getRecommendId()!=null){ |
| | | SysVipInfo topVipInfo = sysVipInfoDao.selectById(referrerVip.getRecommendId()); |
| | | if(topParentScore>0){ |
| | | scoreVipDetailService.addScore(null, |
| | | topVipInfo.getId(), |
| | | pageOrder.getStaffId(), |
| | | pageOrder.getShopId(), |
| | | topParentScore, |
| | | pageOrder.getId(), |
| | | ScoreVipDetail.SCORE_VIP_TYPE_CASH, |
| | | "推荐消费奖励" |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | sourceOrder.setIsHasRefund(SysOrder.IS_HAS_REFUND_Y); |
| | | // sourceOrder.setStatu(Dictionary.ORDER_STATU_TK); |
| | | sysOrderDao.update(sourceOrder); |
| | | SysOrder oldOrder=sysOrderDao.selectById( sysOrder.getOldOrderId()); |
| | | |
| | | sysOrder.setId(null); |
| | | sysOrder.setStaffId(user.getSuId()); |
| | |
| | | addOrderFlow(sysOrder); |
| | | //退款退套餐退项目 |
| | | refundProjUse(sysOrder); |
| | | //删除积分 |
| | | scoreVipDetailService.removeByBusinessId(null,oldOrder.getVipId(), oldOrder.getId()); |
| | | |
| | | // 设置业绩 |
| | | achieveNewService.addAchaeveByOrder(sysOrder); |