| | |
| | | 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; |
| | |
| | | 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 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 |
| | |
| | | @Autowired |
| | | BusParameterSettingsDao parameterSettingsDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | //发送微信公众号提醒 |
| | | 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); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * jyy 收款 |
| | | */ |
| | |
| | | throw new GlobleException("该订单已经收过款,请刷新页面再试!"); |
| | | } |
| | | |
| | | //检查交易限制调整 |
| | | checkSealLimit(pageOrder); |
| | | |
| | | checkOrder(pageOrder); |
| | | |
| | | |
| | | // 更新收款时间 |
| | |
| | | |
| | | //设置会员积分 |
| | | addVipScore(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() + "业绩金额与收款金额不一致"); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 设置会员消费积分 |
| | | * |
| | | * @param pageOrder |
| | | */ |
| | | private void addVipScore(SysOrder pageOrder) { |
| | |
| | | sysOrderFlowDao.insert(flow); |
| | | flowCount++; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | sourceOrder.setCashPay(sourceOrder.getCashPay()==null?0:sourceOrder.getCashPay() + cashPayTotal); |
| | | sysOrderDao.update(sourceOrder); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * 全是赠送金额,且配置了赠送金额购买计算为赠送 |
| | | * |
| | | * @param order |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 退款退项目,套餐,卡项 |
| | | * |
| | | * @param sysOrder |
| | | */ |
| | | private void refundProjUse(SysOrder sysOrder) { |