| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.douyin.openapi.client.models.*; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.*; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum; |
| | | import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingNotifyResult; |
| | |
| | | import com.github.binarywang.wxpay.service.WxPayService; |
| | | import com.google.common.collect.Lists; |
| | | import com.google.gson.Gson; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.UserStatus; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.text.Convert; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.ip.IpUtils; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.utils.CodeFactoryUtil; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.goods.api.domain.TLotteryEvent; |
| | | import com.ruoyi.goods.api.service.LotteryEventClient; |
| | | import com.ruoyi.order.config.WxPayConfiguration; |
| | | import com.ruoyi.order.domain.dto.*; |
| | | import com.ruoyi.order.domain.pojo.account.OrderPayment; |
| | |
| | | import com.ruoyi.order.service.account.ProfitSharingService; |
| | | import com.ruoyi.order.service.order.*; |
| | | import com.ruoyi.order.util.HuiFuTianXiaUtil; |
| | | import com.ruoyi.order.util.douyin.OrderUtil; |
| | | import com.ruoyi.order.util.douyin.VerifyUtil; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.constant.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constant.SecurityConstant; |
| | |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.domain.vo.*; |
| | | import com.ruoyi.system.api.model.QwH5LoginVo; |
| | | import com.ruoyi.system.api.model.QwUserDetailDto; |
| | | import com.ruoyi.system.api.service.*; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | 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; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.NumberFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | |
| | | |
| | | @Resource |
| | | private OrderPaymentService orderPaymentService; |
| | | |
| | | |
| | | @Resource |
| | | private ProfitSharingService profitSharingService; |
| | | |
| | | |
| | | @Resource |
| | | private OrderRefundService orderRefundService; |
| | | |
| | | |
| | | @Value("${wx.pay.callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private LotteryEventClient lotteryEventClient; |
| | | |
| | | |
| | | /** |
| | | * @description: buyGoods |
| | | * @param: appSureOrderDto |
| | |
| | | if(shop!=null&&shop.getShopStatus()!=1){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_CLOSED); |
| | | } |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | // 初始化订单对象 |
| | | AppSureOrderVo appSureOrderVo = new AppSureOrderVo(); |
| | | // 初始化订单商品列表 |
| | |
| | | String goodsId; |
| | | Integer buyNum; |
| | | BigDecimal buyNumBig; |
| | | String memberCouponId; |
| | | Long memberCouponId; |
| | | Goods goods; |
| | | BigDecimal goodsPrice; |
| | | BigDecimal goodsTotalPrice; |
| | |
| | | BigDecimal orderPayDeposit = new BigDecimal("0.00"); |
| | | BigDecimal orderPayMoney = new BigDecimal("0.00"); |
| | | // 遍历购买商品列表 |
| | | HashSet<String> userCouponIdSet = new HashSet<>(); |
| | | HashSet<Long> userCouponIdSet = new HashSet<>(); |
| | | for (AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList) { |
| | | appSureOrderGoodsVo = new AppSureOrderGoodsVo(); |
| | | discountMoney = BigDecimal.ZERO; |
| | |
| | | ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | if (shopGoods != null) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | } else { |
| | | //经销商定制价格 |
| | | appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | | appShopGoodsGetDto.setShopId(belongShop.getShopId()); |
| | | shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | } |
| | | } |
| | | appSureOrderGoodsVo.setGoodsPrice(goodsPrice); |
| | | buyNumBig = BigDecimal.valueOf(buyNum); |
| | | goodsTotalPrice = goodsPrice.multiply(buyNumBig); |
| | | goodsRealPrice = goodsTotalPrice; |
| | | // 处理优惠券 |
| | | if (StringUtils.isNotBlank(memberCouponId)) { |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); |
| | | if (null != memberCouponId) { |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId.toString()); |
| | | System.err.println(JSON.toJSONString(appMemberCouponVoMap)); |
| | | System.err.println(memberCouponId); |
| | | System.err.println(JSON.toJSONString(appMemberCouponVo)); |
| | | if (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId)) { |
| | | couponType = appMemberCouponVo.getCouponType(); |
| | | if (couponType == 1 && appMemberCouponVo.getMoneyThreshold() != null && appMemberCouponVo.getDiscountMoney() != null) { |
| | |
| | | goodsRealPrice = goodsTotalPrice.subtract(discountMoney); |
| | | useCoupon = 1; |
| | | userCouponIdSet.add(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId.toString()); |
| | | } |
| | | } else if (couponType == 2 && appMemberCouponVo.getDiscountPercent() != null) { |
| | | discountPercent = appMemberCouponVo.getDiscountPercent(); |
| | |
| | | discountMoney = goodsTotalPrice.subtract(goodsRealPrice); |
| | | useCoupon = 1; |
| | | userCouponIdSet.add(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId.toString()); |
| | | } else if (couponType == 3 && appMemberCouponVo.getDiscountMoney() != null) { |
| | | discountMoney = appMemberCouponVo.getDiscountMoney(); |
| | | if (goodsTotalPrice.compareTo(discountMoney) > 0) { |
| | |
| | | } |
| | | useCoupon = 1; |
| | | userCouponIdSet.add(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId); |
| | | appSureOrderGoodsVo.setMemberCouponId(memberCouponId.toString()); |
| | | } |
| | | } |
| | | } |
| | |
| | | sureOrderGoodsVo.setAppMemberCouponVoList(appGoodsMemberCouponVoList); |
| | | } |
| | | } |
| | | /*if (appMemberCouponVoList != null && !appMemberCouponVoList.isEmpty()) { |
| | | // 获取商品关联优惠券 |
| | | appGoodsMemberCouponVoList = new ArrayList<>(); |
| | | for(AppSureOrderGoodsVo sureOrderGoodsVo : appSureOrderGoodsVoList){ |
| | | for (AppMemberCouponVo entity : appMemberCouponVoList) { |
| | | if (StringUtils.isBlank(entity.getRelGoodsIds())) { |
| | | if (entity.getCouponType() == 1 && entity.getMoneyThreshold() != null && entity.getDiscountMoney() != null) { |
| | | moneyThreshold = entity.getMoneyThreshold(); |
| | | if (sureOrderGoodsVo.getGoodsTotalPrice().compareTo(moneyThreshold) >= 0) { |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | } else if (entity.getRelGoodsIds().contains(sureOrderGoodsVo.getGoodsId())) { |
| | | if (entity.getCouponType() == 1 && entity.getMoneyThreshold() != null && entity.getDiscountMoney() != null) { |
| | | moneyThreshold = entity.getMoneyThreshold(); |
| | | if (sureOrderGoodsVo.getGoodsTotalPrice().compareTo(moneyThreshold) >= 0) { |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | if(userCouponIdSet==null||!userCouponIdSet.contains(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | }else{ |
| | | if(sureOrderGoodsVo.getMemberCouponId()!=null&&sureOrderGoodsVo.getMemberCouponId().equals(entity.getMemberCouponId())){ |
| | | appGoodsMemberCouponVoList.add(entity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | sureOrderGoodsVo.setAppMemberCouponVoList(appGoodsMemberCouponVoList); |
| | | } |
| | | }*/ |
| | | // 设置订单相关金额 |
| | | appSureOrderVo.setOrderGoodsMoney(orderGoodsMoney); |
| | | appSureOrderVo.setCouponDiscount(couponDiscount); |
| | |
| | | ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | if (shopGoods != null) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | } else { |
| | | //经销商定制价格 |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | appShopGoodsGetDto = new AppShopGoodsGetDto(); |
| | | appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | | appShopGoodsGetDto.setShopId(belongShop.getShopId()); |
| | | shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | } |
| | | } |
| | | appPanicBuyVo.setGoodsPrice(goodsPrice); |
| | | buyNumBig = BigDecimal.valueOf(buyNum); |
| | |
| | | BigDecimal buyNumBig; |
| | | Integer serviceNum; |
| | | Integer goodsNum = 0; |
| | | String memberCouponId; |
| | | Long memberCouponId; |
| | | Goods goods = null; |
| | | GoodsFile goodsFile; |
| | | BigDecimal goodsPrice; |
| | |
| | | if (shopGoods != null) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | serviceNum = shopGoods.getServiceNum(); |
| | | } else { |
| | | //经销商定制价格 |
| | | Shop shop = remoteShopService.getShop(appPlaceOrderDto.getShopId()).getData(); |
| | | Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData(); |
| | | appShopGoodsGetDto = new AppShopGoodsGetDto(); |
| | | appShopGoodsGetDto.setGoodsId(goods.getGoodsId()); |
| | | appShopGoodsGetDto.setShopId(belongShop.getShopId()); |
| | | shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData(); |
| | | if (1 == belongShop.getModifyPricePermission() && null != shopGoods) { |
| | | goodsPrice = shopGoods.getSalesPrice(); |
| | | serviceNum = shopGoods.getServiceNum(); |
| | | } |
| | | } |
| | | appSureOrderGoodsVo.setGoodsPrice(goodsPrice); |
| | | // 计算商品总价 |
| | |
| | | goodsRealPrice = goodsTotalPrice; |
| | | // 如果使用了优惠券,计算优惠后的价格 |
| | | if (memberCouponId != null) { |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId.toString()); |
| | | if(null == appMemberCouponVo){ |
| | | throw new ServiceException("优惠券已使用"); |
| | | } |
| | | // 如果优惠券适用于该商品 |
| | | if (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId)) { |
| | | couponType = appMemberCouponVo.getCouponType(); |
| | |
| | | discountMoney = goodsTotalPrice; |
| | | } |
| | | } |
| | | memberCouponSJ.add(memberCouponId); |
| | | memberCouponSJ.add(memberCouponId + ""); |
| | | } |
| | | appSureOrderGoodsVo.setUseCoupon(useCoupon); |
| | | appSureOrderGoodsVo.setGoodsTotalPrice(goodsTotalPrice); |
| | |
| | | appPlaceOrderVo.setPaySign(payArr[5]); |
| | | appPlaceOrderVo.setPrepayId(orderPayment.getPrepayId()); |
| | | // 返回AppPlaceOrderVo对象 |
| | | List<TLotteryEvent> data = lotteryEventClient.getLotteryEventList(2).getData(); |
| | | if (data.size() > 0) { |
| | | long count = data.stream().filter(s -> s.getPayMoney().compareTo(order.getPayMoney()) >= 0).count(); |
| | | appPlaceOrderVo.setLotteryDraw(count > 0); |
| | | } else { |
| | | appPlaceOrderVo.setLotteryDraw(false); |
| | | } |
| | | return appPlaceOrderVo; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public MerHomeShopTotalVo getMerHomeTotal(MerHomeShopTotalVo merHomeShopTotalVo) { |
| | | Long shopId = merHomeShopTotalVo.getShopId(); |
| | | // 查询用户信息 |
| | | QwUserDetailDto qwUserDetail = new QwUserDetailDto(); |
| | | Long userId = SecurityUtils.getUserId(); |
| | | qwUserDetail.setUserid(userId.toString()); |
| | | // 查询用户信息 |
| | | R<QwH5LoginVo> userResult = remoteShopService.qwH5Login(qwUserDetail); |
| | | if(userResult==null){ |
| | | throw new ServiceException(AppErrorConstant.USER_NO_SHOP); |
| | | } |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | if (401 == userResult.getCode()) |
| | | { |
| | | throw new ServiceException("商户已被冻结,请联系管理员",401); |
| | | } |
| | | QwH5LoginVo userInfo = userResult.getData(); |
| | | SysUser user = userInfo.getSysUser(); |
| | | String username = user.getUserName(); |
| | | // IP黑名单校验 |
| | | String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); |
| | | if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) |
| | | { |
| | | throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); |
| | | } |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已停用"); |
| | | } |
| | | // 查询用户商户 |
| | | R<ShopRelUserVo> shopResult = remoteShopService.getShopByUserId(user.getUserId()); |
| | | if (R.FAIL == userResult.getCode()) { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | ShopRelUserVo shopInfo = shopResult.getData(); |
| | | if(null == shopInfo){ |
| | | throw new ServiceException("未查询到商户信息"); |
| | | } |
| | | Long shopId = shopInfo.getShopId(); |
| | | Shop shop = remoteShopService.getShop(shopId).getData(); |
| | | if(-1 == shop.getShopStatus()){ |
| | | throw new ServiceException("对应商户已删除,请联系管理员"); |
| | | } |
| | | if(0 == shop.getShopStatus()){ |
| | | throw new ServiceException("对应商户已冻结,请联系管理员"); |
| | | } |
| | | if(2 == shop.getShopStatus()){ |
| | | throw new ServiceException("对应商户已终止合作,请联系管理员"); |
| | | } |
| | | |
| | | |
| | | shopId = merHomeShopTotalVo.getShopId(); |
| | | |
| | | //获取今日到店 |
| | | Integer todayShop = userServiceRecordService.countShopServicePerson(shopId); |
| | | //获取待处理订单和营业额 |
| | |
| | | merVerifyOrderVo.setAppUserOrderGoodsPageVoList(appUserOrderGoodsPageVoList); |
| | | merVerifyOrderVo.setPayType(order.getPayType()); |
| | | merVerifyOrderVo.setRealReceiveMoney(order.getChangeReceivableMoney()); |
| | | if(order.getPayType()==1){ |
| | | if (order.getPayType() == 1) { |
| | | merVerifyOrderVo.setReceiveMoney(order.getPayMoney()); |
| | | }else{ |
| | | if(order.getOfflinePayMoney()!=null){ |
| | | } else { |
| | | if (order.getOfflinePayMoney() != null) { |
| | | merVerifyOrderVo.setReceiveMoney(order.getOfflinePayMoney()); |
| | | }else{ |
| | | } else { |
| | | merVerifyOrderVo.setReceiveMoney(BigDecimal.ZERO); |
| | | } |
| | | } |
| | |
| | | // 返回结果 |
| | | return merVerifyOrderVo; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public MerVerifyOrderVo verifyOrderDouYin(String orderId, Long shopId) { |
| | | CertificatePrepareResponseData data = VerifyUtil.certificatePrepare(orderId); |
| | | if (null == data) { |
| | | throw new ServiceException("查询券信息失败"); |
| | | } |
| | | List<CertificatePrepareResponseDataCertificatesItem> itemList = data.getCertificates(); |
| | | if (null == itemList || itemList.isEmpty()) { |
| | | throw new ServiceException("查询券信息失败"); |
| | | } |
| | | CertificatePrepareResponseDataCertificatesItem certificatesItem = itemList.get(0); |
| | | //商品信息 |
| | | CertificatePrepareResponseDataCertificatesItemSku sku = certificatesItem.getSku(); |
| | | //次卡信息 |
| | | CertificatePrepareResponseDataCertificatesItemTimeCard timeCard = certificatesItem.getTimeCard(); |
| | | //券的状态 |
| | | Number status = certificatesItem.getStatus(); |
| | | // 创建返回对象 |
| | | MerVerifyOrderVo merVerifyOrderVo = new MerVerifyOrderVo(); |
| | | // 设置返回对象的属性值 |
| | | merVerifyOrderVo.setOrderId(orderId); |
| | | merVerifyOrderVo.setOrderFrom(6); |
| | | merVerifyOrderVo.setOrderStatus(status.intValue() == 1 ? 2 : 3); |
| | | List<AppUserOrderGoodsPageVo> appUserOrderGoodsPageVoList = new ArrayList<>(); |
| | | AppUserOrderGoodsPageVo orderGoodsPageVo = new AppUserOrderGoodsPageVo(); |
| | | orderGoodsPageVo.setGoodsName(sku.getTitle()); |
| | | appUserOrderGoodsPageVoList.add(orderGoodsPageVo); |
| | | merVerifyOrderVo.setAppUserOrderGoodsPageVoList(appUserOrderGoodsPageVoList); |
| | | merVerifyOrderVo.setLaveTime(timeCard.getTimesCount() - timeCard.getTimesUsed()); |
| | | // 返回结果 |
| | | return merVerifyOrderVo; |
| | | } |
| | | |
| | | /** |
| | | * 确认核销订单 |
| | | * |
| | |
| | | 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); |
| | |
| | | remoteMemberService.changeMemberTotal(memberTotalChangeDto); |
| | | return merVerifyOrderVo; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * @description 分账实现 |
| | | * @author jqs |
| | | * @date 2023/9/8 11:56 |
| | | * 核销抖音券 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public MerVerifyOrderVo sureVerifyOrderDouYin(MerVerifyOrderDto merVerifyOrderDto) { |
| | | String phone = merVerifyOrderDto.getPhone(); |
| | | String orderId = merVerifyOrderDto.getOrderId(); |
| | | Long shopId = merVerifyOrderDto.getShopId(); |
| | | //获取核销商户 |
| | | Shop shop = remoteShopService.getShop(shopId).getData(); |
| | | CertificatePrepareResponseData data = VerifyUtil.certificatePrepare(orderId); |
| | | if (null == data) { |
| | | throw new ServiceException("查询券信息失败"); |
| | | } |
| | | List<CertificatePrepareResponseDataCertificatesItem> itemList = data.getCertificates(); |
| | | if (null == itemList || itemList.isEmpty()) { |
| | | throw new ServiceException("查询券信息失败"); |
| | | } |
| | | CertificatePrepareResponseDataCertificatesItem certificatesItem = itemList.get(0); |
| | | Number status = certificatesItem.getStatus(); |
| | | if (status.intValue() == 2) { |
| | | throw new ServiceException("该抖音券不能重复核销"); |
| | | } |
| | | if (status.intValue() != 1) { |
| | | throw new ServiceException("抖音券核销失败"); |
| | | } |
| | | String encryptedCode = certificatesItem.getEncryptedCode(); |
| | | List<CertificateVerifyResponseDataVerifyResultsItem> items = VerifyUtil.certificateVerify(data.getVerifyToken(), shop.getPoiId(), new ArrayList<String>() {{ |
| | | add(encryptedCode); |
| | | }}); |
| | | if (null == items || items.isEmpty()) { |
| | | throw new ServiceException("抖音券核销失败"); |
| | | } |
| | | Order one = this.getOne(new LambdaQueryWrapper<Order>().eq(Order::getTripartiteOrderId, data.getOrderId())); |
| | | if (null != one) { |
| | | throw new ServiceException("该抖音券不能重复核销"); |
| | | } |
| | | |
| | | TradeOrderQueryResponseData tradeOrderQueryResponseData = OrderUtil.queryOrderList(1, 10, data.getOrderId()); |
| | | //原始金额 |
| | | BigDecimal originAmount = BigDecimal.ZERO; |
| | | //支付金额 |
| | | BigDecimal payAmount = BigDecimal.ZERO; |
| | | //优惠金额 |
| | | BigDecimal payDiscountAmount = BigDecimal.ZERO; |
| | | if (null != tradeOrderQueryResponseData) { |
| | | TradeOrderQueryResponseDataOrdersItem ordersItem = tradeOrderQueryResponseData.getOrders().get(0); |
| | | TradeOrderQueryResponseDataOrdersItemAmountInfo amountInfo = ordersItem.getAmountInfo(); |
| | | originAmount = BigDecimal.valueOf(amountInfo.getOriginAmount()).divide(new BigDecimal(100)); |
| | | payAmount = BigDecimal.valueOf(amountInfo.getPayAmount()).divide(new BigDecimal(100)); |
| | | payDiscountAmount = BigDecimal.valueOf(amountInfo.getPayDiscountAmount()).divide(new BigDecimal(100)); |
| | | } |
| | | |
| | | Date nowTime = new Date(); |
| | | Member member = remoteMemberService.getMemberByMobile(phone).getData(); |
| | | //开始添加订单数据 |
| | | Order order = new Order(); |
| | | order.setOrderId(IdUtils.fastSimpleUUID()); |
| | | order.setDelFlag(0); |
| | | order.setOrderStatus(3); |
| | | order.setOrderNo(CodeFactoryUtil.getShopOrderNo()); |
| | | order.setOrderFrom(6); |
| | | order.setShopId(shopId); |
| | | order.setUserId(member.getUserId()); |
| | | order.setOrderMoney(originAmount); |
| | | order.setDiscountMoney(payDiscountAmount); |
| | | order.setReceivableMoney(payAmount); |
| | | order.setPayType(1); |
| | | order.setPayMoney(payAmount); |
| | | order.setOnlinePayMoney(payAmount); |
| | | order.setOrderRemark("抖音订单"); |
| | | order.setCreateTime(nowTime); |
| | | order.setPayTime(nowTime); |
| | | order.setTripartiteOrderId(data.getOrderId()); |
| | | |
| | | //绑定用户判断核销商户 |
| | | if (member.getBindingFlag() == 1) { |
| | | if (!member.getRelationShopId().equals(shopId)) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | } |
| | | order.setUseTime(nowTime); |
| | | order.setUseUserId(merVerifyOrderDto.getUserId()); |
| | | order.setCloseFlag(1); |
| | | this.save(order); |
| | | //创建服务商品 |
| | | //获取商品信息(商品简介,调理问题) |
| | | //商品信息 |
| | | CertificatePrepareResponseDataCertificatesItemSku sku = certificatesItem.getSku(); |
| | | //次卡信息 |
| | | CertificatePrepareResponseDataCertificatesItemTimeCard timeCard = certificatesItem.getTimeCard(); |
| | | |
| | | OrderGoods orderGoods = new OrderGoods(); |
| | | orderGoods.setOrderGoodsId(IdUtils.simpleUUID()); |
| | | orderGoods.setDelFlag(0); |
| | | orderGoods.setOrderId(order.getOrderId()); |
| | | orderGoods.setBuyNum(timeCard.getTimesCount()); |
| | | orderGoods.setCycleNumFlag(1); |
| | | orderGoods.setServiceNum(timeCard.getTimesCount()); |
| | | orderGoods.setGoodsType(2); |
| | | orderGoods.setGoodsName(sku.getTitle()); |
| | | orderGoodsService.save(orderGoods); |
| | | |
| | | ConsumerGoods consumerGoods = new ConsumerGoods(); |
| | | consumerGoods.setConsumerGoodsId(IdUtils.simpleUUID()); |
| | | consumerGoods.setDelFlag(0); |
| | | consumerGoods.setServiceStatus(1); |
| | | consumerGoods.setShopId(order.getShopId()); |
| | | consumerGoods.setUserId(order.getUserId()); |
| | | consumerGoods.setOrderId(orderId); |
| | | consumerGoods.setOrderGoodsId(orderGoods.getOrderGoodsId()); |
| | | consumerGoods.setGoodsName(sku.getTitle()); |
| | | consumerGoods.setCycleNumFlag(1); |
| | | consumerGoods.setServiceNum(timeCard.getTimesCount()); |
| | | consumerGoods.setCreateTime(nowTime); |
| | | consumerGoods.setGoodsType(2); |
| | | consumerGoods.setSourceFrom(1); |
| | | consumerGoodsService.save(consumerGoods); |
| | | //生成返回 |
| | | MerVerifyOrderVo merVerifyOrderVo = new MerVerifyOrderVo(); |
| | | merVerifyOrderVo.setOrderId(orderId); |
| | | merVerifyOrderVo.setOrderNo(order.getOrderNo()); |
| | | merVerifyOrderVo.setOrderStatus(order.getOrderStatus()); |
| | | merVerifyOrderVo.setOrderFrom(order.getOrderFrom()); |
| | | merVerifyOrderVo.setOrderGoodsMoney(order.getOrderMoney()); |
| | | merVerifyOrderVo.setCouponDiscount(order.getCouponMoney()); |
| | | merVerifyOrderVo.setReceivableDeposit(order.getReceivableDeposit()); |
| | | merVerifyOrderVo.setPayMoney(order.getPayMoney()); |
| | | merVerifyOrderVo.setOrderRemark(order.getOrderRemark()); |
| | | merVerifyOrderVo.setAppUserOrderGoodsPageVoList(new ArrayList<AppUserOrderGoodsPageVo>() {{ |
| | | add(new AppUserOrderGoodsPageVo() {{ |
| | | setOrderGoodsId(orderGoods.getOrderGoodsId()); |
| | | setGoodsName(orderGoods.getGoodsName()); |
| | | setGoodsType(orderGoods.getGoodsType()); |
| | | setBuyNum(orderGoods.getBuyNum()); |
| | | }}); |
| | | }}); |
| | | merVerifyOrderVo.setCreateTime(order.getCreateTime()); |
| | | merVerifyOrderVo.setPayTime(order.getPayTime()); |
| | | merVerifyOrderVo.setUseTime(order.getUseTime()); |
| | | merVerifyOrderVo.setPayType(order.getPayType()); |
| | | merVerifyOrderVo.setRealReceiveMoney(order.getChangeReceivableMoney()); |
| | | //根据支付方式返回应收金额和已收金额 |
| | | if (order.getPayType() == 1) { |
| | | merVerifyOrderVo.setReceivableMoney(order.getOrderMoney().subtract(order.getPayMoney())); |
| | | merVerifyOrderVo.setReceiveMoney(order.getPayMoney()); |
| | | } else { |
| | | merVerifyOrderVo.setReceivableMoney(order.getOrderMoney().subtract(order.getCouponMoney()).subtract(order.getReceivableDeposit())); |
| | | if (order.getOfflinePayMoney() != null) { |
| | | merVerifyOrderVo.setReceiveMoney(order.getOfflinePayMoney()); |
| | | } else { |
| | | merVerifyOrderVo.setReceiveMoney(BigDecimal.ZERO); |
| | | } |
| | | } |
| | | merVerifyOrderVo.setUnReceiveMoney(merVerifyOrderVo.getRealReceiveMoney().subtract(merVerifyOrderVo.getReceiveMoney())); |
| | | merVerifyOrderVo.setUserId(order.getUserId()); |
| | | merVerifyOrderVo.setUserName(member.getRealName()); |
| | | merVerifyOrderVo.setUserMobile(member.getMobile()); |
| | | merVerifyOrderVo.setCloseFlag(order.getCloseFlag()); |
| | | //判断用户是否绑定 2023-09-05需求改变核销时绑定用户 |
| | | if (member.getBindingFlag() != 1) { |
| | | //绑定商户 |
| | | AppMemberBindingDto appMemberBindingDto = new AppMemberBindingDto(); |
| | | appMemberBindingDto.setShopId(order.getShopId()); |
| | | appMemberBindingDto.setUserId(order.getUserId()); |
| | | appMemberBindingDto.setBindingFlag(1); |
| | | if (order.getOrderFrom() == 1) { |
| | | appMemberBindingDto.setBindingType(1); |
| | | } else if (order.getOrderFrom() == 2) { |
| | | appMemberBindingDto.setBindingType(2); |
| | | } |
| | | remoteMemberService.updateMemberBinding(appMemberBindingDto); |
| | | order.setNewMemberFlag(1); |
| | | } else { |
| | | order.setNewMemberFlag(0); |
| | | } |
| | | this.saveOrUpdate(order); |
| | | //更新用户积分和消费统计 |
| | | MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto(); |
| | | memberTotalChangeDto.setUserId(order.getUserId()); |
| | | // 如果存在积分兑换比例,则计算积分 |
| | | 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.getOnlinePayMoney()).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.setConsumeTime(nowTime); |
| | | remoteMemberService.changeMemberTotal(memberTotalChangeDto); |
| | | return merVerifyOrderVo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @param orderId |
| | | * @param orderNo |
| | | * @param shopId |
| | | * @param orderMoney |
| | | * @param orderFrom |
| | | * @return void |
| | | * @return void |
| | | * @description 分账实现 |
| | | * @author jqs |
| | | * @date 2023/9/8 11:56 |
| | | */ |
| | | private void submitProfitSharing(String orderId, String orderNo, Long shopId, BigDecimal orderMoney, Integer orderFrom) { |
| | | String sendMessage = ""; |
| | |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public MerVerifyCouponVo sureVerifyCoupon(MerVerifyCouponDto merVerifyCouponDto) { |
| | | MerVerifyCouponGetVo verifyCouponGetVo = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()).getData(); |
| | | R<MerVerifyCouponGetVo> verifyCoupon = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()); |
| | | if(verifyCoupon.getCode() != 200){ |
| | | throw new ServiceException(verifyCoupon.getMsg()); |
| | | } |
| | | MerVerifyCouponGetVo verifyCouponGetVo = verifyCoupon.getData(); |
| | | MemberCoupon memberCoupon = verifyCouponGetVo.getMemberCoupon(); |
| | | ShopRelUserVo shopRelUserVo = remoteShopService.getShopByUserId(merVerifyCouponDto.getUserId()).getData(); |
| | | Long userId = verifyCouponGetVo.getUserId(); |
| | |
| | | Long shopId = shopRelUserVo.getShopId(); |
| | | Shop shop = remoteShopService.getShop(shopId).getData(); |
| | | //平台奖品判断 |
| | | if (memberGiftRecord.getGiftFrom() == 1) { |
| | | if (memberGiftRecord.getGiftFrom() == 1 && memberGiftRecord.getPrizeFrom() == 1) { |
| | | BirthdayCard birthdayCard = remoteMemberService.getBirthdayCard().getData(); |
| | | //判断生日活动状态 |
| | | if(birthdayCard!=null&&birthdayCard.getCardStatus()==1){ |
| | | if (birthdayCard != null && birthdayCard.getCardStatus() == 1) { |
| | | shop = remoteShopService.getShop(shopId).getData(); |
| | | //判断指定区域全部店铺 |
| | | if(birthdayCard.getAreaFlag()==2&&birthdayCard.getShopFlag()==1&&!StringUtils.checkString(birthdayCard.getDesignatedArea(),shop.getShopCityCode())){ |
| | | if (birthdayCard.getAreaFlag() == 2 && birthdayCard.getShopFlag() == 1 && !StringUtils.checkString(birthdayCard.getDesignatedArea(), shop.getShopCityCode())) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | //判断指定店铺 |
| | | if(birthdayCard.getShopFlag()==2&&!StringUtils.checkString(birthdayCard.getApplicableShop(),shopId.toString())){ |
| | | if (birthdayCard.getShopFlag() == 2 && !StringUtils.checkString(birthdayCard.getApplicableShop(), shopId.toString())) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | }else{ |
| | | } else { |
| | | throw new ServiceException(AppErrorConstant.BIRTHDAY_CARD_ERROR); |
| | | } |
| | | } |
| | |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | Member member = remoteMemberService.getMember(memberGiftRecord.getUserId()).getData(); |
| | | |
| | | |
| | | merVerifyAwardVo.setUserName(member.getRealName()); |
| | | merVerifyAwardVo.setUserMobile(member.getMobile()); |
| | | if (memberGiftRecord.getGiftFrom() == 1) { |
| | | merVerifyAwardVo.setGiftFrom("平台生日卡"); |
| | | if (memberGiftRecord.getPrizeFrom() == 1) { |
| | | if (memberGiftRecord.getGiftFrom() == 1) { |
| | | merVerifyAwardVo.setGiftFrom("平台生日卡"); |
| | | } else { |
| | | merVerifyAwardVo.setGiftFrom("商户生日卡"); |
| | | } |
| | | } else { |
| | | merVerifyAwardVo.setGiftFrom("商户生日卡"); |
| | | merVerifyAwardVo.setGiftFrom("抽奖"); |
| | | } |
| | | merVerifyAwardVo.setGiftType(memberGiftRecord.getGiftType()); |
| | | List<BirthdayGiftSendDto> giftSendDtoList = new ArrayList<>(); |
| | | BirthdayGiftSendDto birthdayGiftSendDto = new BirthdayGiftSendDto(); |
| | | switch (memberGiftRecord.getGiftType()) { |
| | | case 1: |
| | | merVerifyAwardVo.setGiftName(memberGiftRecord.getCouponName()); |
| | | merVerifyAwardVo.setGiftNumber(Double.valueOf(memberGiftRecord.getCouponNumber())); |
| | | birthdayGiftSendDto.setUserId(memberGiftRecord.getUserId()); |
| | | birthdayGiftSendDto.setGiftType(memberGiftRecord.getGiftType()); |
| | | birthdayGiftSendDto.setGiftFrom(memberGiftRecord.getGiftFrom()); |
| | | birthdayGiftSendDto.setShopId(memberGiftRecord.getShopId()); |
| | | birthdayGiftSendDto.setCouponId(memberGiftRecord.getCouponId()); |
| | | birthdayGiftSendDto.setCouponNumber(memberGiftRecord.getCouponNumber()); |
| | | giftSendDtoList.add(birthdayGiftSendDto); |
| | | remoteCouponService.sendCouponGift(giftSendDtoList); |
| | | if (memberGiftRecord.getPrizeFrom() == 1) { |
| | | merVerifyAwardVo.setGiftName(memberGiftRecord.getCouponName()); |
| | | merVerifyAwardVo.setGiftNumber(Double.valueOf(memberGiftRecord.getCouponNumber())); |
| | | birthdayGiftSendDto.setUserId(memberGiftRecord.getUserId()); |
| | | birthdayGiftSendDto.setGiftType(memberGiftRecord.getGiftType()); |
| | | birthdayGiftSendDto.setGiftFrom(memberGiftRecord.getGiftFrom()); |
| | | birthdayGiftSendDto.setShopId(memberGiftRecord.getShopId()); |
| | | birthdayGiftSendDto.setCouponId(memberGiftRecord.getCouponId()); |
| | | birthdayGiftSendDto.setCouponNumber(memberGiftRecord.getCouponNumber()); |
| | | giftSendDtoList.add(birthdayGiftSendDto); |
| | | remoteCouponService.sendCouponGift(giftSendDtoList); |
| | | } |
| | | break; |
| | | case 2: |
| | | Goods goods = remoteGoodsService.getGoods(memberGiftRecord.getGoodsId()).getData(); |
| | |
| | | birthdayGiftSendDto.setGoodsNumber(memberGiftRecord.getGoodsNumber()); |
| | | giftSendDtoList.add(birthdayGiftSendDto); |
| | | consumerGoodsService.sendGoodsGift(giftSendDtoList); |
| | | //抽奖奖品中的平台商品需要生成订单数据 |
| | | if (memberGiftRecord.getPrizeFrom() == 2) { |
| | | addOrder(memberGiftRecord.getShopId(), memberGiftRecord.getUserId(), goods, memberGiftRecord.getGoodsNumber(), memberGiftRecord.getGiftId()); |
| | | } |
| | | break; |
| | | case 3: |
| | | merVerifyAwardVo.setGiftName("现金"); |
| | | merVerifyAwardVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue()); |
| | | if (memberGiftRecord.getPrizeFrom() == 1) { |
| | | merVerifyAwardVo.setGiftName("现金"); |
| | | merVerifyAwardVo.setGiftNumber(memberGiftRecord.getMoney().doubleValue()); |
| | | } |
| | | break; |
| | | case 4: |
| | | merVerifyAwardVo.setGiftName(memberGiftRecord.getGiftName()); |
| | |
| | | merVerifyAwardVo.setVerifyStatus(2); |
| | | return merVerifyAwardVo; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 核销抽奖的平台商品生成订单 |
| | | * |
| | | * @param shopId |
| | | * @param userId |
| | | * @param goods |
| | | * @param goodsNum |
| | | */ |
| | | public void addOrder(Long shopId, Long userId, Goods goods, Integer goodsNum, String giftId) { |
| | | Order order = new Order(); |
| | | order.setOrderId(IdUtils.simpleUUID()); |
| | | order.setDelFlag(0); |
| | | order.setOrderStatus(3); |
| | | order.setOrderNo(CodeFactoryUtil.getShopOrderNo()); |
| | | order.setOrderFrom(4); |
| | | order.setShopId(shopId); |
| | | order.setUserId(userId); |
| | | order.setOrderMoney(BigDecimal.ZERO); |
| | | order.setCouponMoney(BigDecimal.ZERO); |
| | | order.setDiscountMoney(BigDecimal.ZERO); |
| | | order.setReceivableMoney(BigDecimal.ZERO); |
| | | order.setPayType(1); |
| | | order.setPayMoney(BigDecimal.ZERO); |
| | | order.setOrderRemark("抽奖订单"); |
| | | order.setCreateTime(new Date()); |
| | | order.setPayTime(new Date()); |
| | | order.setUseTime(new Date()); |
| | | order.setUseUserId(userId); |
| | | order.setGoodsNum(goodsNum); |
| | | order.setReceivableDeposit(BigDecimal.ZERO); |
| | | order.setCloseFlag(1); |
| | | order.setActivityId(giftId); |
| | | this.save(order); |
| | | OrderGoods orderGoods = new OrderGoods(); |
| | | orderGoods.setOrderGoodsId(IdUtils.simpleUUID()); |
| | | orderGoods.setDelFlag(0); |
| | | orderGoods.setOrderId(order.getOrderId()); |
| | | orderGoods.setGoodsId(goods.getGoodsId()); |
| | | orderGoods.setBuyNum(goodsNum); |
| | | orderGoods.setGoodsPrice(goods.getSalesPrice()); |
| | | orderGoods.setGoodsDeposit(goods.getSubscription()); |
| | | orderGoods.setGoodsTotalMoney(goods.getSalesPrice().multiply(new BigDecimal(goodsNum))); |
| | | orderGoods.setGoodsReceivableMoney(BigDecimal.ZERO); |
| | | orderGoods.setCycleNumFlag(goods.getCycleNumFlag()); |
| | | orderGoods.setServiceNum(goods.getServiceNum()); |
| | | orderGoods.setGoodsType(goods.getGoodsType()); |
| | | orderGoods.setGoodsName(goods.getGoodsName()); |
| | | GoodsFile goodsFile = remoteGoodsService.getGoodsFile(goods.getGoodsId()).getData(); |
| | | if (null != goodsFile) { |
| | | orderGoods.setGoodsPicture(goodsFile.getFileUrl()); |
| | | } |
| | | orderGoods.setGoodsIntroduction(goods.getGoodsIntroduction()); |
| | | orderGoods.setGoodsTag(goods.getGoodsTags()); |
| | | orderGoodsService.save(orderGoods); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 收银未结清订单列表 |
| | | * |
| | |
| | | if (merMemberNoClearOrderVo.getUnPaidMoney() == null) { |
| | | merMemberNoClearOrderVo.setUnPaidMoney(zeroBig); |
| | | } |
| | | if(merMemberNoClearOrderVo.getUnPaidMoney().compareTo(zeroBig)<0){ |
| | | if (merMemberNoClearOrderVo.getUnPaidMoney().compareTo(zeroBig) < 0) { |
| | | merMemberNoClearOrderVo.setUnPaidMoney(zeroBig); |
| | | } |
| | | } |
| | | } |
| | | return merMemberNoClearOrderVoList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 结清订单 |
| | | * |
| | |
| | | BigDecimal buyNumBig; |
| | | Integer serviceNum; |
| | | Integer goodsNum = 0; |
| | | String memberCouponId; |
| | | Long memberCouponId; |
| | | Goods goods; |
| | | BigDecimal goodsPrice; |
| | | BigDecimal goodsTotalPrice; |
| | |
| | | goodsRealPrice = goodsTotalPrice; |
| | | //优惠券计算 |
| | | if (memberCouponId != null) { |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId); |
| | | log.info("使用优惠券:{}", memberCouponId); |
| | | appMemberCouponVo = appMemberCouponVoMap.get(memberCouponId.toString()); |
| | | log.info("匹配的优惠券:{}", JSON.toJSONString(appMemberCouponVo)); |
| | | if (null != appMemberCouponVo && (StringUtils.isBlank(appMemberCouponVo.getRelGoodsIds()) || appMemberCouponVo.getRelGoodsIds().contains(goodsId))) { |
| | | log.info("可以使用优惠券:{}", JSON.toJSONString(appMemberCouponVo)); |
| | | couponType = appMemberCouponVo.getCouponType(); |
| | | couponType = appMemberCouponVo.getCouponType(); |
| | | if (couponType == 1 && appMemberCouponVo.getMoneyThreshold() != null && appMemberCouponVo.getDiscountMoney() != null) { |
| | | moneyThreshold = appMemberCouponVo.getMoneyThreshold(); |
| | |
| | | goodsRealPrice = BigDecimal.ZERO; |
| | | discountMoney = goodsTotalPrice.subtract(goodsRealPrice); |
| | | } |
| | | memberCouponSJ.add(memberCouponId); |
| | | memberCouponSJ.add(memberCouponId + ","); |
| | | } |
| | | } |
| | | goodsDeposit = goods.getSubscription(); |
| | |
| | | consumerGoodsService.saveBatchConsumerGoods(consumerGoodsList); |
| | | //减去优惠券 |
| | | if (StringUtils.isNotBlank(memberCouponSJ.toString())) { |
| | | log.info("修改优惠券使用状态:{}", JSON.toJSONString(memberCouponSJ)); |
| | | remoteCouponService.useMemberCoupon(memberCouponSJ.toString()); |
| | | } |
| | | //更新会员消费记录 |
| | |
| | | if (merMemberNoClearOrderVo.getUnPaidMoney() == null) { |
| | | merMemberNoClearOrderVo.setUnPaidMoney(zeroBig); |
| | | } |
| | | if(merMemberNoClearOrderVo.getUnPaidMoney().compareTo(zeroBig)<0){ |
| | | if (merMemberNoClearOrderVo.getUnPaidMoney().compareTo(zeroBig) < 0) { |
| | | merMemberNoClearOrderVo.setUnPaidMoney(zeroBig); |
| | | } |
| | | List<MerCouponGoodsListVo> goodsList = new ArrayList<>(); |
| | | orderGoodsService.listByOrderId(merMemberNoClearOrderVo.getOrderId()).forEach(orderGoodsVo -> { |
| | | MerCouponGoodsListVo merCouponGoodsListVo = new MerCouponGoodsListVo(); |
| | | merCouponGoodsListVo.setGoodsId(orderGoodsVo.getGoodsId()); |
| | | merCouponGoodsListVo.setGoodsName(orderGoodsVo.getGoodsName()); |
| | | merCouponGoodsListVo.setGoodsNum(orderGoodsVo.getBuyNum()); |
| | | if (orderGoodsVo.getGoodsType() == 1) { |
| | | merCouponGoodsListVo.setGoodsType("周期"); |
| | | } else if (orderGoodsVo.getGoodsType() == 2) { |
| | | merCouponGoodsListVo.setGoodsType("服务"); |
| | | } else if (orderGoodsVo.getGoodsType() == 3) { |
| | | merCouponGoodsListVo.setGoodsType("体验"); |
| | | } else if (orderGoodsVo.getGoodsType() == 4) { |
| | | merCouponGoodsListVo.setGoodsType("单品"); |
| | | } |
| | | goodsList.add(merCouponGoodsListVo); |
| | | }); |
| | | merMemberNoClearOrderVo.setGoodsList(goodsList); |
| | | } |
| | | } |
| | | return merMemberNoClearOrderVoList; |
| | |
| | | mgtShopOrderPageDto.setUserIds(mgtUserIdByKeywordVo.getUserIds()); |
| | | } |
| | | } |
| | | //数据权限 |
| | | List<Long> userId = remoteUserService.getScopeOfAuthorityUserId(); |
| | | BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto(); |
| | | boardMemberTotalDto.setUserIds(userId); |
| | | List<Shop> shops = remoteShopService.getShopBySysUserIds(boardMemberTotalDto); |
| | | if (!shops.isEmpty()) { |
| | | List<Long> collect = shops.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | String join = collect.stream().map(Object::toString).collect(Collectors.joining(",")); |
| | | String shopIds = mgtShopOrderPageDto.getShopIds(); |
| | | if(StringUtils.isNotEmpty(shopIds)){ |
| | | shopIds = shopIds + "," + join; |
| | | }else{ |
| | | shopIds = join; |
| | | } |
| | | mgtShopOrderPageDto.setShopIds(shopIds); |
| | | } |
| | | |
| | | |
| | | // 从数据库中获取活动订单列表 |
| | | List<MgtActivityOrderPageVo> activityOrderPageVoList = orderMapper.pageMgtActivityOrder(page, mgtShopOrderPageDto); |
| | | // 如果列表不为空 |
| | |
| | | mgtShopOrderPageDto.setUserIds(mgtUserIdByKeywordVo.getUserIds()); |
| | | } |
| | | } |
| | | //数据权限 |
| | | List<Long> userId = remoteUserService.getScopeOfAuthorityUserId(); |
| | | BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto(); |
| | | boardMemberTotalDto.setUserIds(userId); |
| | | List<Shop> shops = remoteShopService.getShopBySysUserIds(boardMemberTotalDto); |
| | | if (!shops.isEmpty()) { |
| | | List<Long> collect = shops.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | String join = collect.stream().map(Object::toString).collect(Collectors.joining(",")); |
| | | String shopIds = mgtShopOrderPageDto.getShopIds(); |
| | | if(StringUtils.isNotEmpty(shopIds)){ |
| | | shopIds = shopIds + "," + join; |
| | | }else{ |
| | | shopIds = join; |
| | | } |
| | | mgtShopOrderPageDto.setShopIds(shopIds); |
| | | } |
| | | MgtOrderTotal mgtOrderTotal = new MgtOrderTotal(); |
| | | MgtOrderTotal mgtOrderTotalFirst = orderMapper.totalOrderFirst(mgtShopOrderPageDto); |
| | | MgtOrderTotal mgtOrderTotalSecond = orderMapper.totalOrderSecond(mgtShopOrderPageDto); |
| | |
| | | if (StringUtils.isNotBlank(mgtUserIdByKeywordVo.getUserIds())) { |
| | | mgtShopOrderPageDto.setUserIds(mgtUserIdByKeywordVo.getUserIds()); |
| | | } |
| | | } |
| | | //数据权限 |
| | | List<Long> userId = remoteUserService.getScopeOfAuthorityUserId(); |
| | | BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto(); |
| | | boardMemberTotalDto.setUserIds(userId); |
| | | List<Shop> shops = remoteShopService.getShopBySysUserIds(boardMemberTotalDto); |
| | | if (!shops.isEmpty()) { |
| | | List<Long> collect = shops.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | String join = collect.stream().map(Object::toString).collect(Collectors.joining(",")); |
| | | String shopIds = mgtShopOrderPageDto.getShopIds(); |
| | | if(StringUtils.isNotEmpty(shopIds)){ |
| | | shopIds = shopIds + "," + join; |
| | | }else{ |
| | | shopIds = join; |
| | | } |
| | | mgtShopOrderPageDto.setShopIds(shopIds); |
| | | } |
| | | List<MgtShopOrderPageVo> shopOrderPageVoList = orderMapper.pageMgtShopOrder(page, mgtShopOrderPageDto); |
| | | // 如果列表不为空 |
| | |
| | | * @date 2023/6/18 17:20 |
| | | */ |
| | | @Override |
| | | public MgtBulletinBoardVo boardOrderTotal() { |
| | | MgtBulletinBoardVo mgtBulletinBoardVo = orderMapper.boardOrderTotal(); |
| | | Integer activityUserTotal = orderMapper.activityUserTotal(); |
| | | public MgtBulletinBoardVo boardOrderTotal(List<Long> userIds) { |
| | | BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto(); |
| | | boardMemberTotalDto.setUserIds(userIds); |
| | | List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto); |
| | | List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | MgtBulletinBoardVo mgtBulletinBoardVo = orderMapper.boardOrderTotal(collect); |
| | | Integer activityUserTotal = orderMapper.activityUserTotal(collect); |
| | | mgtBulletinBoardVo.setActivityUserTotal(activityUserTotal); |
| | | return mgtBulletinBoardVo; |
| | | } |
| | |
| | | userIdList.add(mgtBasePlatformDto.getUserId()); |
| | | } else { |
| | | MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept(); |
| | | mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId()); |
| | | mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getDeptId()); |
| | | mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData(); |
| | | userIdList = mgtUserIdByDept.getUserIdList(); |
| | | } |
| | |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | } |
| | | //数据权限 |
| | | List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId(); |
| | | if(null != userIds){ |
| | | List<Long> userIdList = mgtBasePlatformDto.getUserIdList(); |
| | | if(null != userIdList){ |
| | | userIdList.addAll(userIds); |
| | | }else{ |
| | | userIdList = userIds; |
| | | } |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | |
| | | |
| | | List<Long> shopIdList = new ArrayList<>(); |
| | | if(mgtBasePlatformDto.getShopId()!=null){ |
| | | shopIdList.add(mgtBasePlatformDto.getShopId()); |
| | |
| | | MgtSimpleShopVo simpleShopVo; |
| | | HashSet<String> set = new HashSet<>(); |
| | | // 遍历MgtMemberOrderPageVoList,获取shopId并添加到set中 |
| | | for (Long entity : shopIdList) { |
| | | set.add(entity.toString()); |
| | | if(null != shopIdList){ |
| | | for (Long entity : shopIdList) { |
| | | set.add(entity.toString()); |
| | | } |
| | | } |
| | | String joinedString = String.join(",", set); |
| | | MgtBaseBathDto mgtBaseBathDto = new MgtBaseBathDto(); |
| | |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | if (mgtBasePlatformDto.getUserId() != null) { |
| | | userIdList.add(mgtBasePlatformDto.getUserId()); |
| | | } |
| | | else { |
| | | // 如果当前登陆人的可视权限是仅个人 只选择了部门也只能看自己的数据 |
| | | SysUser sysUser = SecurityUtils.getSysUser(); |
| | | if (sysUser.getDataScope().equals("5")){ |
| | | userIdList.add(sysUser.getUserId()); |
| | | }else{ |
| | | MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept(); |
| | | mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getDeptId()); |
| | | mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData(); |
| | | userIdList = mgtUserIdByDept.getUserIdList(); |
| | | } |
| | | } else { |
| | | List<SysUser> data = remoteUserService.getUsersByDeptId(mgtBasePlatformDto.getDeptId()).getData(); |
| | | userIdList.addAll(data.stream().map(SysUser::getUserId).collect(Collectors.toList())); |
| | | } |
| | | if (!userIdList.isEmpty()) { |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | }else{ |
| | | // 没有选择筛选部门和员工 获取当前登陆人的可视权限 |
| | | SysUser sysUser = SecurityUtils.getSysUser(); |
| | | // 如果当前登陆人是查看个人数据 |
| | | Long userId1 = null; |
| | | // 如果当前登陆人权限是查看部门数据 |
| | | List<Long> userList = new ArrayList<>(); |
| | | if (sysUser!=null){ |
| | | String dataScope = sysUser.getDataScope(); |
| | | if (!sysUser.getUserName().equals("admin")){ |
| | | if (org.springframework.util.StringUtils.hasLength(dataScope)){ |
| | | switch (dataScope){ |
| | | case "3": |
| | | // 本部门数据 查询当前登陆人属于哪个部门 查询这个部门下所有员工关联的所有店铺 |
| | | MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept(); |
| | | mgtUserIdByDept.setDeptId(sysUser.getDeptId()); |
| | | mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData(); |
| | | userList = mgtUserIdByDept.getUserIdList(); |
| | | mgtBasePlatformDto.setDeptId(sysUser.getDeptId()); |
| | | mgtBasePlatformDto.setUserIdList(userList); |
| | | case "5": |
| | | // 仅个人数据 查询当前登陆人关联店铺下的用户 |
| | | userId1 = sysUser.getUserId(); |
| | | userList.add(userId1); |
| | | mgtBasePlatformDto.setDeptId(sysUser.getDeptId()); |
| | | mgtBasePlatformDto.setUserIdList(userList); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //数据权限 |
| | | List<Long> userIdList = mgtBasePlatformDto.getUserIdList(); |
| | | List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId(); |
| | | if(null != userIds){ |
| | | if(null != userIdList){ |
| | | userIdList.addAll(userIds); |
| | | }else{ |
| | | userIdList = userIds; |
| | | } |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | |
| | | |
| | | MgtTotalOrderTotalVo mgtTotalOrderTotalVo = new MgtTotalOrderTotalVo(); |
| | | mgtTotalOrderTotalVo.setOrderTotal(0); |
| | | mgtTotalOrderTotalVo.setOnlineTotal(0); |
| | |
| | | if(mgtBasePlatformDto.getActivityFrom()!=null&&mgtBasePlatformDto.getActivityFrom()==2){ |
| | | return totalActivityTotalVo; |
| | | } |
| | | |
| | | //数据权限 |
| | | List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId(); |
| | | if(null != userIds){ |
| | | List<Long> userIdList = mgtBasePlatformDto.getUserIdList(); |
| | | if(null == userIdList){ |
| | | userIdList = new ArrayList<>(); |
| | | } |
| | | userIdList.addAll(userIds); |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | |
| | | List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData(); |
| | | if (StringUtils.isNotBlank(mgtBasePlatformDto.getShopProvinceCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopCityCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopAreaCode())) { |
| | | if(shopIdList==null||shopIdList.isEmpty()){ |
| | |
| | | shopIdList.add(mgtBasePlatformDto.getShopId()); |
| | | } |
| | | mgtBasePlatformDto.setShopIdList(shopIdList); |
| | | |
| | | //获取基础统计 |
| | | MgtPlTotalActivityTotalVo mgtTotalActivityTotalVo = orderMapper.getPlTotalActivityTotal(mgtBasePlatformDto); |
| | | totalActivityTotalVo.setOrderTotal(mgtTotalActivityTotalVo.getOrderTotal()); |
| | |
| | | } |
| | | HashSet<String> set = new HashSet<>(); |
| | | // 遍历MgtMemberOrderPageVoList,获取shopId并添加到set中 |
| | | for (Long shopId : mgtBasePlatformDto.getShopIdList()) { |
| | | set.add(shopId.toString()); |
| | | if(null != mgtBasePlatformDto.getShopIdList()){ |
| | | for (Long shopId : mgtBasePlatformDto.getShopIdList()) { |
| | | set.add(shopId.toString()); |
| | | } |
| | | } |
| | | // 将set中的shopId转换为逗号分隔的字符串 |
| | | String joinedString = String.join(",", set); |
| | |
| | | totalActivityTotalVo.setOrderTotalValue(orderTotalValue); |
| | | totalActivityTotalVo.setOrderMoneyValue(orderMoneyValue); |
| | | } |
| | | |
| | | //参与人数 2023-09-06 另开接口 |
| | | /*List<MgtMapIntTotalVo> joinList = orderMapper.getMgtActivityMemberTotal(mgtBasePlatformDto); |
| | | // 将查询结果转为Map |
| | | Map<String, Integer> mgtMapIntTotalVoMap = new HashMap<>(); |
| | | if (joinList != null && !joinList.isEmpty()) { |
| | | mgtMapIntTotalVoMap = joinList.stream() |
| | | .collect(Collectors.toMap(MgtMapIntTotalVo::getMapKey, MgtMapIntTotalVo::getMapValue)); |
| | | } |
| | | // 获取日期范围 |
| | | List<String> dateList = getDateRange(mgtBasePlatformDto.getStartDate(), mgtBasePlatformDto.getEndDate()); |
| | | int size = dateList.size(); |
| | | // 创建日期和成员总数的数组 |
| | | String[] joinMemberTotalKey = new String[size]; |
| | | Integer[] joinMemberTotalValue = new Integer[size]; |
| | | // 遍历日期列表,设置日期和成员总数的数组 |
| | | String str; |
| | | Integer value; |
| | | for (int i = 0; i < size; i++) { |
| | | str = dateList.get(i); |
| | | joinMemberTotalKey[i] = str; |
| | | value = mgtMapIntTotalVoMap.get(str); |
| | | joinMemberTotalValue[i] = (value != null) ? value : 0; |
| | | } |
| | | totalActivityTotalVo.setJoinMemberTotalKey(joinMemberTotalKey); |
| | | totalActivityTotalVo.setJoinMemberTotalValue(joinMemberTotalValue); |
| | | //获客人数 |
| | | List<MgtMapIntTotalVo> getList = orderMapper.getMgtActivityGetMemberTotal(mgtBasePlatformDto); |
| | | // 将查询结果转为Map |
| | | Map<String, Integer> getMemberMap = new HashMap<>(); |
| | | if (getList != null && !getList.isEmpty()) { |
| | | getMemberMap = getList.stream() |
| | | .collect(Collectors.toMap(MgtMapIntTotalVo::getMapKey, MgtMapIntTotalVo::getMapValue)); |
| | | } |
| | | // 创建日期和成员总数的数组 |
| | | String[] getMemberTotalKey = new String[size]; |
| | | Integer[] getMemberTotalValue = new Integer[size]; |
| | | // 遍历日期列表,设置日期和成员总数的数组 |
| | | for (int i = 0; i < size; i++) { |
| | | str = dateList.get(i); |
| | | getMemberTotalKey[i] = str; |
| | | value = getMemberMap.get(str); |
| | | getMemberTotalValue[i] = (value != null) ? value : 0; |
| | | } |
| | | totalActivityTotalVo.setGetMemberTotalKey(getMemberTotalKey); |
| | | totalActivityTotalVo.setGetMemberTotalValue(getMemberTotalValue);*/ |
| | | return totalActivityTotalVo; |
| | | } |
| | | |
| | |
| | | if(mgtBasePlatformDto.getActivityFrom()!=null&&mgtBasePlatformDto.getActivityFrom()==2){ |
| | | return totalActivityTotalVo; |
| | | } |
| | | /*if(mgtBasePlatformDto.getActivityType()!=null&&mgtBasePlatformDto.getActivityType()!=1){ |
| | | return new MgtPlTotalActivityTotalVo(); |
| | | }*/ |
| | | //获取需要关联的用户id集合 |
| | | /*if (mgtBasePlatformDto.getDeptId() != null) { |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | if (mgtBasePlatformDto.getUserId() != null) { |
| | | userIdList.add(mgtBasePlatformDto.getUserId()); |
| | | } else { |
| | | MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept(); |
| | | mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId()); |
| | | mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData(); |
| | | userIdList = mgtUserIdByDept.getUserIdList(); |
| | | } |
| | | if (!userIdList.isEmpty()) { |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | }*/ |
| | | |
| | | List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData(); |
| | | log.info("shopIdList1-----"+shopIdList.toString()); |
| | |
| | | if(mgtBasePlatformDto.getShopId()!=null){ |
| | | shopIdList = new ArrayList<>(); |
| | | shopIdList.add(mgtBasePlatformDto.getShopId()); |
| | | } |
| | | |
| | | List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId(); |
| | | BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto(); |
| | | boardMemberTotalDto.setUserIds(userIds); |
| | | List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto); |
| | | List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | if(null != shopIdList){ |
| | | shopIdList.addAll(collect); |
| | | }else{ |
| | | shopIdList = collect; |
| | | } |
| | | mgtBasePlatformDto.setShopIdList(shopIdList); |
| | | if(mgtBasePlatformDto.getAgeType()!=null){ |
| | |
| | | if(mgtBasePlatformDto.getActivityFrom()!=null&&mgtBasePlatformDto.getActivityFrom()==2){ |
| | | return totalActivityTotalVo; |
| | | } |
| | | /*if(mgtBasePlatformDto.getActivityType()!=null&&mgtBasePlatformDto.getActivityType()!=1){ |
| | | return new MgtPlTotalActivityTotalVo(); |
| | | }*/ |
| | | //获取需要关联的用户id集合 |
| | | /*if (mgtBasePlatformDto.getDeptId() != null) { |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | if (mgtBasePlatformDto.getUserId() != null) { |
| | | userIdList.add(mgtBasePlatformDto.getUserId()); |
| | | } else { |
| | | MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept(); |
| | | mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId()); |
| | | mgtUserIdByDept = remoteConfigService.getUserIdByDept(mgtUserIdByDept).getData(); |
| | | userIdList = mgtUserIdByDept.getUserIdList(); |
| | | } |
| | | if (!userIdList.isEmpty()) { |
| | | mgtBasePlatformDto.setUserIdList(userIdList); |
| | | } |
| | | }*/ |
| | | List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData(); |
| | | if (StringUtils.isNotBlank(mgtBasePlatformDto.getShopProvinceCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopCityCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopAreaCode())) { |
| | | if(shopIdList==null||shopIdList.isEmpty()){ |
| | |
| | | if(mgtBasePlatformDto.getShopId()!=null){ |
| | | shopIdList = new ArrayList<>(); |
| | | shopIdList.add(mgtBasePlatformDto.getShopId()); |
| | | } |
| | | //数据权限 |
| | | List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId(); |
| | | BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto(); |
| | | boardMemberTotalDto.setUserIds(userIds); |
| | | List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto); |
| | | List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList()); |
| | | if(null != shopIdList){ |
| | | shopIdList.addAll(collect); |
| | | }else{ |
| | | shopIdList = collect; |
| | | } |
| | | mgtBasePlatformDto.setShopIdList(shopIdList); |
| | | if(mgtBasePlatformDto.getAgeType()!=null){ |
| | |
| | | // 创建MerVerifyCouponVo对象 |
| | | MerVerifyCouponVo merVerifyCouponVo = new MerVerifyCouponVo(); |
| | | // 调用remoteCouponService的getVerifyCoupon方法获取MerVerifyCouponGetVo对象 |
| | | MerVerifyCouponGetVo verifyCouponGetVo = remoteCouponService.getVerifyCoupon(verifyCode).getData(); |
| | | R<MerVerifyCouponGetVo> verifyCoupon = remoteCouponService.getVerifyCoupon(Long.valueOf(verifyCode)); |
| | | if(verifyCoupon.getCode() != 200){ |
| | | throw new ServiceException(verifyCoupon.getMsg()); |
| | | } |
| | | MerVerifyCouponGetVo verifyCouponGetVo = verifyCoupon.getData(); |
| | | MemberCoupon memberCoupon = verifyCouponGetVo.getMemberCoupon(); |
| | | // 检查优惠券状态 |
| | | int couponStatus = memberCoupon.getCouponStatus(); |
| | |
| | | if (memberGiftRecord.getGiftFrom() == 1) { |
| | | BirthdayCard birthdayCard = remoteMemberService.getBirthdayCard().getData(); |
| | | //判断生日活动状态 |
| | | if(birthdayCard!=null&&birthdayCard.getCardStatus()==1){ |
| | | if (birthdayCard != null && birthdayCard.getCardStatus() == 1) { |
| | | shop = remoteShopService.getShop(shopId).getData(); |
| | | //判断指定区域全部店铺 |
| | | if(birthdayCard.getAreaFlag()==2&&birthdayCard.getShopFlag()==1&&!StringUtils.checkString(birthdayCard.getDesignatedArea(),shop.getShopCityCode())){ |
| | | if (birthdayCard.getAreaFlag() == 2 && birthdayCard.getShopFlag() == 1 && !StringUtils.checkString(birthdayCard.getDesignatedArea(), shop.getShopCityCode())) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | //判断指定店铺 |
| | | if(birthdayCard.getShopFlag()==2&&!StringUtils.checkString(birthdayCard.getApplicableShop(),shopId.toString())){ |
| | | if (birthdayCard.getShopFlag() == 2 && !StringUtils.checkString(birthdayCard.getApplicableShop(), shopId.toString())) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | }else{ |
| | | } else { |
| | | throw new ServiceException(AppErrorConstant.BIRTHDAY_CARD_ERROR); |
| | | } |
| | | } |
| | |
| | | if (memberGiftRecord.getGiftFrom() == 2 && !memberGiftRecord.getShopId().equals(shopId)) { |
| | | throw new ServiceException(AppErrorConstant.VERIFY_SHOP_ERROR); |
| | | } |
| | | |
| | | |
| | | merVerifyAwardVo.setUserName(member.getRealName()); |
| | | merVerifyAwardVo.setUserMobile(member.getMobile()); |
| | | if (memberGiftRecord.getGiftFrom() == 1) { |
| | | merVerifyAwardVo.setGiftFrom("平台生日卡"); |
| | | if (1 == memberGiftRecord.getPrizeFrom()) { |
| | | if (memberGiftRecord.getGiftFrom() == 1) { |
| | | merVerifyAwardVo.setGiftFrom("平台生日卡"); |
| | | } else { |
| | | merVerifyAwardVo.setGiftFrom("商户生日卡"); |
| | | } |
| | | } else { |
| | | merVerifyAwardVo.setGiftFrom("商户生日卡"); |
| | | merVerifyAwardVo.setGiftFrom("平台抽奖"); |
| | | } |
| | | merVerifyAwardVo.setGiftType(memberGiftRecord.getGiftType()); |
| | | //礼物类型1优惠券2商品3现金4实物 |
| | | //礼物类型1优惠券2商品3现金4实物5积分 |
| | | switch (memberGiftRecord.getGiftType()) { |
| | | case 1: |
| | | merVerifyAwardVo.setGiftName(memberGiftRecord.getCouponName()); |
| | |
| | | @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()); |
| | | // 根据商品存在状态,设置会员统计信息 |