| | |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.app.dto.OrderListDto; |
| | |
| | | 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.constance.AppConstance; |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.SysUsersDao; |
| | | import com.matrix.system.constance.Dictionary; |
| | |
| | | @Autowired |
| | | private SysInstoreInfoService sysInstoreInfoService; |
| | | |
| | | @Autowired |
| | | BusParameterSettingsDao parameterSettingsDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | |
| | | sysOrderFlowDao.deleteByOrderId(id); |
| | | |
| | | //删除积分 |
| | | scoreVipDetailService.removeByBusinessId(null,order.getVipId(), order.getId()); |
| | | scoreVipDetailService.removeByBusinessId(order.getVipId(), order.getId()); |
| | | |
| | | // 取消订单 |
| | | order.setStatu(Dictionary.ORDER_STATU_YQX); |
| | |
| | | |
| | | //添加自己的积分 |
| | | if(selfScore>0){ |
| | | scoreVipDetailService.addScore(null, |
| | | scoreVipDetailService.addScore( |
| | | vipInfo.getId(), |
| | | pageOrder.getStaffId(), |
| | | pageOrder.getShopId(), |
| | |
| | | //推荐注册老带新积分奖励 |
| | | SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); |
| | | if(parentScore>0){ |
| | | scoreVipDetailService.addScore(null, |
| | | scoreVipDetailService.addScore( |
| | | referrerVip.getId(), |
| | | pageOrder.getStaffId(), |
| | | pageOrder.getShopId(), |
| | |
| | | if(referrerVip.getRecommendId()!=null){ |
| | | SysVipInfo topVipInfo = sysVipInfoDao.selectById(referrerVip.getRecommendId()); |
| | | if(topParentScore>0){ |
| | | scoreVipDetailService.addScore(null, |
| | | scoreVipDetailService.addScore( |
| | | topVipInfo.getId(), |
| | | pageOrder.getStaffId(), |
| | | pageOrder.getShopId(), |
| | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | BusParameterSettingsDao parameterSettingsDao; |
| | | |
| | | /** |
| | | * @param order 新增出库单并更新本店库存 |
| | |
| | | @Override |
| | | public void addOutStore(SysOrder order) { |
| | | |
| | | List<SysOutStoreItem> storeItemList = new ArrayList<>(); |
| | | BusParameterSettings manageStockSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WAREHOUSE_MANAGE_STOCK, order.getCompanyId()); |
| | | if(AppConstance.IS_Y.equals(manageStockSetting.getParamValue())){ |
| | | |
| | | for (SysOrderItem sysOrderItem : order.getItems()) { |
| | | List<SysOutStoreItem> storeItemList = new ArrayList<>(); |
| | | |
| | | if (ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP.equals(sysOrderItem.getType())) { |
| | | for (SysOrderItem sysOrderItem : order.getItems()) { |
| | | |
| | | SysOutStoreItem storeItem = new SysOutStoreItem(); |
| | | storeItem.setSkuId(sysOrderItem.getGoodsId()); |
| | | storeItem.setAmount(Double.valueOf(sysOrderItem.getCount())); |
| | | storeItemList.add(storeItem); |
| | | if (ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP.equals(sysOrderItem.getType())) { |
| | | |
| | | } else if (ShoppingGoods.SHOPPING_GOODS_TYPE_TC.equals(sysOrderItem.getType()) |
| | | SysOutStoreItem storeItem = new SysOutStoreItem(); |
| | | storeItem.setSkuId(sysOrderItem.getGoodsId()); |
| | | storeItem.setAmount(Double.valueOf(sysOrderItem.getCount())); |
| | | storeItemList.add(storeItem); |
| | | |
| | | || ShoppingGoods.SHOPPING_GOODS_TYPE_ZHK.equals(sysOrderItem.getType())) { |
| | | } else if (ShoppingGoods.SHOPPING_GOODS_TYPE_TC.equals(sysOrderItem.getType()) |
| | | |
| | | List<ShoppingGoodsAssemble> goodsList = new ArrayList<>(); |
| | | || ShoppingGoods.SHOPPING_GOODS_TYPE_ZHK.equals(sysOrderItem.getType())) { |
| | | |
| | | goodsList.addAll(shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP)); |
| | | List<ShoppingGoodsAssemble> goodsList = new ArrayList<>(); |
| | | |
| | | if (ShoppingGoods.SHOPPING_GOODS_TYPE_ZHK.equals(sysOrderItem.getType())) { |
| | | //综合卡处理,中的套餐,中的家居产品 |
| | | List<ShoppingGoodsAssemble> zhkAssemble = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_TC); |
| | | zhkAssemble.forEach(item -> { |
| | | goodsList.addAll(shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(item.getAssembleGoodId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP)); |
| | | goodsList.addAll(shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP)); |
| | | |
| | | if (ShoppingGoods.SHOPPING_GOODS_TYPE_ZHK.equals(sysOrderItem.getType())) { |
| | | //综合卡处理,中的套餐,中的家居产品 |
| | | List<ShoppingGoodsAssemble> zhkAssemble = shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(sysOrderItem.getGoodsId(), ShoppingGoods.SHOPPING_GOODS_TYPE_TC); |
| | | zhkAssemble.forEach(item -> { |
| | | goodsList.addAll(shoppingGoodsAssembleDao.selectGoodsByShoppingGoodsIdAndType(item.getAssembleGoodId(), ShoppingGoods.SHOPPING_GOODS_TYPE_JJCP)); |
| | | }); |
| | | } |
| | | |
| | | goodsList.forEach(item -> { |
| | | SysOutStoreItem storeItem = new SysOutStoreItem(); |
| | | storeItem.setSkuId(item.getAssembleGoodId()); |
| | | storeItem.setAmount(Double.valueOf(item.getTotal())); |
| | | storeItemList.add(storeItem); |
| | | }); |
| | | } |
| | | |
| | | goodsList.forEach(item -> { |
| | | SysOutStoreItem storeItem = new SysOutStoreItem(); |
| | | storeItem.setSkuId(item.getAssembleGoodId()); |
| | | storeItem.setAmount(Double.valueOf(item.getTotal())); |
| | | storeItemList.add(storeItem); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(storeItemList)) { |
| | | Long warehouseId = warehouseDao.findShopWarehouse(order.getShopId()).get(0).getId(); |
| | | SysOutStore outStore = new SysOutStore(); |
| | | outStore.setOutStoreNo(codeService.getOutStoreCode()); |
| | | outStore.setOrderId(order.getId()); |
| | | outStore.setShopId(order.getShopId()); |
| | | outStore.setShopId(order.getShopId()); |
| | | outStore.setStaffId(order.getStaffId()); |
| | | outStore.setType(Dictionary.OUT_STORE_JJCPCK); |
| | | outStore.setServiceNo(order.getOrderNo()); |
| | | outStore.setTime(new Date()); |
| | | outStore.setCheckStatus(Dictionary.CHECK_STATUS_DSH); |
| | | outStore.setCompanyId(order.getCompanyId()); |
| | | sysOutStoreDao.insert(outStore); |
| | | if (CollectionUtils.isNotEmpty(storeItemList)) { |
| | | Long warehouseId = warehouseDao.findShopWarehouse(order.getShopId()).get(0).getId(); |
| | | SysOutStore outStore = new SysOutStore(); |
| | | outStore.setOutStoreNo(codeService.getOutStoreCode()); |
| | | outStore.setOrderId(order.getId()); |
| | | outStore.setShopId(order.getShopId()); |
| | | outStore.setShopId(order.getShopId()); |
| | | outStore.setStaffId(order.getStaffId()); |
| | | outStore.setType(Dictionary.OUT_STORE_JJCPCK); |
| | | outStore.setServiceNo(order.getOrderNo()); |
| | | outStore.setTime(new Date()); |
| | | outStore.setCheckStatus(Dictionary.CHECK_STATUS_DSH); |
| | | outStore.setCompanyId(order.getCompanyId()); |
| | | sysOutStoreDao.insert(outStore); |
| | | |
| | | //出库明细,根据批次维度定义 |
| | | List<SysOutStoreItem> realOutStoreItemList = new ArrayList<>(); |
| | | //出库明细,根据批次维度定义 |
| | | List<SysOutStoreItem> realOutStoreItemList = new ArrayList<>(); |
| | | |
| | | storeItemList.forEach(outStoreItem -> { |
| | | storeItemList.forEach(outStoreItem -> { |
| | | |
| | | //设置出库主键 |
| | | outStoreItem.setOutStoreId(outStore.getId()); |
| | | //设置出库主键 |
| | | outStoreItem.setOutStoreId(outStore.getId()); |
| | | |
| | | //计算库存总数是否满足本次扣减的需求 |
| | | List<SysStoreInfo> stores = storeInfoDao.selectStoInfoBySku(outStoreItem.getSkuId(), warehouseId); |
| | | double sum = stores.stream().mapToDouble(item -> item.getStoreTotal()).sum(); |
| | | if (sum < outStoreItem.getAmount()) { |
| | | ShoppingGoods sysGoods = shoppingGoodsDao.selectById(outStoreItem.getSkuId()); |
| | | if (sysGoods != null) { |
| | | throw new GlobleException("出库失败:【" + sysGoods.getName() + "库存不足】"); |
| | | //计算库存总数是否满足本次扣减的需求 |
| | | List<SysStoreInfo> stores = storeInfoDao.selectStoInfoBySku(outStoreItem.getSkuId(), warehouseId); |
| | | double sum = stores.stream().mapToDouble(item -> item.getStoreTotal()).sum(); |
| | | if (sum < outStoreItem.getAmount()) { |
| | | ShoppingGoods sysGoods = shoppingGoodsDao.selectById(outStoreItem.getSkuId()); |
| | | if (sysGoods != null) { |
| | | throw new GlobleException("出库失败:【" + sysGoods.getName() + "库存不足】"); |
| | | |
| | | } else { |
| | | throw new GlobleException("出库失败没有找到出库产品"); |
| | | } else { |
| | | throw new GlobleException("出库失败没有找到出库产品"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //循环获取所有批次产品,并扣减库存 |
| | | Double number = outStoreItem.getAmount(); |
| | | for (SysStoreInfo storeInfo : stores) { |
| | | Double oldStoreTotal = storeInfo.getStoreTotal(); |
| | | Double surplus = storeInfo.getStoreTotal() - number; |
| | | //更新库存 |
| | | storeInfo.setStoreTotal(surplus < 0 ? 0 : surplus); |
| | | //循环获取所有批次产品,并扣减库存 |
| | | Double number = outStoreItem.getAmount(); |
| | | for (SysStoreInfo storeInfo : stores) { |
| | | Double oldStoreTotal = storeInfo.getStoreTotal(); |
| | | Double surplus = storeInfo.getStoreTotal() - number; |
| | | //更新库存 |
| | | storeInfo.setStoreTotal(surplus < 0 ? 0 : surplus); |
| | | |
| | | //每次扣减库存都创建一个出库记录 |
| | | SysOutStoreItem sysOutStoreItem = new SysOutStoreItem(); |
| | | BeanUtils.copyProperties(outStoreItem, sysOutStoreItem); |
| | | sysOutStoreItem.setStoreId(storeInfo.getId()); |
| | | sysOutStoreItem.setAmount(oldStoreTotal - storeInfo.getStoreTotal()); |
| | | realOutStoreItemList.add(sysOutStoreItem); |
| | | //每次扣减库存都创建一个出库记录 |
| | | SysOutStoreItem sysOutStoreItem = new SysOutStoreItem(); |
| | | BeanUtils.copyProperties(outStoreItem, sysOutStoreItem); |
| | | sysOutStoreItem.setStoreId(storeInfo.getId()); |
| | | sysOutStoreItem.setAmount(oldStoreTotal - storeInfo.getStoreTotal()); |
| | | realOutStoreItemList.add(sysOutStoreItem); |
| | | |
| | | storeInfoDao.update(storeInfo); |
| | | //扣除后剩余库存大于0则跳出扣除,否则剩余数量的负数的绝对值就是再次扣减的数量 |
| | | if (surplus > 0) { |
| | | break; |
| | | } else { |
| | | number = Math.abs(surplus); |
| | | storeInfoDao.update(storeInfo); |
| | | //扣除后剩余库存大于0则跳出扣除,否则剩余数量的负数的绝对值就是再次扣减的数量 |
| | | if (surplus > 0) { |
| | | break; |
| | | } else { |
| | | number = Math.abs(surplus); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | sysOutStoreItemDao.batchInsert(realOutStoreItemList); |
| | | }); |
| | | sysOutStoreItemDao.batchInsert(realOutStoreItemList); |
| | | } |
| | | |
| | | }else{ |
| | | LogUtil.debug("不管理库存"); |
| | | } |
| | | |
| | | |
| | |
| | | order.setRemark(cardUser.getCardName()); |
| | | order.setStaffId(user.getSuId()); |
| | | order.setIsCross(2 + ""); |
| | | order.setOrderType(SysOrder.ORDER_TYPE_SEAL); |
| | | order.setStatu(Dictionary.ORDER_STATU_YFK); |
| | | order.setCompanyId(user.getCompanyId()); |
| | | sysOrderDao.insert(order); |
| | |
| | | orderItem.setPrice(czVo.getBjmoney()); |
| | | orderItem.setStatus(Dictionary.ORDER_STATU_YFK); |
| | | orderItem.setAchieveList(czVo.getAchaeveList()); |
| | | orderItem.setShoppingGoods(shoppingGoods); |
| | | orderItemDao.insert(orderItem); |
| | | List<SysOrderItem> items = new ArrayList<>(); |
| | | items.add(orderItem); |
| | |
| | | moneyCardUseFlowDao.insert(moneyCardUseFlow); |
| | | |
| | | order.setFlows(czVo.getFlows()); |
| | | |
| | | addOrderFlow(order); |
| | | |
| | | // 添加员工业绩 |
| | | achieveNewService.addAchaeveByOrder(order); |
| | | |
| | | return order; |
| | | |
| | | } |
| | |
| | | sysOrder.setPayTime(now); |
| | | sysOrder.setOrderNo(codeService.getRefundOrderNo()); |
| | | sysOrder.setZkTotal(-sysOrder.getZkTotal()); |
| | | sysOrder.setOrderType(SysOrder.ORDER_TYPE_REFUND); |
| | | //新增订单 |
| | | sysOrderDao.insert(sysOrder); |
| | | //插入明细 |
| | |
| | | //退款退套餐退项目 |
| | | refundProjUse(sysOrder); |
| | | //删除积分 |
| | | scoreVipDetailService.removeByBusinessId(null,oldOrder.getVipId(), oldOrder.getId()); |
| | | scoreVipDetailService.removeByBusinessId(oldOrder.getVipId(), oldOrder.getId()); |
| | | |
| | | // 设置业绩 |
| | | achieveNewService.addAchaeveByOrder(sysOrder); |
| | |
| | | shoppingGoodsDao.update(goods); |
| | | } |
| | | |
| | | // 家居产品退库存 |
| | | if (CollectionUtils.isNotEmpty(returnGoodsList)) { |
| | | refundInstore(returnGoodsList); |
| | | BusParameterSettings manageStockSetting = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WAREHOUSE_MANAGE_STOCK, sysOrder.getCompanyId()); |
| | | if(AppConstance.IS_Y.equals(manageStockSetting.getParamValue())){ |
| | | // 家居产品退库存 |
| | | if (CollectionUtils.isNotEmpty(returnGoodsList)) { |
| | | refundInstore(returnGoodsList); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |