| | |
| | | import com.matrix.system.common.dao.SysUsersDao; |
| | | import com.matrix.system.common.service.OperationLogService; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.enums.BooleanEnum; |
| | | import com.matrix.system.enums.OperationButtonEnum; |
| | | import com.matrix.system.enums.OperationFunctionEnum; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.dto.GoodsSealLimitDto; |
| | | import com.matrix.system.hive.dto.OrderItemDto; |
| | | import com.matrix.system.hive.dto.SysOrderItemDto; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.system.hive.plugin.util.MoneyUtil; |
| | | import com.matrix.system.hive.pojo.CzXkVo; |
| | |
| | | |
| | | @Autowired |
| | | private OperationLogService operationLogService; |
| | | |
| | | @Autowired |
| | | private SysVipInfoService sysVipInfoService; |
| | | |
| | | @Autowired |
| | | private SysOrderServiceHelper sysOrderServiceHelper; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateReceiptMoney(SysOrder pageOrder) throws GlobleException { |
| | | |
| | | if (!Dictionary.ORDER_STATU_DFK.equals(pageOrder.getStatu())) { |
| | | throw new GlobleException("该订单已经收过款,请刷新页面再试!"); |
| | | } |
| | | |
| | | |
| | | //校验订单是否满足收款条件 |
| | | checkOrder(pageOrder); |
| | | |
| | | |
| | | // 更新收款时间 |
| | | // 更新订单主表信息 |
| | | updateOrderInfo(pageOrder); |
| | | |
| | | // 获取用户信息 |
| | | SysVipInfo vipInfo = sysVipInfoDao.selectById(pageOrder.getVipId()); |
| | | if (SysVipInfo.UNDEAL_VIP == vipInfo.getIsDeal()) { |
| | | //非成交客户下单更新客户为成交客户 |
| | | vipInfo.setIsDeal(SysVipInfo.DEAL_VIP); |
| | | sysVipInfoDao.update(vipInfo); |
| | | } |
| | | // 设置用户为成交客户 |
| | | sysVipInfoService.updateDealStatus(pageOrder.getVipId(), BooleanEnum.TRUE.getValue()); |
| | | |
| | | //添加支付流水 |
| | | addOrderFlow(pageOrder); |
| | | sysOrderServiceHelper.addOrderFlow(pageOrder); |
| | | |
| | | // 设置会员充值卡使用情况 |
| | | addMoneyCardUse(pageOrder); |
| | |
| | | //设置会员积分 |
| | | addVipScore(pageOrder); |
| | | |
| | | |
| | | |
| | | //保存订单收款日志 |
| | | saveOrderSkLog(pageOrder); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存订单收款日志 |
| | | * @param pageOrder |
| | | */ |
| | | private void saveOrderSkLog(SysOrder pageOrder) { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | operationLogService.saveOperation(pageOrder.getCompanyId(), pageOrder.getShopId(), user.getSuId(), |
| | | OperationFunctionEnum.ORDER, |
| | | OperationButtonEnum.ORDER_SK, |
| | | pageOrder.getId(), |
| | | pageOrder.getOrderNo(), |
| | | pageOrder.getVipId()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 付款后更新订单信息 |
| | |
| | | |
| | | pageOrder.setCardPay(cardPayAmount.doubleValue()); |
| | | pageOrder.setCashPay(cashPayAmount.doubleValue()); |
| | | //欠款金额在流水处理中处理了 |
| | | |
| | | for (SysOrderFlow flow : pageOrder.getFlows()) { |
| | | //欠款处理 |
| | | if (SysOrderFlow.PAY_METHOD_ARREARS.equals(flow.getPayMethod())) { |
| | | pageOrder.setStatu(Dictionary.ORDER_STATU_QK); |
| | | pageOrder.setArrears(flow.getAmount().doubleValue()); |
| | | } |
| | | } |
| | | |
| | | double sum = flows.stream().mapToDouble(item -> item.getAmount().doubleValue()).sum(); |
| | | |
| | |
| | | |
| | | sysOrderDao.update(pageOrder); |
| | | |
| | | //保存单据日志 |
| | | operationLogService.saveOperation(pageOrder.getCompanyId(), pageOrder.getShopId(), user.getSuId(), |
| | | OperationFunctionEnum.ORDER, |
| | | OperationButtonEnum.ORDER_SK, |
| | | pageOrder.getId(), |
| | | pageOrder.getOrderNo(), |
| | | pageOrder.getVipId()); |
| | | |
| | | } |
| | | |
| | | private void checkOrder(SysOrder pageOrder) { |
| | | //检查交易限制调整 jyytodo 测试一下 |
| | | |
| | | SysOrder checkOrder = sysOrderDao.selectById(pageOrder.getId()); |
| | | |
| | | //状态校验 |
| | | if (!Dictionary.ORDER_STATU_DFK.equals(checkOrder.getStatu())) { |
| | | throw new GlobleException("该订单已经收过款,请刷新页面再试!"); |
| | | } |
| | | |
| | | //检查交易限制调整 |
| | | GoodsSealLimitDto goodsSealLimitDto = new GoodsSealLimitDto(); |
| | | goodsSealLimitDto.setVipId(pageOrder.getVipId()); |
| | | goodsSealLimitDto.setOrderItemDtoList(Lists.newArrayList()); |
| | | goodsSealLimitDto.setSysOrderItemDtoList(Lists.newArrayList()); |
| | | pageOrder.getItems().forEach(e->{ |
| | | goodsSealLimitDto.getOrderItemDtoList().add(BeanUtil.copyProperties(e, OrderItemDto.class)); |
| | | goodsSealLimitDto.getSysOrderItemDtoList().add(BeanUtil.copyProperties(e, SysOrderItemDto.class)); |
| | | }); |
| | | shoppingGoodsService.checkGoodsSealLimit(goodsSealLimitDto); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建支付流水 |
| | | * |
| | | * @author:姜友瑶 |
| | | */ |
| | | private void addOrderFlow(SysOrder sourceOrder) { |
| | | |
| | | |
| | | //处理支付流水 |
| | | int flowCount = 1; |
| | | for (SysOrderFlow flow : sourceOrder.getFlows()) { |
| | | //支付内容摘要设置 |
| | | Long goodsId = sourceOrder.getItems().get(0).getGoodsId(); |
| | | ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId); |
| | | flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品"); |
| | | // 若是退款,则取负数 |
| | | if (SysOrder.ORDER_TYPE_REFUND == sourceOrder.getOrderType()) { |
| | | flow.setFlowType(SysOrderFlow.FLOW_TYPE_REFUND); |
| | | flow.setAmount(flow.getAmount().negate()); |
| | | flow.setOrderId(sourceOrder.getOldOrderId()); |
| | | } else { |
| | | flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY); |
| | | flow.setOrderId(sourceOrder.getId()); |
| | | } |
| | | |
| | | //欠款处理 |
| | | if (SysOrderFlow.PAY_METHOD_ARREARS.equals(flow.getPayMethod())) { |
| | | sourceOrder.setStatu(Dictionary.ORDER_STATU_QK); |
| | | sourceOrder.setArrears(flow.getAmount().doubleValue()); |
| | | sysOrderDao.update(sourceOrder); |
| | | } |
| | | |
| | | //统计储值卡支付 |
| | | if (SysOrderFlow.PAY_METHOD_CARD.equals(flow.getPayMethod())) { |
| | | if (flow.getCardId() != null) { |
| | | MoneyCardUse moneyCardUse = moneyCardUseDao.selectById(flow.getCardId()); |
| | | //修改储值卡余额 |
| | | cardPaySk(moneyCardUse, sourceOrder, flow); |
| | | } else { |
| | | throw new GlobleException("无效的储值卡支付方式"); |
| | | } |
| | | } |
| | | |
| | | flow.setFlowNo(codeService.getFlowCode() + "-" + flowCount); |
| | | flow.setVipId(sourceOrder.getVipId()); |
| | | flow.setShopId(sourceOrder.getShopId()); |
| | | flow.setCompanyId(sourceOrder.getCompanyId()); |
| | | sysOrderFlowDao.insert(flow); |
| | | flowCount++; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | order.setFlows(czVo.getFlows()); |
| | | |
| | | addOrderFlow(order); |
| | | sysOrderServiceHelper.addOrderFlow(order); |
| | | |
| | | // 添加员工业绩 |
| | | achieveNewService.addAchaeveByOrder(order); |
| | |
| | | |
| | | |
| | | // 添加订单收款流水 |
| | | addOrderFlow(sysOrder); |
| | | sysOrderServiceHelper.addOrderFlow(sysOrder); |
| | | //退款退套餐退项目 |
| | | refundProjUse(sysOrder); |
| | | //删除积分 |