| | |
| | | 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; |
| | |
| | | |
| | | //获取折扣----- |
| | | Double zk = zk = 1.0; |
| | | //验证商品是否只购买了一次 |
| | | checkBuyOnce(car, info.getId()); |
| | | |
| | | SysOrder order = new SysOrder(); |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | |
| | | int count = 0; |
| | | // 设置订单条目 |
| | | for (ShoppingCarItem carItem : car.getCarItems()) { |
| | | // 检测最大销售数量 |
| | | checkIsArrivedMax(carItem); |
| | | |
| | | SysOrderItem orderItem = new SysOrderItem(); |
| | | orderItem.setOrderId(order.getId()); |
| | | orderItem.setCount(carItem.getCount()); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 验证商品是否购买过一次 |
| | | * |
| | | * @Title: checkBuyOnce @author:jyy @param car void 返回类型 @date |
| | | * 2016年9月22日 上午10:05:33 @throws |
| | | */ |
| | | private void checkBuyOnce(ShoppingCarItemsVo car, Long vipId) { |
| | | for (ShoppingCarItem carItem : car.getCarItems()) { |
| | | if (shoppingGoodsDao.selectBuyCount(carItem.getGoodsId(), vipId) > 0) { |
| | | ShoppingGoods goods = shoppingGoodsDao.selectById(carItem.getGoodsId()); |
| | | throw new GlobleException(goods.getName() + "只能购买一次!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * jyy 收款 |
| | |
| | | if (!Dictionary.ORDER_STATU_DFK.equals(pageOrder.getStatu())) { |
| | | throw new GlobleException("该订单已经收过款,请刷新页面再试!"); |
| | | } |
| | | |
| | | //检查交易限制调整 |
| | | checkSealLimit(pageOrder); |
| | | |
| | | //交易业绩设置是否合理 |
| | | checkAchieveIsOk(pageOrder); |
| | | |
| | | |
| | | // 更新收款时间 |
| | | pageOrder.setPayTime(new Date()); |
| | | pageOrder.setStatu(Dictionary.ORDER_STATU_YFK); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 检查产品销售次数 |
| | | */ |
| | | private void checkSealLimit(SysOrder pageOrder) { |
| | | pageOrder.getItems().forEach(item->{ |
| | | ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId()); |
| | | |
| | | //最大销售次数检测 |
| | | Integer maxNum = shopGoods.getCarMaxSaleCount(); |
| | | if (maxNum != null && maxNum != 0) { |
| | | Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(),null); |
| | | if ((buyNum + item.getCount()) > maxNum) { |
| | | throw new GlobleException(shopGoods.getName() + "已超过最大销售数量"); |
| | | } |
| | | if ((buyNum + item.getCount()) == maxNum) { |
| | | if (!shopGoods.getStaus().equals(Dictionary.BUSINESS_STATE_DOWN)) { |
| | | shopGoods.setStaus(Dictionary.BUSINESS_STATE_DOWN); |
| | | shoppingGoodsDao.update(shopGoods); |
| | | } |
| | | } |
| | | } |
| | | //每人限购次数检测 |
| | | Integer onceCount = shopGoods.getIsOnce(); |
| | | if(onceCount!=null && onceCount!=0){ |
| | | Integer buyOnceCount = orderItemDao.selectByGoodsId(shopGoods.getId(),pageOrder.getVipId()); |
| | | |
| | | if ((buyOnceCount + item.getCount()) > onceCount) { |
| | | throw new GlobleException(shopGoods.getName() + "每人限购"+onceCount+"次"); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 交易业绩设置是否合理 |
| | | * @param pageOrder |
| | | */ |
| | | private void checkAchieveIsOk(SysOrder pageOrder) { |
| | | double huakouSum = pageOrder.getItems().stream() |
| | | .mapToDouble( |
| | | item -> |
| | | item.getAchieveList().stream() |
| | | .filter(achieveNew -> "划扣".equals(achieveNew.getPayMethod())) |
| | | .mapToDouble(achieve -> achieve.getGoodsCash()).sum() |
| | | ).sum(); |
| | | |
| | | double czkPay= pageOrder.getFlows().stream() |
| | | .filter(sysOrderFlow -> "储值卡".equals(sysOrderFlow.getPayMethod())) |
| | | .mapToDouble(sysOrderFlow ->sysOrderFlow.getAmount().doubleValue()).sum(); |
| | | |
| | | if(czkPay!=huakouSum){ |
| | | throw new GlobleException("划扣业绩不等于储值卡扣款金额,请修改业绩设置!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置会员消费积分 |
| | | * @param pageOrder |
| | | */ |
| | |
| | | &&StringUtils.isNotBlank(cashConsumption.getParamValue())){ |
| | | |
| | | BigDecimal scoreSetting0 = new BigDecimal(cashConsumption.getParamValue()); |
| | | cashScore[0]= cashPayAmount.divide(scoreSetting0).intValue(); |
| | | if(scoreSetting0.compareTo(BigDecimal.ZERO)>0) { |
| | | cashScore[0] = cashPayAmount.divide(scoreSetting0).intValue(); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(cashConsumption.getParamValue1())){ |
| | | BigDecimal scoreSetting1 = new BigDecimal(cashConsumption.getParamValue1()); |
| | | cashScore[1]= cashPayAmount.divide(scoreSetting1).intValue(); |
| | | if(scoreSetting1.compareTo(BigDecimal.ZERO)>0){ |
| | | cashScore[1]= cashPayAmount.divide(scoreSetting1).intValue(); |
| | | } |
| | | |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(cashConsumption.getParamValue2())){ |
| | | BigDecimal scoreSetting2 = new BigDecimal(cashConsumption.getParamValue2()); |
| | | cashScore[2]= cashPayAmount.divide(scoreSetting2).intValue(); |
| | | if(scoreSetting2.compareTo(BigDecimal.ZERO)>0){ |
| | | cashScore[2]= cashPayAmount.divide(scoreSetting2).intValue(); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | &&StringUtils.isNotBlank(principalBalanceConsumption.getParamValue())){ |
| | | |
| | | BigDecimal scoreSetting0 = new BigDecimal(principalBalanceConsumption.getParamValue()); |
| | | cardScore[0]= cardPayAmount.divide(scoreSetting0).intValue(); |
| | | if(scoreSetting0.compareTo(BigDecimal.ZERO)>0) { |
| | | cardScore[0] = cardPayAmount.divide(scoreSetting0).intValue(); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(principalBalanceConsumption.getParamValue1())){ |
| | | BigDecimal scoreSetting1 = new BigDecimal(principalBalanceConsumption.getParamValue1()); |
| | | cardScore[1]= cardPayAmount.divide(scoreSetting1).intValue(); |
| | | if(scoreSetting1.compareTo(BigDecimal.ZERO)>0) { |
| | | cardScore[1] = cardPayAmount.divide(scoreSetting1).intValue(); |
| | | } |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(principalBalanceConsumption.getParamValue2())){ |
| | | BigDecimal scoreSetting2 = new BigDecimal(principalBalanceConsumption.getParamValue2()); |
| | | cardScore[2]= cardPayAmount.divide(scoreSetting2).intValue(); |
| | | if(scoreSetting2.compareTo(BigDecimal.ZERO)>0) { |
| | | cardScore[2] = cardPayAmount.divide(scoreSetting2).intValue(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | &&StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue())){ |
| | | |
| | | BigDecimal scoreSetting0 = new BigDecimal(bonusBalanceConsumption.getParamValue()); |
| | | giftScore[0]= giftPayAmount.divide(scoreSetting0).intValue(); |
| | | if(scoreSetting0.compareTo(BigDecimal.ZERO)>0) { |
| | | giftScore[0] = giftPayAmount.divide(scoreSetting0).intValue(); |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue1())){ |
| | | BigDecimal scoreSetting1 = new BigDecimal(bonusBalanceConsumption.getParamValue1()); |
| | | giftScore[1]= giftPayAmount.divide(scoreSetting1).intValue(); |
| | | if(scoreSetting1.compareTo(BigDecimal.ZERO)>0) { |
| | | giftScore[1] = giftPayAmount.divide(scoreSetting1).intValue(); |
| | | } |
| | | } |
| | | |
| | | if(StringUtils.isNotBlank(bonusBalanceConsumption.getParamValue2())){ |
| | | BigDecimal scoreSetting2 = new BigDecimal(bonusBalanceConsumption.getParamValue2()); |
| | | giftScore[2]= giftPayAmount.divide(scoreSetting2).intValue(); |
| | | if(scoreSetting2.compareTo(BigDecimal.ZERO)>0) { |
| | | giftScore[2] = giftPayAmount.divide(scoreSetting2).intValue(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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()); |
| | |
| | | // 最大发卡数量为0代表不做限制 |
| | | if (maxNum != null && maxNum != 0) { |
| | | // 查询该商品已经被购买的次数 |
| | | Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId()); |
| | | Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(),null); |
| | | buyNum = (buyNum == null ? 0 : buyNum); |
| | | if ((buyNum + carItem.getCount()) > maxNum) { |
| | | throw new GlobleException(shopGoods.getName() + "已超过最大销售数量"); |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | |
| | | @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("不管理库存"); |
| | | } |
| | | |
| | | |
| | |
| | | } else { |
| | | puse.setPrice(goodsAssemble.getPrice() * zk); |
| | | } |
| | | puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount()))); |
| | | |
| | | // 赠送和打折后金额为0的都视为赠送项目 |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { |
| | | puse.setSource(Dictionary.TAOCAN_SOURCE_GM); |
| | | } else { |
| | | |
| | | puse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | //赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗 |
| | | boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE); |
| | | if(zsConsumeAchieve){ |
| | | if (taocanId == null) { |
| | | puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() ); |
| | | } else { |
| | | puse.setPrice(goodsAssemble.getPrice()); |
| | | } |
| | | }else{ |
| | | puse.setPrice(0D); |
| | | } |
| | | |
| | | |
| | | } |
| | | puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount()))); |
| | | puse.setFailTime(failTime); |
| | | sysProjUseDao.insert(puse); |
| | | return puse; |
| | |
| | | taocanProjUse.setIsCourse(taocanShoppingGoods.getIsCourse()); |
| | | taocanProjUse.setIsInfinite(taocanShoppingGoods.getIsInfinite()); |
| | | // 赠送和打折后金额为0的都视为赠送项目 |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0 && !isGiftMoneyPay(order)) { |
| | | taocanProjUse.setSource(Dictionary.TAOCAN_SOURCE_GM); |
| | | } else { |
| | | taocanProjUse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | |
| | | sysProjUseDao.update(taocanProjUse); |
| | | } |
| | | |
| | | @Autowired |
| | | private SysProjServicesService projServicesService; |
| | | |
| | | /** |
| | | * 根据订单创建用户项目使用情况 |
| | | * |
| | |
| | | puse.setVipId(order.getVipId()); |
| | | puse.setStatus(Dictionary.TAOCAN_STATUS_YX); |
| | | puse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); |
| | | puse.setBalance(sysOrderItem.getZkPrice()); |
| | | puse.setPrice(sysOrderItem.getZkPrice()); |
| | | |
| | | |
| | | puse.setProjName(sysOrderItem.getShoppingGoods().getName()); |
| | | |
| | | |
| | | // 赠送和打折后金额为0的都视为赠送项目 |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { |
| | | if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0 && !isGiftMoneyPay(order)) { |
| | | puse.setSource(Dictionary.TAOCAN_SOURCE_GM); |
| | | puse.setPrice(sysOrderItem.getZkPrice()); |
| | | } else { |
| | | puse.setSource(Dictionary.TAOCAN_SOURCE_ZS); |
| | | //赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗 |
| | | boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE); |
| | | if(zsConsumeAchieve){ |
| | | puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice()); |
| | | }else{ |
| | | puse.setPrice(0D); |
| | | } |
| | | |
| | | |
| | | } |
| | | // 设置失效时间 |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null); |
| | | puse.setFailTime(invalidTime); |
| | | puse.setBalance(sysOrderItem.getShoppingGoods().getSealPice()*puse.getSurplusCount()); |
| | | sysProjUseDao.insert(puse); |
| | | } |
| | | |
| | | /** |
| | | * 全是赠送金额,且配置了赠送金额购买计算为赠送 |
| | | * @param order |
| | | * @return |
| | | */ |
| | | private boolean isGiftMoneyPay(SysOrder order) { |
| | | BusParameterSettings giftiIsfree = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SHOP_MANAGE_GIFTISFREE, order.getCompanyId()); |
| | | if(giftiIsfree.getParamValue().equals("是")){ |
| | | return order.getFlows().stream().allMatch(item -> SysOrderFlow.IS_GIFT_Y.equals(item.getIsGift()) |
| | | && item.getAmount().doubleValue() >0D); |
| | | }else{ |
| | | return false; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | | //插入明细 |
| | |
| | | |
| | | 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.getOldItemId()); |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |