| | |
| | | import com.ruoyi.system.api.constant.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constant.SecurityConstant; |
| | | import com.ruoyi.system.api.domain.dto.*; |
| | | import com.ruoyi.system.api.domain.poji.activity.Activity; |
| | | import com.ruoyi.system.api.domain.poji.activity.ActivityRecord; |
| | | import com.ruoyi.system.api.domain.poji.config.DelayTask; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | |
| | | import lombok.extern.log4j.Log4j2; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | 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; |
| | |
| | | //处理订单回显 |
| | | for (AppUserOrderPageVo appUserOrderPageVo : appUserOrderPageVoList) { |
| | | if(member.getBindingFlag()==0&&appUserOrderPageVo.getOrderFrom()==2){ |
| | | appUserOrderPageVo.setShopName("全部店铺"); |
| | | //查询秒杀活动的参与店铺 |
| | | R<Activity> activity = remoteActivityService.getActivity(appUserOrderPageVo.getActivityId()); |
| | | if(activity.getCode() != 200){ |
| | | throw new RuntimeException(activity.getMsg()); |
| | | } |
| | | Activity data = activity.getData(); |
| | | if(data.getAreaFlag() == 1){ |
| | | appUserOrderPageVo.setShopNumber(0); |
| | | appUserOrderPageVo.setShopName("全部店铺"); |
| | | } |
| | | if(data.getAreaFlag() == 2 && data.getShopFlag() == 1){ |
| | | String designatedArea = data.getDesignatedArea(); |
| | | String[] split = designatedArea.split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | R<List<Shop>> listR = remoteShopService.listShopByCityCode(list); |
| | | if(listR.getCode() != 200){ |
| | | throw new RuntimeException(listR.getMsg()); |
| | | } |
| | | List<Shop> data1 = listR.getData(); |
| | | appUserOrderPageVo.setShopNumber(1); |
| | | appUserOrderPageVo.setShopName(JSON.toJSONString(data1)); |
| | | } |
| | | if(data.getShopFlag() == 2){ |
| | | String applicableShop = data.getApplicableShop(); |
| | | String[] split = applicableShop.split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | R<List<Shop>> listR = remoteShopService.listShopByIds(list); |
| | | if(listR.getCode() != 200){ |
| | | throw new RuntimeException(listR.getMsg()); |
| | | } |
| | | List<Shop> data1 = listR.getData(); |
| | | appUserOrderPageVo.setShopNumber(1); |
| | | appUserOrderPageVo.setShopName(JSON.toJSONString(data1)); |
| | | } |
| | | }else if(member.getBindingFlag()==1&&appUserOrderPageVo.getOrderFrom()==2){ |
| | | Long relationShopId = member.getRelationShopId(); |
| | | R<Shop> shop = remoteShopService.getShop(relationShopId); |
| | | if(shop.getCode() != 200){ |
| | | throw new RuntimeException(shop.getMsg()); |
| | | } |
| | | Shop data1 = shop.getData(); |
| | | //查询秒杀活动的参与店铺 |
| | | R<Activity> activity = remoteActivityService.getActivity(appUserOrderPageVo.getActivityId()); |
| | | if(activity.getCode() != 200){ |
| | | throw new RuntimeException(activity.getMsg()); |
| | | } |
| | | Activity data = activity.getData(); |
| | | if(data.getAreaFlag() == 1){ |
| | | appUserOrderPageVo.setShopNumber(2); |
| | | appUserOrderPageVo.setShopName(data1.getShopName()); |
| | | appUserOrderPageVo.setShopServicePhone(data1.getShopServicePhone()); |
| | | } |
| | | if(data.getAreaFlag() == 2 && data.getShopFlag() == 1){ |
| | | String designatedArea = data.getDesignatedArea(); |
| | | String[] split = designatedArea.split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | R<List<Shop>> listR = remoteShopService.listShopByCityCode(list); |
| | | if(listR.getCode() != 200){ |
| | | throw new RuntimeException(listR.getMsg()); |
| | | } |
| | | List<Shop> data2 = listR.getData(); |
| | | List<Long> collect = data2.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | if(collect.contains(relationShopId)){ |
| | | appUserOrderPageVo.setShopNumber(2); |
| | | appUserOrderPageVo.setShopName(data1.getShopName()); |
| | | appUserOrderPageVo.setShopServicePhone(data1.getShopServicePhone()); |
| | | }else{ |
| | | appUserOrderPageVo.setShopNumber(1); |
| | | appUserOrderPageVo.setShopName(JSON.toJSONString(data2)); |
| | | } |
| | | } |
| | | if(data.getShopFlag() == 2){ |
| | | String applicableShop = data.getApplicableShop(); |
| | | String[] split = applicableShop.split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | R<List<Shop>> listR = remoteShopService.listShopByIds(list); |
| | | if(listR.getCode() != 200){ |
| | | throw new RuntimeException(listR.getMsg()); |
| | | } |
| | | List<Shop> data2 = listR.getData(); |
| | | List<Long> collect = data2.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | if(collect.contains(relationShopId)){ |
| | | appUserOrderPageVo.setShopNumber(2); |
| | | appUserOrderPageVo.setShopName(data1.getShopName()); |
| | | appUserOrderPageVo.setShopServicePhone(data1.getShopServicePhone()); |
| | | }else{ |
| | | appUserOrderPageVo.setShopNumber(1); |
| | | appUserOrderPageVo.setShopName(JSON.toJSONString(data2)); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | }else{ |
| | | simpleShopVo = shopMap.get(appUserOrderPageVo.getShopId()); |
| | | appUserOrderPageVo.setShopName(simpleShopVo.getShopName()); |
| | | appUserOrderPageVo.setShopServicePhone(simpleShopVo.getShopServicePhone()); |
| | | appUserOrderPageVo.setShopNumber(2); |
| | | if (appUserOrderPageVo.getShopId().equals(appUserOrderPageDto.getShopId())) { |
| | | appUserOrderPageVo.setSameShop(1); |
| | | } else { |
| | |
| | | //判断用户是否绑定 |
| | | if(member.getBindingFlag()==1){ |
| | | //绑定用户判断核销商户 |
| | | if(order.getOrderFrom()==2&&order.getUnbindingFlag()==1){ |
| | | if (!member.getRelationShopId().equals(shopId)) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | //未绑定时下的活动订单只需要判断店铺是否支持 |
| | | String activityId = order.getActivityId(); |
| | | MerActivityShopDto merActivityShopDto = new MerActivityShopDto(); |
| | | merActivityShopDto.setShopId(shopId); |
| | | merActivityShopDto.setActivityId(activityId); |
| | | Boolean judge = remoteActivityService.judgeActivityShop(merActivityShopDto).getData(); |
| | | if(!judge){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_NO_ACTIVITY); |
| | | } |
| | | }else{ |
| | | if (order.getOrderFrom()==2&&!member.getRelationShopId().equals(shopId)) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | if(order.getOrderFrom() == 1){ |
| | | //商城订单和绑定后活动订单判断核销商户和订单商户和用户关联商户是否统一 |
| | | if (!order.getShopId().equals(shopId)) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | |
| | | //获取核销商户 |
| | | ShopRelUserVo shopRelUserVo = remoteShopService.getShopByUserId(merVerifyOrderDto.getUserId()).getData(); |
| | | Long shopId = shopRelUserVo.getShopId(); |
| | | log.info("当前核销员工【" + shopRelUserVo.getUserName() + "】门店ID:" + shopId); |
| | | //获取订单商品列表 |
| | | List<AppUserOrderGoodsPageVo> appUserOrderGoodsPageVoList = orderGoodsService.listAppVoByOrderId(orderId); |
| | | //绑定用户判断核销商户 |
| | | if(member.getBindingFlag()==1){ |
| | | //未绑定的活动订单只需要判断店铺是否支持 |
| | | if(order.getOrderFrom()==2&&order.getUnbindingFlag()==1){ |
| | | if(order.getOrderFrom()==2 && !member.getRelationShopId().equals(shopId)){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | if(order.getOrderFrom()==2 && member.getRelationShopId().equals(shopId)){ |
| | | String activityId = order.getActivityId(); |
| | | MerActivityShopDto merActivityShopDto = new MerActivityShopDto(); |
| | | merActivityShopDto.setShopId(shopId); |
| | |
| | | Boolean judge = remoteActivityService.judgeActivityShop(merActivityShopDto).getData(); |
| | | if(!judge){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_NO_ACTIVITY); |
| | | } |
| | | }else{ |
| | | //绑定用户需直接判断商户一致 |
| | | if (!order.getShopId().equals(shopId)) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | } |
| | | }else{ |
| | |
| | | throw new ServiceException(AppErrorConstant.SHOP_NO_ACTIVITY); |
| | | } |
| | | } |
| | | //未绑定用户需判断核销商城订单判断商品单价和优惠券 |
| | | /*StringJoiner goodsIdSJ = new StringJoiner(","); |
| | | for (AppUserOrderGoodsPageVo appUserOrderGoodsPageVo : appUserOrderGoodsPageVoList) { |
| | | goodsIdSJ.add(appUserOrderGoodsPageVo.getGoodsId()); |
| | | } |
| | | //获取商品列表 |
| | | List<Goods> goodsList = remoteGoodsService.listGoodsByGoodsId(goodsIdSJ.toString()).getData(); |
| | | Map<String, Goods> goodsMap = goodsList.stream() |
| | | .collect(Collectors.toMap(Goods::getGoodsId, Function.identity())); |
| | | Goods goods; |
| | | ShopGoods shopGoods; |
| | | AppShopGoodsGetDto appShopGoodsGetDto; |
| | | for (AppUserOrderGoodsPageVo appUserOrderGoodsPageVo : appUserOrderGoodsPageVoList) { |
| | | appShopGoodsGetDto= new AppShopGoodsGetDto(); |
| | | appShopGoodsGetDto.setShopId(shopId); |
| | | appShopGoodsGetDto.setGoodsId(appUserOrderGoodsPageVo.getGoodsId()); |
| | | shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | goods = goodsMap.get(appUserOrderGoodsPageVo.getGoodsId()); |
| | | //当商户定制价格不为空时判断商品定制价格否则判断商品价格是否一致 |
| | | if(shopGoods!=null){ |
| | | if(shopGoods.getSalesPrice().compareTo(appUserOrderGoodsPageVo.getGoodsPrice())!=0){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | if(appUserOrderGoodsPageVo.getCycleNumFlag()==0){ |
| | | if(shopGoods.getServiceNum()!=null){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | }else{ |
| | | if(shopGoods.getServiceNum()!=appUserOrderGoodsPageVo.getServiceNum()){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | } |
| | | }else{ |
| | | if(goods.getSalesPrice().compareTo(appUserOrderGoodsPageVo.getGoodsPrice())!=0){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | if(appUserOrderGoodsPageVo.getCycleNumFlag()==0){ |
| | | if(goods.getServiceNum()!=null){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | }else{ |
| | | if(goods.getServiceNum()!=appUserOrderGoodsPageVo.getServiceNum()){ |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | } |
| | | } |
| | | }*/ |
| | | } |
| | | order.setShopId(shopId); |
| | | order.setOrderStatus(3); |
| | |
| | | OrderGoods orderGoods; |
| | | String orderGoodsId; |
| | | GoodsFile goodsFile; |
| | | //BigDecimal cycleMoney = new BigDecimal("0.00"); |
| | | //BigDecimal experienceMoney = new BigDecimal("0.00"); |
| | | //BigDecimal serviceMoney = new BigDecimal("0.00"); |
| | | //BigDecimal goodsMoney = new BigDecimal("0.00"); |
| | | List<OrderGoods> orderGoodsList = new ArrayList<>(); |
| | | ConsumerGoods consumerGoods; |
| | | String consumerGoodsId; |
| | |
| | | consumerGoodsList.add(consumerGoods); |
| | | } |
| | | } |
| | | |
| | | //商户变更计算 |
| | | /*switch (orderGoods.getGoodsType()) { |
| | | case 1: |
| | | cycleMoney = cycleMoney.add(orderGoods.getGoodsReceivableMoney()); |
| | | break; |
| | | case 2: |
| | | serviceMoney = serviceMoney.add(orderGoods.getGoodsReceivableMoney()); |
| | | break; |
| | | case 3: |
| | | experienceMoney = experienceMoney.add(orderGoods.getGoodsReceivableMoney()); |
| | | break; |
| | | case 4: |
| | | goodsMoney = goodsMoney.add(orderGoods.getGoodsReceivableMoney()); |
| | | break; |
| | | default: |
| | | break; |
| | | }*/ |
| | | } |
| | | //创建订单 |
| | | Order order = new Order(); |
| | |
| | | memberTotalChangeDto.setUserId(order.getUserId()); |
| | | memberTotalChangeDto.setConsumeTime(nowTime); |
| | | remoteMemberService.changeMemberTotal(memberTotalChangeDto); |
| | | //更新商户统计 |
| | | /*ShopTotalChangeDto shopTotalChangeDto = new ShopTotalChangeDto(); |
| | | shopTotalChangeDto.setShopId(order.getShopId()); |
| | | shopTotalChangeDto.setOrderType(1); |
| | | shopTotalChangeDto.setCycleMoney(cycleMoney); |
| | | shopTotalChangeDto.setServiceMoney(serviceMoney); |
| | | shopTotalChangeDto.setExperienceMoney(experienceMoney); |
| | | shopTotalChangeDto.setGoodsMoney(goodsMoney); |
| | | remoteShopService.changeShopTotal(shopTotalChangeDto);*/ |
| | | //创建支付记录 |
| | | PayRecord payRecord = new PayRecord(); |
| | | payRecord.setDelFlag(0); |
| | |
| | | mgtTotalOrderTotalVo.setCycleTotal(0); |
| | | mgtTotalOrderTotalVo.setExperienceTotal(0); |
| | | mgtTotalOrderTotalVo.setServiceTotal(0); |
| | | mgtTotalOrderTotalVo.setItemTotal(0); |
| | | mgtTotalOrderTotalVo.setOrderMoney(new BigDecimal("0")); |
| | | mgtTotalOrderTotalVo.setOnlineMoney(new BigDecimal("0")); |
| | | mgtTotalOrderTotalVo.setOfflineMoney(new BigDecimal("0")); |
| | |
| | | mgtTotalOrderTotalVo.setCycleMoney(new BigDecimal("0")); |
| | | mgtTotalOrderTotalVo.setExperienceMoney(new BigDecimal("0")); |
| | | mgtTotalOrderTotalVo.setServiceMoney(new BigDecimal("0")); |
| | | mgtTotalOrderTotalVo.setItemMoney(new BigDecimal("0")); |
| | | mgtTotalOrderTotalVo.setOrderTotalKey(new String[0]); |
| | | mgtTotalOrderTotalVo.setOrderTotalValue(new Integer[0]); |
| | | mgtTotalOrderTotalVo.setOrderMoneyValue(new BigDecimal[0]); |
| | |
| | | mgtTotalOrderTotalVo.setCycleMoney(BigDecimal.ZERO); |
| | | mgtTotalOrderTotalVo.setServiceTotal(0); |
| | | mgtTotalOrderTotalVo.setServiceMoney(BigDecimal.ZERO); |
| | | mgtTotalOrderTotalVo.setItemTotal(0); |
| | | mgtTotalOrderTotalVo.setItemMoney(BigDecimal.ZERO); |
| | | mgtTotalOrderTotalVo.setExperienceTotal(0); |
| | | mgtTotalOrderTotalVo.setExperienceMoney(BigDecimal.ZERO); |
| | | if (MgtMapIntTotalVoGoodsType != null && MgtMapIntTotalVoGoodsType.size() > 0) { |
| | |
| | | } else if (MgtMapIntTotalVoGoodsType.get(i).getMapKey().equals("4")) { |
| | | mgtMapIntTotalVo.setMapKey("单品"); |
| | | mgtMapBigTotalVo.setMapKey("单品"); |
| | | mgtTotalOrderTotalVo.setItemTotal(mgtTotalOrderTotalVo.getItemTotal() + MgtMapIntTotalVoGoodsType.get(i).getMapValueFirst()); |
| | | mgtTotalOrderTotalVo.setItemMoney(mgtTotalOrderTotalVo.getItemMoney().add(MgtMapIntTotalVoGoodsType.get(i).getMapValueSecond())); |
| | | noGoods = false; |
| | | } |
| | | goodsTypeTotalList.add(mgtMapIntTotalVo); |
| | |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void payBack(PartnerTransactionsResult transaction, BigDecimal feeAmount) { |
| | | log.info("订单支付回调---"+transaction.toString()); |
| | | // Order order = this.getById(orderId); |
| | | // 更新订单状态 outTradeNo |
| | | String outTradeNo = transaction.getOutTradeNo(); |
| | | Order order = this.getByOutTradeNo(outTradeNo); |
| | |
| | | } |
| | | //更新商品统计 |
| | | remoteGoodsService.changeGoodsTotal(goodsTotalChangeDtoList); |
| | | // 更新商户统计信息 |
| | | /*ShopTotalChangeDto shopTotalChangeDto = new ShopTotalChangeDto(); |
| | | shopTotalChangeDto.setShopId(order.getShopId()); |
| | | shopTotalChangeDto.setOrderType(1); |
| | | shopTotalChangeDto.setCycleMoney(cycleMoney); |
| | | shopTotalChangeDto.setServiceMoney(serviceMoney); |
| | | shopTotalChangeDto.setExperienceMoney(experienceMoney); |
| | | shopTotalChangeDto.setGoodsMoney(goodsMoney); |
| | | remoteShopService.changeShopTotal(shopTotalChangeDto);*/ |
| | | // 初始化会员统计信息 |
| | | MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto(); |
| | | memberTotalChangeDto.setUserId(order.getUserId()); |
| | | // 如果存在积分兑换比例,则计算积分 2023-09-14改为核销后获取积分 |
| | | /*if (redisService.hasKey(SecurityConstant.PAY_MONEY_INTEGRAL)) { |
| | | Integer moneyValue = redisService.getCacheObject(SecurityConstant.PAY_MONEY_INTEGRAL); |
| | | BigDecimal moneyValueBig = BigDecimal.valueOf(moneyValue); |
| | | BigDecimal integralBig = moneyValueBig.multiply(order.getPayMoney()).setScale(0,BigDecimal.ROUND_HALF_UP); |
| | | Integer integral = Integer.valueOf(integralBig.toString()); |
| | | if(integral>0){ |
| | | memberTotalChangeDto.setChangeIntegral(integral); |
| | | memberTotalChangeDto.setTypeIntegral(1); |
| | | memberTotalChangeDto.setOrderId(orderId); |
| | | memberTotalChangeDto.setOrderNo(order.getOrderNo()); |
| | | } |
| | | }*/ |
| | | // 设置会员支付金额和支付时间 |
| | | memberTotalChangeDto.setPayMoney(order.getPayMoney()); |
| | | memberTotalChangeDto.setPayTime(new Date()); |
| | |
| | | remoteCouponService.backMemberCoupon(memberCouponSJ.toString()); |
| | | } |
| | | } |
| | | // 更新商户统计信息 |
| | | /*ShopTotalChangeDto shopTotalChangeDto = new ShopTotalChangeDto(); |
| | | shopTotalChangeDto.setOrderType(2); |
| | | shopTotalChangeDto.setShopId(order.getShopId()); |
| | | shopTotalChangeDto.setCycleMoney(cycleMoney); |
| | | shopTotalChangeDto.setServiceMoney(serviceMoney); |
| | | shopTotalChangeDto.setExperienceMoney(experienceMoney); |
| | | shopTotalChangeDto.setGoodsMoney(goodsMoney); |
| | | remoteShopService.changeShopTotal(shopTotalChangeDto);*/ |
| | | // 初始化会员统计信息 |
| | | MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto(); |
| | | memberTotalChangeDto.setUserId(order.getUserId()); |
| | | // 如果存在积分兑换比例,则计算积分 2023-09-14改为核销后获取积分 |
| | | /*if (redisService.hasKey(SecurityConstant.PAY_MONEY_INTEGRAL)) { |
| | | Integer moneyValue = redisService.getCacheObject(SecurityConstant.PAY_MONEY_INTEGRAL); |
| | | BigDecimal moneyValueBig = BigDecimal.valueOf(moneyValue); |
| | | BigDecimal integralBig = moneyValueBig.multiply(order.getPayMoney()); |
| | | Integer integral = Integer.valueOf(integralBig.toString()); |
| | | memberTotalChangeDto.setChangeIntegral(integral); |
| | | memberTotalChangeDto.setTypeIntegral(2); |
| | | }*/ |
| | | // 设置会员支付金额和支付时间 |
| | | memberTotalChangeDto.setPayMoney(order.getPayMoney().negate()); |
| | | // 根据商品存在状态,设置会员统计信息 |