| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.app.dto.OrderListDto; |
| | | import com.matrix.system.app.mapper.SysProjUseMapper; |
| | | import com.matrix.system.app.vo.OrderDetailAchieveItemVo; |
| | | import com.matrix.system.app.vo.OrderDetailItemVo; |
| | | import com.matrix.system.app.vo.OrderDetailVo; |
| | |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.SysUsersDao; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.constance.SystemConstance; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.hievEnum.PayMethodEnum; |
| | | import com.matrix.system.hive.plugin.util.CollectionUtils; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.system.hive.plugin.util.MoneyUtil; |
| | | import com.matrix.system.hive.pojo.CzXkVo; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItem; |
| | | import com.matrix.system.hive.pojo.ShoppingCarItemsVo; |
| | | import com.matrix.system.hive.service.AchieveNewService; |
| | | import com.matrix.system.hive.service.CodeService; |
| | | import com.matrix.system.hive.service.ShoppingGoodsService; |
| | | import com.matrix.system.hive.service.SysOrderService; |
| | | import com.matrix.system.hive.service.*; |
| | | import com.matrix.system.shopXcx.mqTask.MQTaskRouting; |
| | | 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 java.util.*; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @date 2016-07-03 20:53 |
| | |
| | | @Autowired |
| | | private SysOrderFlowDao sysOrderFlowDao; |
| | | |
| | | @Autowired |
| | | private SysSupplierInfoDao sysSupplierInfoDao; |
| | | |
| | | @Autowired |
| | | private SysInstoreInfoDao sysInstoreInfoDao; |
| | | |
| | | @Autowired |
| | | private SysInstoreDetailDao sysInstoreDetailDao; |
| | | |
| | | @Autowired |
| | | private SysInstoreInfoService sysInstoreInfoService; |
| | | |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | @Autowired |
| | | private RabiitMqTemplate rabiitMqTemplate; |
| | | |
| | | |
| | | @Override |
| | | public int add(SysOrder sysOrder) { |
| | | return sysOrderDao.insert(sysOrder); |
| | |
| | | |
| | | @Override |
| | | public List<SysOrder> findInPage(SysOrder sysOrder, PaginationVO pageVo) { |
| | | if(pageVo!=null){ |
| | | if (pageVo != null) { |
| | | pageVo.setSort("desc"); |
| | | pageVo.setSort("orderTime"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public SysOrder checkAndSaveOrder(SysOrder sysOrder) { |
| | | // 收款改变订单状态 |
| | | |
| | | // 计算订单折扣金额,收款情况下 计算订单总额 |
| | | double zkTotal = 0.0; |
| | |
| | | |
| | | // 订单欠款减去支付金额 设置实际欠款 |
| | | Double itemZkTotal = MoneyUtil.mul(item.getZkPrice(), Double.valueOf(item.getCount())); |
| | | zkTotal=MoneyUtil.add(zkTotal, itemZkTotal); |
| | | zkTotal = MoneyUtil.add(zkTotal, itemZkTotal); |
| | | item.setStatus(orderStatus); |
| | | } |
| | | |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | sysOrder.setZkTotal(zkTotal); |
| | | sysOrder.setStatu(orderStatus); |
| | | sysOrder.setStaffId(user.getSuId()); |
| | | sysOrder.setCompanyId(user.getCompanyId()); |
| | | SysOrder source = null; |
| | | if (sysOrder.getId() != null) { |
| | | source = sysOrderDao.selectById(sysOrder.getId()); |
| | | } |
| | | sysOrder.setStaffId(source != null ? source.getStaffId() : user.getSuId()); |
| | | sysOrder.setCompanyId(source != null ? source.getCompanyId() : user.getCompanyId()); |
| | | |
| | | sysOrder.setPayTime(new Date()); |
| | | if(sysOrder.getId()==null){ |
| | | |
| | | if (sysOrder.getId() == null) { |
| | | //新增订单 |
| | | sysOrder.setOrderNo(codeService.getOrderCode()); |
| | | sysOrderDao.insert(sysOrder); |
| | | |
| | | }else{ |
| | | } else { |
| | | //更新订单 |
| | | sysOrderDao.update(sysOrder); |
| | | //删除原有订单明细 |
| | |
| | | |
| | | sysOrder.getItems().forEach(sysOrderItem -> { |
| | | sysOrderItem.setOrderId(sysOrder.getId()); |
| | | orderItemDao.insert(sysOrderItem); |
| | | if (sysOrder.getStatu().equals(Dictionary.ORDER_STATU_TK)) { |
| | | // 取负数 |
| | | sysOrderItem.setCount(-sysOrderItem.getCount()); |
| | | orderItemDao.insert(sysOrderItem); |
| | | // 调整回来 |
| | | sysOrderItem.setCount(-sysOrderItem.getCount()); |
| | | } else { |
| | | orderItemDao.insert(sysOrderItem); |
| | | } |
| | | |
| | | }); |
| | | |
| | | return sysOrder; |
| | |
| | | |
| | | /** |
| | | * 取消订单 |
| | | * 本方法无法退回多次不同卡项收款的订单 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | order.setStatu(Dictionary.ORDER_STATU_YQX); |
| | | order.setArrears(0D); |
| | | |
| | | //发送微信公众号提醒 |
| | | UniformMsgParam uniformMsgParam = new UniformMsgParam(order.getCompanyId(), UniformMsgParam.GZH_DDQX); |
| | | uniformMsgParam.put("orderId", order.getId()); |
| | | rabiitMqTemplate.sendMsg(MQTaskRouting.SEND_UNIFORM_TEMPLATE_MSG + evn, uniformMsgParam.toJSONString()); |
| | | |
| | | return sysOrderDao.update(order); |
| | | |
| | | } else { |
| | |
| | | throw new GlobleException("订单已取消"); |
| | | } |
| | | |
| | | List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(id); |
| | | List<SysOrderFlow> flows = sysOrderFlowDao.selectByOrderId(id); |
| | | // 非现金收款退回扣卡余额 |
| | | for (SysOrderFlow flow : flows) { |
| | | if (SysOrderFlow.PAY_METHOD_CARD.equals(flow.getPayMethod())) { |
| | | |
| | | for (SysOrderItem orderItem : sysOrderItems) { |
| | | |
| | | //非现金收款退回扣卡余额 |
| | | if (StringUtils.isNotBlank(orderItem.getPayMethodDetail())) { |
| | | |
| | | MoneyCardUse moneyCardUse = moneyCardUseDao.selectById(Long.parseLong(orderItem.getPayMethodDetail())); |
| | | MoneyCardUse moneyCardUse = moneyCardUseDao.selectById(flow.getCardId()); |
| | | MoneyCardUseFlow moneyCardUseFlow = new MoneyCardUseFlow(); |
| | | |
| | | if (moneyCardUse != null) { |
| | | |
| | | // 根据订单明细判断是赠送金额购买还是本金购买 |
| | | |
| | | moneyCardUseFlow.setTotal(orderItem.getCardPay()); |
| | | moneyCardUse.setRealMoney(MoneyUtil.add(moneyCardUse.getRealMoney(), orderItem.getCardPay())); |
| | | //TODO 目前无法退回到具体的赠送金额还是本金 |
| | | moneyCardUseFlow.setTotal(flow.getAmount().doubleValue()); |
| | | if (SysOrderFlow.IS_GIFT_Y.equals(flow.getIsGift())) { |
| | | moneyCardUse.setGiftMoney(MoneyUtil.add(moneyCardUse.getGiftMoney(), flow.getAmount().doubleValue())); |
| | | } else { |
| | | moneyCardUse.setRealMoney(MoneyUtil.add(moneyCardUse.getRealMoney(), flow.getAmount().doubleValue())); |
| | | } |
| | | |
| | | if (!moneyCardUse.getIsVipCar().equals(Dictionary.FLAG_YES_Y)) { |
| | | if(moneyCardUse.getLastCount()!=null) { |
| | | if (moneyCardUse.getLastCount() != null) { |
| | | moneyCardUse.setLastCount(moneyCardUse.getLastCount() + 1); |
| | | moneyCardUseFlow.setTimes(1); |
| | | } |
| | |
| | | moneyCardUseFlow.setCreateTime(new Date()); |
| | | moneyCardUseFlow.setOperationId(user.getSuId()); |
| | | moneyCardUseFlow.setContent(moneyCardUse.getChangeRemark()); |
| | | moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney()+moneyCardUse.getRealMoney()); |
| | | moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney() + moneyCardUse.getRealMoney()); |
| | | moneyCardUseFlowDao.insert(moneyCardUseFlow); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<SysOrderItem> sysOrderItems = orderItemDao.selectByOrderId(id); |
| | | for (SysOrderItem orderItem : sysOrderItems) { |
| | | // 充值卡类型退款 |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_CZK.equals(orderItem.getType())) { |
| | | |
| | | ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(orderItem.getGoodsId()); |
| | | |
| | | |
| | | //删除购买的充值卡 |
| | | moneyCardUseDao.deleteByOrderItemId(orderItem.getId()); |
| | | |
| | | } else if (Dictionary.SHOPPING_GOODS_TYPE_XM.equals(orderItem.getType()) |
| | | || Dictionary.SHOPPING_GOODS_TYPE_TC.equals(orderItem.getType())) { |
| | | // 项目套餐退款 |
| | | // 删除套餐项目使用情况 |
| | | sysProjUseDao.deleteByOrderItemId(orderItem.getId()); |
| | | |
| | | |
| | | } else if (Dictionary.SHOPPING_GOODS_TYPE_ZHK.equals(orderItem.getType())) { |
| | | // 综合卡 |
| | | // 删除套餐项目使用情况 |
| | | sysProjUseDao.deleteByOrderItemId(orderItem.getId()); |
| | | // 删除充值卡 |
| | | moneyCardUseDao.deleteByOrderItemId(orderItem.getId()); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | AchieveNew achieveNew = new AchieveNew(); |
| | | achieveNew.setOrderId(id); |
| | | achieveNewService.removeByModel(achieveNew); |
| | | |
| | | // 删除收款记录 |
| | | sysOrderFlowDao.deleteByOrderId(id); |
| | | |
| | | // 取消订单 |
| | | order.setStatu(Dictionary.ORDER_STATU_YQX); |
| | | return sysOrderDao.update(order); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // 设置订单总价与折后价 |
| | | order.setTotal(total); |
| | | order.setZkTotal(zkTotal); |
| | | order.setArrears(zkTotal); |
| | | sysOrderDao.update(order); |
| | | return i; |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateReceiptMoney(SysOrder pageOrder) throws GlobleException { |
| | | |
| | | |
| | | if (!Dictionary.ORDER_STATU_DFK.equals(pageOrder.getStatu())) { |
| | | throw new GlobleException("该订单已经收过款,请刷新页面再试!"); |
| | | } |
| | | // 更新收款时间 |
| | | pageOrder.setPayTime(new Date()); |
| | | pageOrder.setStatu(Dictionary.ORDER_STATU_YFK); |
| | | sysOrderDao.update(pageOrder); |
| | | |
| | | // 获取用户信息 |
| | | SysVipInfo vipInfo = sysVipInfoDao.selectById(pageOrder.getVipId()); |
| | |
| | | sysVipInfoDao.update(vipInfo); |
| | | } |
| | | |
| | | changeOrderStatu(pageOrder); |
| | | //添加支付流水 |
| | | addOrderFlow(pageOrder); |
| | | |
| | | // 设置会员充值卡使用情况 |
| | | addMoneyCardUse(pageOrder); |
| | | |
| | | // 新增出库单 |
| | | addOutStore(pageOrder); |
| | | |
| | | // 改变客户项目套餐使用情况 |
| | | addTaocanProj(pageOrder); |
| | | |
| | | // 新增出库单 |
| | | addOutStore(pageOrder); |
| | | |
| | | // 设置业绩 |
| | | achieveNewService.addAchaeveByOrder(pageOrder); |
| | | |
| | | setShopSelCount(pageOrder); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 收款改变订单状态,划扣金额 |
| | | * 创建支付流水 |
| | | * |
| | | * @author:姜友瑶 |
| | | */ |
| | | private void changeOrderStatu(SysOrder sourceOrder) { |
| | | int i = 1; |
| | | String orderStatus = Dictionary.ORDER_STATU_YFK; |
| | | double cashPayTotal = 0D; |
| | | double cardPayTotal = 0D; |
| | | private void addOrderFlow(SysOrder sourceOrder) { |
| | | |
| | | |
| | | //处理支付流水 |
| | | int flowCount = 1; |
| | | for (SysOrderFlow flow : sourceOrder.getFlows()) { |
| | | flow.setFlowNo(codeService.getFlowCode() + "-" + i); |
| | | //支付内容摘要设置 |
| | | Long goodsId = sourceOrder.getItems().get(0).getGoodsId(); |
| | | ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId); |
| | | flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品"); |
| | | |
| | | if (Dictionary.ORDER_STATU_TK.equals(sourceOrder.getStatu())) { |
| | | // 若是退款,则取负数 |
| | | 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()); |
| | | } |
| | | |
| | | flow.setVipId(sourceOrder.getVipId()); |
| | | flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY); |
| | | // 若使用储值卡付款 |
| | | //欠款处理 |
| | | 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); |
| | | cardPayTotal += flow.getAmount().doubleValue(); |
| | | }else{ |
| | | throw new GlobleException("无效的储值卡支付方式"); |
| | | } |
| | | } |
| | | |
| | | if (SysOrderFlow.PAY_METHOD_ARREARS.equals(flow.getPayMethod())) { |
| | | orderStatus = Dictionary.ORDER_STATU_QK; |
| | | sourceOrder.setArrears(flow.getAmount().doubleValue()); |
| | | } |
| | | |
| | | if (!SysOrderFlow.PAY_METHOD_ARREARS.equals(flow.getPayMethod()) && !SysOrderFlow.PAY_METHOD_CARD.equals(flow.getPayMethod())) { |
| | | cashPayTotal += flow.getAmount().doubleValue(); |
| | | } |
| | | flow.setFlowNo(codeService.getFlowCode() + "-" + flowCount); |
| | | flow.setVipId(sourceOrder.getVipId()); |
| | | flow.setShopId(sourceOrder.getShopId()); |
| | | flow.setCompanyId(sourceOrder.getCompanyId()); |
| | | sysOrderFlowDao.insert(flow); |
| | | i++; |
| | | flowCount++; |
| | | } |
| | | |
| | | if (Dictionary.ORDER_STATU_TK.equals(sourceOrder.getStatu())) { |
| | | orderStatus = Dictionary.ORDER_STATU_TK; |
| | | } |
| | | |
| | | // 更新收款状态 |
| | | sourceOrder.setStatu(orderStatus); |
| | | sourceOrder.setCardPay(cardPayTotal); |
| | | sourceOrder.setCashPay(cashPayTotal); |
| | | sysOrderDao.update(sourceOrder); |
| | | |
| | | } |
| | | |
| | |
| | | Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId()); |
| | | buyNum = (buyNum == null ? 0 : buyNum); |
| | | if ((buyNum + carItem.getCount()) > maxNum) { |
| | | |
| | | throw new GlobleException(shopGoods.getName() + "已超过最大销售数量,还剩【" + (maxNum - buyNum) + "】件"); |
| | | throw new GlobleException(shopGoods.getName() + "已超过最大销售数量"); |
| | | } |
| | | if ((buyNum + carItem.getCount()) == maxNum) { |
| | | if (!shopGoods.getStaus().equals(Dictionary.BUSINESS_STATE_DOWN)) { |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | MoneyCardUseFlow moneyCardUseFlow=new MoneyCardUseFlow(); |
| | | MoneyCardUseFlow moneyCardUseFlow = new MoneyCardUseFlow(); |
| | | if (SysOrderFlow.IS_GIFT_Y.equals(flow.getIsGift())) { |
| | | if(moneyCardUse.getGiftMoney() >= flow.getAmount().doubleValue()) { |
| | | if (moneyCardUse.getGiftMoney() >= flow.getAmount().doubleValue()) { |
| | | double surplus = MoneyUtil.sub(moneyCardUse.getGiftMoney(), flow.getAmount().doubleValue()); |
| | | moneyCardUse.setGiftMoney(surplus); |
| | | |
| | | moneyCardUseFlow.setGiftMoney(0D - flow.getAmount().doubleValue()); |
| | | } else { |
| | | throw new GlobleException(moneyCardUse.getCardName() + "余额不足"); |
| | | } |
| | | } else { |
| | | if(moneyCardUse.getRealMoney() >= flow.getAmount().doubleValue()) { |
| | | if (moneyCardUse.getRealMoney() >= flow.getAmount().doubleValue()) { |
| | | double surplus = MoneyUtil.sub(moneyCardUse.getRealMoney(), flow.getAmount().doubleValue()); |
| | | moneyCardUse.setRealMoney(surplus); |
| | | |
| | | moneyCardUseFlow.setTotal(0 - flow.getAmount().doubleValue()); |
| | | } else { |
| | | throw new GlobleException(moneyCardUse.getCardName() + "余额不足"); |
| | | } |
| | | } |
| | | |
| | | if (moneyCardUse.getIsVipCar().equals(Dictionary.FLAG_NO_N)) { |
| | | //余额为0时充值卡变为无效 |
| | | if (moneyCardUse.getRealMoney().equals(0D) && moneyCardUse.getGiftMoney().equals(0D)) { |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | } |
| | | } |
| | | |
| | | ShoppingGoods shoppingGoods = shoppingGoodsService.findById(moneyCardUse.getGoodsId()); |
| | | if (shoppingGoods != null) { |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(shoppingGoods, 2, moneyCardUse.getFailTime()); |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | } |
| | | // 更新充值卡信息 |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | //设置卡项使用流水 |
| | | moneyCardUseFlow.setCarUseId(moneyCardUse.getId()); |
| | | moneyCardUseFlow.setOrderNo(sourceOrder.getOrderNo()); |
| | |
| | | moneyCardUseFlow.setType(MoneyCardUseFlow.USE_TYPE_CONSUMER); |
| | | moneyCardUseFlow.setCreateTime(new Date()); |
| | | moneyCardUseFlow.setOperationId(user.getSuId()); |
| | | moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney()+moneyCardUse.getRealMoney()); |
| | | moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney() + moneyCardUse.getRealMoney()); |
| | | moneyCardUseFlowDao.insert(moneyCardUseFlow); |
| | | |
| | | // 达到使用次数后自动清空余额 |
| | | if (!moneyCardUse.getIsVipCar().equals(Dictionary.FLAG_YES_Y) |
| | | && moneyCardUse.getLastCount() <= 0) { |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setLastCount(0); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | } |
| | | if (moneyCardUse.getRealMoney().equals(0D) && moneyCardUse.getGiftMoney().equals(0D)) { |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | } |
| | | |
| | | ShoppingGoods shoppingGoods = shoppingGoodsService.findById(moneyCardUse.getGoodsId()); |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(shoppingGoods, 2, moneyCardUse.getFailTime()); |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | // 更新充值卡信息 |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | } |
| | | |
| | | /** |
| | |
| | | return true; |
| | | } else { |
| | | // 不是一卡通, |
| | | // 判断卡是否可应用于所有产品 |
| | | ShoppingGoods cardGoods = shoppingGoodsDao.selectById(moneyCardUse.getGoodsId()); |
| | | if (cardGoods != null) { |
| | | if (Dictionary.FLAG_YES.equals(cardGoods.getCarIsAll())) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | // 比较分类 |
| | | MoneyCardAssemble moneyCardAssemble = new MoneyCardAssemble(); |
| | | moneyCardAssemble.setCardId(moneyCardUse.getGoodsId()); |
| | |
| | | // 如果购买的是充值卡 |
| | | if (sysOrderItem.getType().equals(Dictionary.SHOPPING_GOODS_TYPE_CZK)) { |
| | | |
| | | ShoppingGoods moneyCar = shoppingGoodsDao.selectById(sysOrderItem.getGoodsId()); |
| | | MoneyCardUse moneyCardUse = new MoneyCardUse(); |
| | | moneyCardUse.setVipId(sourceOrder.getVipId()); |
| | | moneyCardUse.setGiftMoney(moneyCar.getReferencePice()); |
| | | moneyCardUse.setRealMoney(moneyCar.getSealPice()); |
| | | moneyCardUse.setGoodsId(moneyCar.getId()); |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_NO_N); |
| | | moneyCardUse.setOrderItemId(sysOrderItem.getId()); |
| | | moneyCardUse.setSource(Dictionary.TAOCAN_SOURCE_GM); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_YX); |
| | | moneyCardUse.setCardName(moneyCar.getName()); |
| | | |
| | | if (Dictionary.FLAG_YES.equals(moneyCar.getCarIsAll())) { |
| | | moneyCardUse.setIsVipCar(Dictionary.FLAG_YES_Y); |
| | | } else { |
| | | // 非会籍卡 |
| | | moneyCardUse.setIsVipCar(Dictionary.FLAG_NO_N); |
| | | } |
| | | |
| | | // 是否为赠送 |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_YES)) { |
| | | moneyCardUse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | } else { |
| | | for (int i = 0; i < sysOrderItem.getCount(); i++) { |
| | | ShoppingGoods moneyCar = shoppingGoodsDao.selectById(sysOrderItem.getGoodsId()); |
| | | MoneyCardUse moneyCardUse = new MoneyCardUse(); |
| | | moneyCardUse.setVipId(sourceOrder.getVipId()); |
| | | moneyCardUse.setGiftMoney(moneyCar.getReferencePice()); |
| | | moneyCardUse.setRealMoney(moneyCar.getSealPice()); |
| | | moneyCardUse.setGoodsId(moneyCar.getId()); |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_NO_N); |
| | | moneyCardUse.setOrderItemId(sysOrderItem.getId()); |
| | | moneyCardUse.setSource(Dictionary.TAOCAN_SOURCE_GM); |
| | | } |
| | | if (moneyCar.getCarUseCount() == null || moneyCar.getCarUseCount() == 0) { |
| | | moneyCardUse.setUseTotal(999999999); |
| | | moneyCardUse.setLastCount(999999999); |
| | | } else { |
| | | moneyCardUse.setUseTotal(moneyCar.getCarUseCount()); |
| | | moneyCardUse.setLastCount(moneyCar.getCarUseCount()); |
| | | } |
| | | moneyCardUse.setVipId(sourceOrder.getVipId()); |
| | | // if (moneyCar.getValidity() == null || moneyCar.getValidity() == 0) { |
| | | // // 设置失效时间 |
| | | // Calendar cal = Calendar.getInstance(); |
| | | // cal.set(2200, 1, 1); |
| | | // moneyCardUse.setFailTime(cal.getTime()); |
| | | // } else { |
| | | // moneyCardUse.setFailTime(DateUtil.nextNDate(new Date(), 30 * moneyCar.getValidity())); |
| | | // } |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null); |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_YX); |
| | | moneyCardUse.setCardName(moneyCar.getName()); |
| | | moneyCardUse.setIsVipCar(Dictionary.FLAG_NO_N); |
| | | moneyCardUse.setVipId(sourceOrder.getVipId()); |
| | | |
| | | moneyCardUseDao.insert(moneyCardUse); |
| | | // 是否为赠送 |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_YES)) { |
| | | moneyCardUse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | } else { |
| | | moneyCardUse.setSource(Dictionary.TAOCAN_SOURCE_GM); |
| | | } |
| | | //余次处理 |
| | | if (moneyCar.getCarUseCount() == null || moneyCar.getCarUseCount() == 0) { |
| | | moneyCardUse.setUseTotal(999999999); |
| | | moneyCardUse.setLastCount(999999999); |
| | | } else { |
| | | moneyCardUse.setUseTotal(moneyCar.getCarUseCount()); |
| | | moneyCardUse.setLastCount(moneyCar.getCarUseCount()); |
| | | } |
| | | //失效时间处理 |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null); |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | |
| | | moneyCardUseDao.insert(moneyCardUse); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | refundTotal += flow.getAmount().doubleValue(); |
| | | flow.setShopId(sourceOrder.getShopId()); |
| | | flow.setCompanyId(sourceOrder.getCompanyId()); |
| | | sysOrderFlowDao.insert(flow); |
| | | i++; |
| | | } |
| | | |
| | | boolean haQk=false; |
| | | boolean haQk = false; |
| | | |
| | | if (refundTotal == pageOrder.getArrears()) { |
| | | haQk = true; |
| | | } |
| | | |
| | | //更新收款状态 |
| | | if(haQk){ |
| | | if (haQk) { |
| | | sourceOrder.setStatu(Dictionary.ORDER_STATU_YFK); |
| | | }else{ |
| | | } else { |
| | | sourceOrder.setStatu(Dictionary.ORDER_STATU_QK); |
| | | } |
| | | |
| | |
| | | ShoppingGoods sysGoods = shoppingGoodsDao.selectById(outStoreItem.getSkuId()); |
| | | if (sysGoods != null) { |
| | | throw new GlobleException("出库失败:【" + sysGoods.getName() + "库存不足】"); |
| | | |
| | | } else { |
| | | throw new GlobleException("出库失败没有找到出库产品"); |
| | | } |
| | |
| | | //综合卡中包含的项目 |
| | | List<ShoppingGoodsAssemble> assembleList = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_XM); |
| | | assembleList.forEach(item -> { |
| | | createProjuseByAssemble(order, sysOrderItem, item, null); |
| | | //TODO 补综合卡逻辑 |
| | | createProjuseByAssemble(order, sysOrderItem, item, null, null); |
| | | }); |
| | | |
| | | //处理综合卡中包含的套餐 |
| | |
| | | * 通过组合关系创建用户项目余次 |
| | | */ |
| | | private SysProjUse createProjuseByAssemble(SysOrder order, SysOrderItem sysOrderItem, |
| | | ShoppingGoodsAssemble goodsAssemble, Long taocanId) { |
| | | ShoppingGoodsAssemble goodsAssemble, Long taocanId, Date failTime) { |
| | | //计算折扣 |
| | | Double zk=sysOrderItem.getZkPrice()/sysOrderItem.getPrice(); |
| | | Double zk = sysOrderItem.getZkPrice() / sysOrderItem.getPrice(); |
| | | |
| | | SysProjUse puse = new SysProjUse(); |
| | | puse.setIsOver(Dictionary.DELETED_N); |
| | |
| | | puse.setTaocanId(taocanId); |
| | | puse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); |
| | | if (taocanId == null) { |
| | | puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() * zk ); |
| | | puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() * zk); |
| | | } else { |
| | | puse.setPrice(goodsAssemble.getPrice() * zk ); |
| | | puse.setPrice(goodsAssemble.getPrice() * zk); |
| | | } |
| | | puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount()))); |
| | | // 赠送和打折后金额为0的都视为赠送项目 |
| | |
| | | } else { |
| | | puse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | } |
| | | // 设置失效时间 |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.set(2200, 1, 1); |
| | | puse.setFailTime(cal.getTime()); |
| | | puse.setFailTime(failTime); |
| | | sysProjUseDao.insert(puse); |
| | | return puse; |
| | | } |
| | |
| | | taocanProjUse.setFailTime(invalidTime); |
| | | sysProjUseDao.insert(taocanProjUse); |
| | | //计划次数 |
| | | int surplusCount=0; |
| | | int surplusCount = 0; |
| | | //总余额 |
| | | Double sumBanance = 0D; |
| | | //创建套餐绑定的项目 |
| | | List<ShoppingGoodsAssemble> assembleList = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(projId, ShoppingGoods.SHOPPING_GOODS_TYPE_XM); |
| | | for (ShoppingGoodsAssemble assemble : assembleList) { |
| | | SysProjUse tempUse = createProjuseByAssemble(order, sysOrderItem, assemble, taocanProjUse.getId()); |
| | | SysProjUse tempUse = createProjuseByAssemble(order, sysOrderItem, assemble, taocanProjUse.getId(),taocanProjUse.getFailTime()); |
| | | sumBanance += tempUse.getBalance(); |
| | | surplusCount+=tempUse.getSurplusCount(); |
| | | surplusCount += tempUse.getSurplusCount(); |
| | | } |
| | | if(Dictionary.FLAG_NO_N.equals(taocanShoppingGoods.getIsCourse())){ |
| | | if (Dictionary.FLAG_NO_N.equals(taocanShoppingGoods.getIsCourse())) { |
| | | //固定套餐,剩余次数等于绑定项目的次数 |
| | | taocanProjUse.setSurplusCount(surplusCount); |
| | | }else{ |
| | | } else { |
| | | //任选套餐剩余次数等于最大使用次数 |
| | | taocanProjUse.setSurplusCount(taocanShoppingGoods.getCarUseCount()); |
| | | } |
| | |
| | | puse.setVipId(order.getVipId()); |
| | | puse.setStatus(Dictionary.TAOCAN_STATUS_YX); |
| | | puse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); |
| | | puse.setBalance(MoneyUtil.add(sysOrderItem.getCardPay(), sysOrderItem.getCashPay())); |
| | | puse.setBalance(sysOrderItem.getZkPrice()); |
| | | puse.setPrice(sysOrderItem.getZkPrice()); |
| | | puse.setProjName(sysOrderItem.getShoppingGoods().getName()); |
| | | // 赠送和打折后金额为0的都视为赠送项目 |
| | |
| | | |
| | | /** |
| | | * 会员卡充值 |
| | | * |
| | | * @param czVo |
| | | */ |
| | | @Override |
| | |
| | | public SysOrder updateAddCardMoney(CzXkVo czVo) { |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | SysVipInfo vip = (SysVipInfo) WebUtil.getSession().getAttribute(SystemConstance.CURRENT_CUSTOMER); |
| | | czVo.setVipId(vip.getId()); |
| | | // SysVipInfo vip = (SysVipInfo) WebUtil.getSession().getAttribute(SystemConstance.CURRENT_CUSTOMER); |
| | | // czVo.setVipId(vip.getId()); |
| | | |
| | | //更新会员会员卡金额 |
| | | MoneyCardUse cardUser = moneyCardUseDao.selectVipCard(vip.getId()); |
| | | MoneyCardUse cardUser = moneyCardUseDao.selectVipCard(czVo.getVipId()); |
| | | cardUser.setRealMoney(MoneyUtil.add(cardUser.getRealMoney(), czVo.getBjmoney())); |
| | | cardUser.setGiftMoney(MoneyUtil.add(cardUser.getGiftMoney(), czVo.getGiftMoney())); |
| | | moneyCardUseDao.update(cardUser); |
| | |
| | | order.setStaffId(user.getSuId()); |
| | | order.setIsCross(2 + ""); |
| | | order.setStatu(Dictionary.ORDER_STATU_YFK); |
| | | order.setCompanyId(user.getCompanyId()); |
| | | sysOrderDao.insert(order); |
| | | |
| | | SysOrderItem orderItem = new SysOrderItem(); |
| | | orderItem.setOrderId(order.getId()); |
| | | orderItem.setOrderNo(order.getOrderNo()); |
| | | orderItem.setArrears(0D); |
| | | ShoppingGoods shoppingGoods= shoppingGoodsDao.selectVipCzGoods(); |
| | | ShoppingGoods shoppingGoods = shoppingGoodsDao.selectVipCzGoods(); |
| | | orderItem.setGoodsId(shoppingGoods.getId()); |
| | | orderItem.setPayMethod(Dictionary.PAY_TYPE_MOENY); |
| | | orderItem.setCashPay(czVo.getBjmoney()); |
| | |
| | | orderItem.setIsFree(Dictionary.FLAG_NO); |
| | | orderItem.setPrice(czVo.getBjmoney()); |
| | | orderItem.setStatus(Dictionary.ORDER_STATU_YFK); |
| | | orderItem.setAchaeveList(czVo.getAchaeveList()); |
| | | orderItem.setAchieveList(czVo.getAchaeveList()); |
| | | orderItemDao.insert(orderItem); |
| | | List<SysOrderItem> items = new ArrayList<>(); |
| | | items.add(orderItem); |
| | | order.setItems(items); |
| | | |
| | | |
| | | //设置卡项使用流水 |
| | | MoneyCardUseFlow moneyCardUseFlow=new MoneyCardUseFlow(); |
| | | MoneyCardUseFlow moneyCardUseFlow = new MoneyCardUseFlow(); |
| | | moneyCardUseFlow.setTotal(czVo.getBjmoney()); |
| | | moneyCardUseFlow.setGiftMoney(czVo.getGiftMoney()); |
| | | moneyCardUseFlow.setCarUseId(czVo.getCardId()); |
| | |
| | | moneyCardUseFlow.setOrderNo(order.getOrderNo()); |
| | | moneyCardUseFlow.setCreateTime(new Date()); |
| | | moneyCardUseFlow.setOperationId(user.getSuId()); |
| | | moneyCardUseFlow.setBalance(cardUser.getGiftMoney()+cardUser.getRealMoney()); |
| | | moneyCardUseFlow.setBalance(cardUser.getGiftMoney() + cardUser.getRealMoney()); |
| | | moneyCardUseFlowDao.insert(moneyCardUseFlow); |
| | | |
| | | |
| | | order.setFlows(czVo.getFlows()); |
| | | addOrderFlow(order); |
| | | // 添加员工业绩 |
| | | achieveNewService.addAchaeveByOrder(order); |
| | | return order; |
| | |
| | | return sysOrderDao.selectShopAchieveRanking(sysOrder); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public List<RankingVo> findStaffSaleAchieveRanking(SysOrder sysOrder) { |
| | | return sysOrderDao.selectStaffSaleAchieveRanking(sysOrder); |
| | | public void refundOrderMoney(SysOrder sysOrder) { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | //原订单设置为退款状态 |
| | | 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.setId(null); |
| | | sysOrder.setStaffId(user.getSuId()); |
| | | sysOrder.setCompanyId(user.getCompanyId()); |
| | | sysOrder.setShopId(user.getShopId()); |
| | | sysOrder.setOrderType(SysOrder.ORDER_TYPE_REFUND); |
| | | sysOrder.setStatu(Dictionary.ORDER_STATU_YFK); |
| | | Date now = new Date(); |
| | | sysOrder.setOrderTime(now); |
| | | sysOrder.setPayTime(now); |
| | | sysOrder.setOrderNo(codeService.getRefundOrderNo()); |
| | | sysOrder.setZkTotal(-sysOrder.getZkTotal()); |
| | | sysOrder.setOrderType(SysOrder.ORDER_TYPE_REFUND); |
| | | //新增订单 |
| | | sysOrderDao.insert(sysOrder); |
| | | //插入明细 |
| | | for (SysOrderItem item : sysOrder.getItems()) { |
| | | |
| | | //更新原订单明细的可退数量 |
| | | SysOrderItem oldItem=new SysOrderItem(); |
| | | oldItem.setId(item.getId()); |
| | | oldItem.setRefundCount(item.getCount()); |
| | | orderItemDao.update(oldItem); |
| | | |
| | | //插入新的订单明细 |
| | | item.setId(null); |
| | | item.setCount(-item.getCount()); |
| | | item.setOrderId(sysOrder.getId()); |
| | | orderItemDao.insert(item); |
| | | } |
| | | |
| | | |
| | | // 添加订单收款流水 |
| | | addOrderFlow(sysOrder); |
| | | //退款退套餐退项目 |
| | | refundProjUse(sysOrder); |
| | | |
| | | // 设置业绩 |
| | | achieveNewService.addAchaeveByOrder(sysOrder); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void refundOrderMoney(SysOrder pageOrder) { |
| | | /** |
| | | * 退款退项目,套餐,卡项 |
| | | * @param sysOrder |
| | | */ |
| | | private void refundProjUse(SysOrder sysOrder) { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | // 插入订单流水 |
| | | changeOrderStatu(pageOrder); |
| | | //记录需要退库存的产品 |
| | | List<SysOrderItem> returnGoodsList = new ArrayList<>(); |
| | | |
| | | for (SysOrderItem item : pageOrder.getItems()) { |
| | | for (SysOrderItem item : sysOrder.getItems()) { |
| | | |
| | | SysProjUse queryProjUse = new SysProjUse(); |
| | | queryProjUse.setIsOver(Dictionary.FLAG_NO_N); |
| | | queryProjUse.setStatus(Dictionary.TAOCAN_STATUS_YX); |
| | | queryProjUse.setOrderItemId(item.getId()); |
| | | queryProjUse.setOrderItemId(item.getOldItemId()); |
| | | // 修改项目信息 |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_XM.equals(item.getType()) && Dictionary.SHOPPING_GOODS_TYPE_JJCP.equals(item.getType())) { |
| | | SysProjUse sysProjUse = sysProjUseDao.selectByModel(queryProjUse).get(0); |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_XM.equals(item.getType()) || Dictionary.SHOPPING_GOODS_TYPE_JJCP.equals(item.getType())) { |
| | | |
| | | int sub = sysProjUse.getSurplusCount() - item.getCount(); |
| | | sysProjUse.setSurplusCount(sub); |
| | | if (sub <= 0) { |
| | | sysProjUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | sysProjUse.setStatus(Dictionary.TAOCAN_STATUS_WX); |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_JJCP.equals(item.getType())) { |
| | | if (Dictionary.FLAG_YES_Y.equals(item.getIsReturnStore())) { |
| | | returnGoodsList.add(item); |
| | | } |
| | | } else { |
| | | SysProjUse sysProjUse = sysProjUseDao.selectByModel(queryProjUse).get(0); |
| | | |
| | | int sub = sysProjUse.getSurplusCount() - item.getCount(); |
| | | if (sub < 0) { |
| | | throw new GlobleException("项目余次不足"); |
| | | }else if(sub==0){ |
| | | sysProjUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | sysProjUse.setStatus(Dictionary.TAOCAN_STATUS_WX); |
| | | } |
| | | sysProjUse.setSurplusCount(sub); |
| | | sysProjUseDao.update(sysProjUse); |
| | | SysProjUseFlow sysProjUseFlow = SysProjUseMapper.INSTANCE.projUseToFlow(sysProjUse); |
| | | sysProjUseFlow.setOptionType("退款修改"); |
| | | sysProjUseFlow.setId(null); |
| | | sysProjUseFlow.setUpdateBy(user.getSuName()); |
| | | sysProjUseFlow.setCreateBy(user.getSuName()); |
| | | sysProjUseDao.insertFlow(sysProjUseFlow); |
| | | } |
| | | sysProjUseDao.update(sysProjUse); |
| | | } |
| | | |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_TC.equals(item.getType())) { |
| | | queryProjUse.setTaocanId(-1L); |
| | | SysProjUse sysProjUse = sysProjUseDao.selectByModel(queryProjUse).get(0); |
| | | sysProjUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | sysProjUse.setStatus(Dictionary.TAOCAN_STATUS_WX); |
| | | List<SysProjUse> sysProjUses = sysProjUseDao.selectByModel(queryProjUse); |
| | | |
| | | sysProjUseDao.update(sysProjUse); |
| | | |
| | | for (int i = 0; i < item.getCount(); i++) { |
| | | |
| | | SysProjUse sysProjUse = sysProjUses.get(i); |
| | | sysProjUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | sysProjUse.setStatus(Dictionary.TAOCAN_STATUS_WX); |
| | | sysProjUseDao.update(sysProjUse); |
| | | SysProjUseFlow sysProjUseFlow = SysProjUseMapper.INSTANCE.projUseToFlow(sysProjUse); |
| | | sysProjUseFlow.setOptionType("退款修改"); |
| | | sysProjUseFlow.setId(null); |
| | | sysProjUseFlow.setUpdateBy(user.getSuName()); |
| | | sysProjUseFlow.setCreateBy(user.getSuName()); |
| | | sysProjUseDao.insertFlow(sysProjUseFlow); |
| | | } |
| | | } |
| | | |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_CZK.equals(item.getType())) { |
| | | MoneyCardUse queryCardUse = new MoneyCardUse(); |
| | | queryCardUse.setIsOver(Dictionary.FLAG_NO_N); |
| | | queryCardUse.setStatus(Dictionary.TAOCAN_STATUS_YX); |
| | | queryCardUse.setOrderItemId(item.getId()); |
| | | queryCardUse.setOrderItemId(item.getOldItemId()); |
| | | |
| | | MoneyCardUse moneyCardUse = moneyCardUseDao.selectByModel(queryCardUse).get(0); |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | List<MoneyCardUse> moneyCardUses = moneyCardUseDao.selectByModel(queryCardUse); |
| | | for (int i = 0; i < item.getCount(); i++) { |
| | | MoneyCardUse moneyCardUse = moneyCardUses.get(i); |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | } |
| | | } |
| | | |
| | | // TODO 综合卡退款 |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | ShoppingGoods goods = shoppingGoodsDao.selectById(item.getGoodsId()); |
| | | goods.setRealSealCount(goods.getRealSealCount() - item.getCount()); |
| | | shoppingGoodsDao.update(goods); |
| | | } |
| | | |
| | | // 设置会员充值卡使用情况 |
| | | addMoneyCardUse(pageOrder); |
| | | // 家居产品退库存 |
| | | if (CollectionUtils.isNotEmpty(returnGoodsList)) { |
| | | refundInstore(returnGoodsList); |
| | | } |
| | | } |
| | | |
| | | // 新增出库单 |
| | | addOutStore(pageOrder); |
| | | /** |
| | | * 退款入库 |
| | | */ |
| | | private void refundInstore(@NotEmpty List<SysOrderItem> items) { |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | SysSupplierInfo supplierInfo = new SysSupplierInfo(); |
| | | supplierInfo.setShopId(user.getShopId()); |
| | | supplierInfo = sysSupplierInfoDao.selectByModel(supplierInfo).get(0); |
| | | |
| | | // 改变客户项目套餐使用情况 |
| | | addTaocanProj(pageOrder); |
| | | Warehouse warehouse = warehouseDao.findShopWarehouse(user.getShopId()).get(0); |
| | | SysInstoreInfo instoreInfo = new SysInstoreInfo(); |
| | | instoreInfo.setInstoreType(SysInstoreInfo.INSTORE_TYPE_RETURN); |
| | | instoreInfo.setInstoreDate(new Date()); |
| | | instoreInfo.setSupplierId(supplierInfo.getId().toString()); |
| | | instoreInfo.setStoreId(warehouse.getId()); |
| | | instoreInfo.setCheckStatus(Dictionary.CHECK_STATUS_DSH); |
| | | // 设置入库单编号 |
| | | instoreInfo.setInstoreId(DateUtil.getTimeMark()); |
| | | instoreInfo.setShopId(user.getShopId()); |
| | | instoreInfo.setCompanyId(user.getCompanyId()); |
| | | sysInstoreInfoDao.insert(instoreInfo); |
| | | |
| | | // 设置业绩 |
| | | achieveNewService.addAchaeveByOrder(pageOrder); |
| | | Double total = 0.0; |
| | | List<SysInstoreDetail> instoreDetails = new ArrayList<>(); |
| | | for (SysOrderItem item : items) { |
| | | ShoppingGoods goods = shoppingGoodsDao.selectById(item.getGoodsId()); |
| | | SysInstoreDetail sysInstoreDetail = new SysInstoreDetail(); |
| | | sysInstoreDetail.setAmount(item.getCount().doubleValue()); |
| | | sysInstoreDetail.setPrice(item.getZkPrice()); |
| | | sysInstoreDetail.setSkuId(goods.getId()); |
| | | |
| | | setShopSelCount(pageOrder); |
| | | total = MoneyUtil.add(MoneyUtil.mul(Double.parseDouble(sysInstoreDetail.getAmount() + ""), sysInstoreDetail.getPrice()), total); |
| | | sysInstoreDetail.setInstoreId(instoreInfo.getId()); |
| | | // 设置小计 |
| | | sysInstoreDetail.setPriceTotal(MoneyUtil.mul(Double.parseDouble(sysInstoreDetail.getAmount() + ""), sysInstoreDetail.getPrice())); |
| | | instoreDetails.add(sysInstoreDetail); |
| | | |
| | | } |
| | | instoreInfo.setSumall(total); |
| | | sysInstoreInfoDao.update(instoreInfo); |
| | | sysInstoreDetailDao.batchInsert(instoreDetails); |
| | | |
| | | sysInstoreInfoService.check(instoreInfo); |
| | | } |
| | | } |