| | |
| | | @Resource |
| | | private UserChangeLogClient userChangeLogClient; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private PointSettingClient pointSettingClient; |
| | | |
| | |
| | | area.setCityCode(appUser.getCityCode()); |
| | | area.setProvinceCode(appUser.getProvinceCode()); |
| | | area.setVip(appUser.getVipId()); |
| | | area.setGoodsId(goodsId); |
| | | GoodsArea goodsArea = goodsAreaClient.getGoodsArea(area).getData(); |
| | | if(null == goodsArea){ |
| | | //没有地区价格,则使用会员价格 |
| | |
| | | price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsVip.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsVip.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsVip.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsVip.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsVip.getTechnicianPoints()); |
| | |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsArea.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsArea.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsArea.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsArea.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsArea.getTechnicianPoints()); |
| | |
| | | price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(goodsArea.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsArea.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsArea.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsArea.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsArea.getTechnicianPoints()); |
| | |
| | | price.setEarnSpendingPoints(goodsSeckill.getEarnSpendingPoints()); |
| | | price.setSuperiorSubcommission(goodsSeckill.getSuperiorSubcommission()); |
| | | price.setSuperiorRebatePoints(goodsSeckill.getSuperiorRebatePoints()); |
| | | price.setSuperiorType(String.valueOf(goodsSeckill.getSuperiorType())); |
| | | price.setSuperiorType(goodsSeckill.getSuperiorType()); |
| | | price.setSuperiorPriceType(goodsSeckill.getSuperiorPriceType()); |
| | | price.setServuceShopCharges(goodsSeckill.getServuceShopCharges()); |
| | | price.setServuceShopPoints(goodsSeckill.getServuceShopPoints()); |
| | | price.setTechnicianPoints(goodsSeckill.getTechnicianPoints()); |
| | |
| | | confirmOrderVo.setDiscountAmount(orderMoney.subtract(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | } |
| | | BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData(); |
| | | confirmOrderVo.setUseSimultaneously(baseSetting.getContent().equals("1")); |
| | | confirmOrderVo.setUseSimultaneously(JSON.parseObject(baseSetting.getContent()).getInteger("status") == 1); |
| | | int earnPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getEarnSpendingPoints).sum(); |
| | | confirmOrderVo.setEarnPoint(earnPoint); |
| | | //支付金额,订单金额-订单优惠 |
| | |
| | | confirmOrderVo.setResidualPoint(appUser.getLavePoint().intValue()); |
| | | //获取默认收货地址 |
| | | UserAddress userAddress = userAddressClient.getDefaultUserAddress(userid).getData(); |
| | | userAddress.setIdStr(userAddress.getId().toString()); |
| | | confirmOrderVo.setUserAddress(userAddress); |
| | | if(null != userAddress){ |
| | | userAddress.setIdStr(userAddress.getId().toString()); |
| | | confirmOrderVo.setUserAddress(userAddress); |
| | | } |
| | | confirmOrderVo.setPaymentType(confirmOrder.getPaymentType()); |
| | | //获取用户优惠券,用户全部优惠券,不能使用的需要标识出来置灰展示 |
| | | PaymentUserCoupon paymentUserCoupon = new PaymentUserCoupon(); |
| | |
| | | List<PaymentUserCouponVo> data = userCouponClient.getPaymentUserCoupon(paymentUserCoupon).getData(); |
| | | if(null != data){ |
| | | for (PaymentUserCouponVo couponInfo : data) { |
| | | List<Integer> forGoodIds = couponInfo.getForGoodIds(); |
| | | List<String> forGoodIds = couponInfo.getForGoodIds(); |
| | | //全部商品适用 |
| | | if(null == forGoodIds){ |
| | | //满减券 |
| | |
| | | //获取快递策略 |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | confirmOrderVo.setExpressFee(jsonObject.getBigDecimal("expressFee")); |
| | | List<Integer> vip = jsonObject.getJSONArray("vip").toList(Integer.class); |
| | | confirmOrderVo.setExpressFee(jsonObject.getBigDecimal("freight")); |
| | | List<String> vip = Arrays.asList(jsonObject.getString("freeVip").split(",")); |
| | | //包邮条件(所有会员或者满足条件的会员) |
| | | if(vip.get(0) == -1 || vip.contains(appUser.getVipId())){ |
| | | if(vip.get(0).equals("0") || vip.contains(appUser.getVipId().toString())){ |
| | | if(confirmOrder.getPaymentType() == 1){ |
| | | //现金支付,支付金额满足包邮条件 |
| | | BigDecimal cash = jsonObject.getBigDecimal("cash"); |
| | | BigDecimal cash = jsonObject.getBigDecimal("freeFreight"); |
| | | if(confirmOrderVo.getPayMoney().compareTo(cash) >= 0){ |
| | | confirmOrderVo.setExpressFee(BigDecimal.ZERO); |
| | | } |
| | | }else{ |
| | | //积分支付,支付积分是否满足包邮条件 |
| | | Integer point = jsonObject.getInteger("point"); |
| | | Integer point = jsonObject.getInteger("freeIntegral"); |
| | | if(confirmOrderVo.getOrderPoint().compareTo(point) >= 0){ |
| | | confirmOrderVo.setExpressFee(BigDecimal.ZERO); |
| | | } |
| | |
| | | vo.setSuperiorSubcommission(price.getSuperiorSubcommission()); |
| | | vo.setSuperiorRebatePoints(price.getSuperiorRebatePoints()); |
| | | vo.setSuperiorType(price.getSuperiorType()); |
| | | vo.setSuperiorPriceType(price.getSuperiorPriceType()); |
| | | vo.setServuceShopCharges(price.getServuceShopCharges()); |
| | | vo.setServuceShopPoints(price.getServuceShopPoints()); |
| | | vo.setTechnicianPoints(price.getTechnicianPoints()); |
| | |
| | | String goodsName = ""; |
| | | for (Integer goodsId : goodsIds) { |
| | | Goods goods = goodsClient.getGoodsById(goodsId).getData(); |
| | | if(1 == goods.getAppointStore() && !collect.contains(goodsId)){ |
| | | if(goods.getType() == 1 && 1 == goods.getAppointStore() && !collect.contains(goodsId)){ |
| | | goodsName = goods.getName(); |
| | | break; |
| | | } |
| | |
| | | orderMoney = orderMoney.add(myShoppingCartVo.getCash().multiply(new BigDecimal(myShoppingCartVo.getNumber()))); |
| | | } |
| | | }else{ |
| | | orderPoint = goodsList.stream().mapToInt(MyShoppingCartVo::getPoint).sum(); |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | orderPoint += (myShoppingCartVo.getPoint() * myShoppingCartVo.getNumber()); |
| | | } |
| | |
| | | if(null != shoppingCartPayment.getUserCouponId() && 3 != shoppingCartPayment.getPaymentType()){ |
| | | couponInfoVo = userCouponClient.getCouponInfo(shoppingCartPayment.getUserCouponId()).getData(); |
| | | String forGoodIds = couponInfoVo.getForGoodIds(); |
| | | List<Integer> parseArray = JSON.parseArray(forGoodIds, Integer.class); |
| | | String[] split = forGoodIds.split(","); |
| | | List<String> parseArray = Arrays.asList(split); |
| | | //全部商品 |
| | | if(parseArray.contains(-1)){ |
| | | if("-1".equals(forGoodIds)){ |
| | | //满减 |
| | | if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(paymentMoney) <= 0){ |
| | | paymentMoney = paymentMoney.subtract(couponInfoVo.getDiscountAmount()); |
| | |
| | | paymentMoney = BigDecimal.ZERO; |
| | | BigDecimal goodsMoney = BigDecimal.ZERO; |
| | | for (MyShoppingCartVo myShoppingCartVo : goodsList) { |
| | | Integer goodsId = myShoppingCartVo.getGoodsId(); |
| | | String goodsId = myShoppingCartVo.getGoodsId().toString(); |
| | | BigDecimal cash = myShoppingCartVo.getCash(); |
| | | if(parseArray.contains(goodsId)){ |
| | | goodsMoney = goodsMoney.add(cash); |
| | |
| | | SystemConfig systemConfig = systemConfigClient.getSystemConfig(3).getData(); |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | //快递费 |
| | | expressFee = jsonObject.getBigDecimal("expressFee"); |
| | | List<Integer> vip = jsonObject.getJSONArray("vip").toList(Integer.class); |
| | | expressFee = jsonObject.getBigDecimal("freight"); |
| | | List<String> vip = Arrays.asList(jsonObject.getString("freeVip").split(",")); |
| | | //包邮条件(所有会员或者满足条件的会员) |
| | | if(vip.get(0) == -1 || vip.contains(appUser.getVipId())){ |
| | | if(vip.get(0).equals("0") || vip.contains(appUser.getVipId().toString())){ |
| | | if(shoppingCartPayment.getPaymentType() != 3){ |
| | | //现金支付,支付金额满足包邮条件 |
| | | BigDecimal cash = jsonObject.getBigDecimal("cash"); |
| | | BigDecimal cash = jsonObject.getBigDecimal("freeFreight"); |
| | | if(paymentMoney.compareTo(cash) >= 0){ |
| | | expressFee = BigDecimal.ZERO; |
| | | } |
| | | }else{ |
| | | //积分支付,支付积分是否满足包邮条件 |
| | | Integer point = jsonObject.getInteger("point"); |
| | | Integer point = jsonObject.getInteger("freeIntegral"); |
| | | if(orderPoint.compareTo(point) >= 0){ |
| | | expressFee = BigDecimal.ZERO; |
| | | } |
| | |
| | | return R.fail("账户余额不足"); |
| | | } |
| | | } |
| | | if(3 == shoppingCartPayment.getPaymentType()){ |
| | | Integer availablePoint = appUser.getAvailablePoint(); |
| | | if(availablePoint < orderPoint){ |
| | | return R.fail("账户积分不足"); |
| | | } |
| | | } |
| | | //判断运费支付是否足够 |
| | | if(null != shoppingCartPayment.getFreightPaymentType() && 2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){ |
| | | BigDecimal balance = appUser.getBalance(); |
| | |
| | | orderGood.setSuperiorSubcommission(myShoppingCartVo.getSuperiorSubcommission()); |
| | | orderGood.setSuperiorRebatePoints(myShoppingCartVo.getSuperiorRebatePoints()); |
| | | orderGood.setSuperiorType(myShoppingCartVo.getSuperiorType()); |
| | | orderGood.setSuperiorPriceType(myShoppingCartVo.getSuperiorPriceType()); |
| | | orderGood.setServuceShopCharges(myShoppingCartVo.getServuceShopCharges()); |
| | | orderGood.setServuceShopPoints(myShoppingCartVo.getServuceShopPoints()); |
| | | orderGood.setTechnicianPoints(myShoppingCartVo.getTechnicianPoints()); |
| | |
| | | //构建积分流水记录 |
| | | if(earnPoint > 0){ |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = earnPoint; |
| | | int earnPoint1 = 0; |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = earnPoint1 * (100 - pointSetting.getBuyPoint()); |
| | | earnPoint1 = new BigDecimal(earnPoint).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | appUser.setShopPoint(appUser.getShopPoint() + earnPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint1); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint); |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + earnPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | |
| | | UserPoint userPoint = new UserPoint(); |
| | | userPoint.setType(1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint1); |
| | | userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint); |
| | | userPoint.setVariablePoint(earnPoint); |
| | | userPoint.setBalance(appUser.getLavePoint()); |
| | | userPoint.setCreateTime(LocalDateTime.now()); |
| | |
| | | appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | //构建余额明细变动记录 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | |
| | | orderService.updateById(order); |
| | | //删除购物车数据 |
| | | this.removeBatchByIds(ids); |
| | | //检查消费积分满足后升级会员 |
| | | vipUpgrade(appUser); |
| | | } |
| | | //积分支付 |
| | | if(3 == shoppingCartPayment.getPaymentType()){ |
| | | Integer lavePoint = appUser.getLavePoint(); |
| | | PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); |
| | | int earnPoint1 = earnPoint; |
| | | int earnPoint1 = 0; |
| | | //计算可用积分比例 |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointOpen()){ |
| | | earnPoint1 = earnPoint1 * (100 - pointSetting.getBuyPoint()); |
| | | earnPoint1 = new BigDecimal(earnPoint).multiply(pointSetting.getBuyPoint().divide(new BigDecimal(100))).intValue(); |
| | | } |
| | | //扣减订单支付积分 |
| | | appUser.setLavePoint(appUser.getLavePoint() - orderPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() - orderPoint); |
| | | |
| | | appUser.setShopPoint(appUser.getShopPoint() + earnPoint); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint1); |
| | | appUser.setLavePoint(appUser.getLavePoint() + earnPoint); |
| | | appUser.setAvailablePoint(appUser.getAvailablePoint() + earnPoint1); |
| | | if(null != pointSetting && 1 == pointSetting.getBuyPointGift()){ |
| | | appUser.setTransferablePoint(appUser.getTransferablePoint() + earnPoint1); |
| | | } |
| | | appUser.setTotalPoint(appUser.getTotalPoint() + earnPoint); |
| | | appUser.setLastShopTime(LocalDateTime.now()); |
| | | appUserClient.editAppUserById(appUser); |
| | | //检查消费积分满足后升级会员 |
| | | vipUpgrade(appUser); |
| | | //变更等级 |
| | | appUserClient.vipUpgrade(appUser.getId()); |
| | | |
| | | //构建积分流水记录 |
| | | UserPoint userPoint = new UserPoint(); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 会员等级变化 |
| | | * @param appUser |
| | | */ |
| | | public void vipUpgrade(AppUser appUser){ |
| | | Integer shopPoint = appUser.getShopPoint(); |
| | | Integer vipId = appUser.getVipId(); |
| | | //钻石会员 |
| | | VipSetting vipSetting3 = vipSettingClient.getVipSetting(3).getData(); |
| | | Integer vipLevelUpShopRole = vipSetting3.getVipLevelUpShopRole(); |
| | | Integer vipLevelUpShop = vipSetting3.getVipLevelUpShop(); |
| | | if(null != vipLevelUpShopRole && 1 == vipLevelUpShopRole && appUser.getVipId() < 3 && shopPoint >= vipLevelUpShop){ |
| | | appUser.setVipId(3); |
| | | appUserClient.editAppUserById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogClient.saveUserChangeLog(userChangeLog); |
| | | return; |
| | | } |
| | | //黄金会员 |
| | | VipSetting vipSetting2 = vipSettingClient.getVipSetting(2).getData(); |
| | | vipLevelUpShopRole = vipSetting2.getVipLevelUpShopRole(); |
| | | vipLevelUpShop = vipSetting2.getVipLevelUpShop(); |
| | | if(null != vipLevelUpShopRole && 1 == vipLevelUpShopRole && appUser.getVipId() < 2 && shopPoint >= vipLevelUpShop){ |
| | | appUser.setVipId(2); |
| | | appUserClient.editAppUserById(appUser); |
| | | //添加等级变化记录 |
| | | UserChangeLog userChangeLog = new UserChangeLog(); |
| | | userChangeLog.setDelFlag(0); |
| | | userChangeLog.setCreateTime(LocalDateTime.now()); |
| | | userChangeLog.setAppUserId(appUser.getId()); |
| | | userChangeLog.setBeforeVipId(vipId); |
| | | userChangeLog.setAfterVipId(appUser.getVipId()); |
| | | userChangeLog.setChangeType(1); |
| | | userChangeLogClient.saveUserChangeLog(userChangeLog); |
| | | } |
| | | } |
| | | } |