| | |
| | | package com.ruoyi.shop.service.impl.shop; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | 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.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult; |
| | | import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingReceiverRequest; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.ExceptionUtil; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.utils.uuid.IdUtils; |
| | |
| | | import com.ruoyi.system.api.domain.poji.config.SysTag; |
| | | import com.ruoyi.system.api.domain.poji.member.Member; |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.poji.shop.ShopAppointableTime; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.domain.vo.*; |
| | | import com.ruoyi.system.api.service.*; |
| | | import lombok.extern.log4j.Log4j2; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.rmi.ServerException; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | |
| | | @Resource |
| | | private WechatPayUtils wechatPayUtils; |
| | | |
| | | |
| | | @Resource |
| | | private ShopDetailService shopDetailService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | |
| | | |
| | | @Resource |
| | | private ShopAppointableTimeService shopAppointableTimeService; |
| | | |
| | | @Value("${callback_path}") |
| | | private String callback_path; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取商户详情 |
| | | * |
| | |
| | | } |
| | | return appShopInfoVo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建商户 |
| | | * |
| | | * @param mgtEditShopDto |
| | | */ |
| | | @Override |
| | | public void createShop(MgtEditShopDto mgtEditShopDto){ |
| | | public void createShop(MgtEditShopDto mgtEditShopDto) { |
| | | Shop shop = new Shop(); |
| | | Boolean newShop = false; |
| | | BigDecimal zeroBig = BigDecimal.ZERO; |
| | | //验证关联账号唯一 |
| | | String relUserIds = mgtEditShopDto.getRelUserIds(); |
| | | if(StringUtils.isNotBlank(relUserIds)) { |
| | | if(relUserIds.startsWith(",")){ |
| | | relUserIds = relUserIds.substring(1); |
| | | } |
| | | String[] relUserIdArray = relUserIds.split(","); |
| | | ShopRelUser shopRelUser; |
| | | Long userId; |
| | | if(mgtEditShopDto.getShopId()!=null){ |
| | | for (String str : relUserIdArray) { |
| | | userId = Long.valueOf(str); |
| | | shopRelUser = shopRelUserService.getByUserId(userId); |
| | | if(shopRelUser!=null&&!shopRelUser.getShopId().equals(mgtEditShopDto.getShopId())){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE); |
| | | } |
| | | } |
| | | }else { |
| | | for (String str : relUserIdArray) { |
| | | userId = Long.valueOf(str); |
| | | shopRelUser = shopRelUserService.getByUserId(userId); |
| | | if(shopRelUser!=null){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | // if(StringUtils.isNotBlank(relUserIds)) { |
| | | // if(relUserIds.startsWith(",")){ |
| | | // relUserIds = relUserIds.substring(1); |
| | | // } |
| | | // String[] relUserIdArray = relUserIds.split(","); |
| | | // ShopRelUser shopRelUser; |
| | | // Long userId; |
| | | // if(mgtEditShopDto.getShopId()!=null){ |
| | | // for (String str : relUserIdArray) { |
| | | // userId = Long.valueOf(str); |
| | | // shopRelUser = shopRelUserService.getByUserId(userId); |
| | | // if(shopRelUser!=null&&!shopRelUser.getShopId().equals(mgtEditShopDto.getShopId())){ |
| | | // throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE); |
| | | // } |
| | | // } |
| | | // }else { |
| | | // for (String str : relUserIdArray) { |
| | | // userId = Long.valueOf(str); |
| | | // shopRelUser = shopRelUserService.getByUserId(userId); |
| | | // if(shopRelUser!=null){ |
| | | // throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | //验证商户名唯一 |
| | | //Shop shopSame = this.getOne(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag,0).eq(Shop::getShopName,mgtEditShopDto.getShopName())); |
| | | if(mgtEditShopDto.getShopId()!=null){ |
| | | if (mgtEditShopDto.getShopId() != null) { |
| | | //取消验重 |
| | | /*if(shopSame!=null&&!Objects.equals(shopSame.getShopId(),mgtEditShopDto.getShopId())){ |
| | | throw new ServiceException(AppErrorConstant.SHOP_DOUBLE); |
| | |
| | | staffHomeShopTotalVo.setShopTask(shopTaskCount); |
| | | return staffHomeShopTotalVo; |
| | | } |
| | | |
| | | /** |
| | | * 获取商户端 |
| | | * |
| | | * @param merBaseDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MerHomeShopTotalVo getMerHomeTotal(MerBaseDto merBaseDto){ |
| | | public MerHomeShopTotalVo getMerHomeTotal(MerBaseDto merBaseDto) { |
| | | Long userId = merBaseDto.getUserId(); |
| | | MerHomeShopTotalVo merHomeShopTotalVo = new MerHomeShopTotalVo(); |
| | | ShopRelUser shopRelUser = shopRelUserService.getByUserId(userId); |
| | | Long shopId = shopRelUser.getShopId(); |
| | | Long shopId = merBaseDto.getShopId(); |
| | | //如果商户变动刷新token |
| | | if(!shopId.equals(merBaseDto.getShopId())){ |
| | | String userKey = SecurityUtils.getUserKey(); |
| | | redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY+userKey); |
| | | throw new ServiceException("登录状态已过期",401); |
| | | } |
| | | // if(!shopId.equals(merBaseDto.getShopId())){ |
| | | // String userKey = SecurityUtils.getUserKey(); |
| | | // redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY+userKey); |
| | | // throw new ServiceException("登录状态已过期",401); |
| | | // } |
| | | merHomeShopTotalVo.setShopId(shopId); |
| | | Shop shop = this.getById(shopId); |
| | | if(shop.getFrozenFlag()==1){ |
| | | if (shop.getFrozenFlag() == 1) { |
| | | String userKey = SecurityUtils.getUserKey(); |
| | | redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY+userKey); |
| | | throw new ServiceException("商户已被冻结,请联系管理员",401); |
| | | redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + userKey); |
| | | throw new ServiceException("商户已被冻结,请联系管理员", 401); |
| | | } |
| | | merHomeShopTotalVo.setShopType(shop.getShopType()); |
| | | MerHomeShopTotalVo orderVo = remoteOrderService.getMerHomeTotal(merHomeShopTotalVo).getData(); |
| | |
| | | merHomeShopTotalVo.setExplorationSurp(orderVo.getExplorationSurp()); |
| | | merHomeShopTotalVo.setPlatformBirthdayFlag(shop.getPlatformBirthdayFlag()); |
| | | merHomeShopTotalVo.setPlatformCouponFlag(shop.getPlatformCouponFlag()); |
| | | int unHandleReserve = shopAppointableTimeService.count(new LambdaQueryWrapper<ShopAppointableTime>().eq(ShopAppointableTime::getShopId, shopId).eq(ShopAppointableTime::getStatus, 1)); |
| | | merHomeShopTotalVo.setUnHandleReserve(unHandleReserve); |
| | | return merHomeShopTotalVo; |
| | | } |
| | | |
| | |
| | | }).collect(Collectors.toList()); |
| | | return simpleShopVoList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @description 获取用户管理商户 |
| | | * @author jqs |
| | | * @date 2023/7/14 10:00 |
| | | * @param userId |
| | | * @return Shop |
| | | * @return Shop |
| | | * @description 获取用户管理商户 |
| | | * @author jqs |
| | | * @date 2023/7/14 10:00 |
| | | */ |
| | | @Override |
| | | public List<Shop> getShopByBelongUserId(Long userId){ |
| | | public List<Shop> getShopByBelongUserId(Long userId) { |
| | | LambdaQueryWrapper<Shop> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Shop::getDelFlag,0); |
| | | queryWrapper.eq(Shop::getBelongUserId,userId); |
| | | queryWrapper.eq(Shop::getDelFlag, 0); |
| | | queryWrapper.eq(Shop::getBelongUserId, userId); |
| | | return this.list(queryWrapper); |
| | | } |
| | | |