| | |
| | | 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{ |
| | |
| | | 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); |