| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.Jwt.JwtPayLoad; |
| | | import com.doumee.config.Jwt.JwtTokenUtil; |
| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.GoodsorderJoinMapper; |
| | | import com.doumee.dao.business.join.MemberJoinMapper; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.ProductLabelJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.model.Labels; |
| | |
| | | import com.doumee.dao.business.model.ShopScan; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.dao.system.vo.ShopMoneyVO; |
| | | import com.doumee.dao.web.dto.*; |
| | | import com.doumee.dao.web.dto.shop.*; |
| | | import com.doumee.dao.web.request.MyCustomerRequest; |
| | |
| | | import org.apache.shiro.SecurityUtils; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.xpath.operations.Bool; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | |
| | | @Autowired |
| | | private ShopMapper shopMapper; |
| | | @Autowired |
| | | private UserActionMapper userActionMapper; |
| | | |
| | | @Autowired |
| | | private GoodsMapper goodsMapper; |
| | | @Autowired |
| | |
| | | private MemberCouponService memberCouponService; |
| | | |
| | | @Autowired |
| | | private InviteRecordService inviteRecordService; |
| | | |
| | | @Autowired |
| | | private ShopNewsService shopNewsService; |
| | | @Autowired |
| | | private LabelsMapper labelsMapper; |
| | |
| | | @Autowired |
| | | private IntegralMapper integralMapper; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String,Object> redisTemplate; |
| | | |
| | | |
| | | @Override |
| | | public Integer create(Shop shop) { |
| | | public Integer create(Shop shop) throws Exception { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | isCreateParamValid(shop,user); |
| | | shop.setCreator(user.getId()); |
| | |
| | | shop.setPassword(Utils.Secure.encryptPassword(shop.getPassword(), salt)); |
| | | shop.setSalt(salt); |
| | | shopMapper.insert(shop); |
| | | String url = inviteRecordService.createShopMiniProgramCode(shop.getId()); |
| | | if(StringUtils.isNotBlank(url)){ |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getProgramCode,url) |
| | | .eq(Shop::getId,shop.getId())); |
| | | } |
| | | return shop.getId(); |
| | | } |
| | | |
| | |
| | | shop.setEditDate(new Date()); |
| | | shop.setIsdeleted(Constants.ONE); |
| | | shopMapper.updateById(shop); |
| | | shopGoodsRelationMapper.delete(new UpdateWrapper<ShopGoodsRelation>().lambda().eq(ShopGoodsRelation::getShopId,id)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void updateById(Shop shop) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(shop.getId()==null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); |
| | | } |
| | | isCreateParamValid(shop,user); |
| | | Shop model = shopMapper.selectById(shop.getId()); |
| | | if(model.getId()==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE) ){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | shop.setEditor(user.getId()); |
| | | shop.setEditDate(new Date()); |
| | | |
| | | shopMapper.updateById(shop); |
| | | if(shop.getSaleType() !=null && !Constants.equalsInteger(shop.getSaleType(),model.getSaleType())){ |
| | | //如果销售模式发生编码,记录变更记录 |
| | | //更换日志记录 |
| | | UserActionServiceImpl.saveUserActionBiz(user,shop.getId(), |
| | | Constants.UserActionType.CHANGE_SALETYPE, |
| | | userActionMapper, |
| | | shop.getEditDate(), |
| | | new String[]{user.getUsername(), DateUtil.getPlusTime2(shop.getEditDate())}, |
| | | JSONObject.toJSONString(shop) , |
| | | Constants.equalsInteger(model.getSaleType(),Constants.ONE)?"自由采购":"平台铺货", |
| | | Constants.equalsInteger(shop.getSaleType(),Constants.ONE)?"自由采购":"平台铺货"); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | queryWrapper.selectAll(Shop.class); |
| | | |
| | | queryWrapper.eq(Shop::getId,id); |
| | | queryWrapper.select("(select AVG(SCORE) from shop_comment where ISDELETED=0 and OBJ_ID=t.id) as score");//门店评分 |
| | | // queryWrapper.select("(select AVG(SCORE) from shop_comment where ISDELETED=0 and OBJ_ID=t.id) as score");//门店评分 |
| | | /** ----------------start店铺访问数据----------------*/ |
| | | queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id) as shopTotalVisits");//主页总访问量 |
| | | queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(now()) ) as shopNowVisits");//今日访问量 |
| | | queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ) as shopYesterdayVisits");//昨日日访问量 |
| | | queryWrapper.select("(select count(s.MEMBER_ID) from (select MEMBER_ID,SHOP_ID from shop_scan where ISDELETED=0 group by MEMBER_ID) as s where s.SHOP_ID = t.id) as shopMemberVisits");//访问总用户数 |
| | | // queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id) as shopTotalVisits");//主页总访问量 |
| | | // queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(now()) ) as shopNowVisits");//今日访问量 |
| | | // queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ) as shopYesterdayVisits");//昨日日访问量 |
| | | // queryWrapper.select("(select count(s.MEMBER_ID) from (select MEMBER_ID,SHOP_ID from shop_scan where ISDELETED=0 group by MEMBER_ID) as s where s.SHOP_ID = t.id) as shopMemberVisits");//访问总用户数 |
| | | /** ----------------end店铺访问数据----------------*/ |
| | | /** ----------------start店铺互动数据----------------*/ |
| | | queryWrapper.select("(select count(id) from shop_follow where ISDELETED=0 and OBJ_ID=t.id and OBJ_TYPE=0) as shopFollower");//粉丝数 |
| | | queryWrapper.select("(select count(id) from shop_menu where ISDELETED=0 and SHOP_ID=t.id ) as shopMenu");//菜品数 |
| | | queryWrapper.select("(select count(id) from shop_comment where ISDELETED=0 and OBJ_ID=t.id ) as shopComment");//评论数 |
| | | queryWrapper.select("(select count(id) from shop_news where ISDELETED=0 and SHOP_ID=t.id ) as shopNews");//新鲜事 |
| | | // queryWrapper.select("(select count(id) from shop_follow where ISDELETED=0 and OBJ_ID=t.id and OBJ_TYPE=0) as shopFollower");//粉丝数 |
| | | // queryWrapper.select("(select count(id) from shop_menu where ISDELETED=0 and SHOP_ID=t.id ) as shopMenu");//菜品数 |
| | | // queryWrapper.select("(select count(id) from shop_comment where ISDELETED=0 and OBJ_ID=t.id ) as shopComment");//评论数 |
| | | // queryWrapper.select("(select count(id) from shop_news where ISDELETED=0 and SHOP_ID=t.id ) as shopNews");//新鲜事 |
| | | /** ----------------end店铺互动数据----------------*/ |
| | | /** ----------------start优惠券数据----------------*/ |
| | | queryWrapper.select("(select count(id) from coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponCount");//优惠券发放总数(张) |
| | | queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponDrawCount");//优惠券领取总数(张) |
| | | queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserComment");//优惠券使用总数(张) |
| | | queryWrapper.select("(select sum(LIMIT_PRICE) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserMoney");//优惠券使用金额(元) |
| | | // queryWrapper.select("(select count(id) from coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponCount");//优惠券发放总数(张) |
| | | // queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponDrawCount");//优惠券领取总数(张) |
| | | // queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserComment");//优惠券使用总数(张) |
| | | // queryWrapper.select("(select sum(LIMIT_PRICE) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserMoney");//优惠券使用金额(元) |
| | | /** ----------------end店铺优惠券数据----------------*/ |
| | | |
| | | queryWrapper.select("(select count(g.id) from goodsorder g where g.ISDELETED=0 and g.DISTRIBUTION_SHOP_ID=t.id ) as totalOrderNUm");//优惠券使用金额(元) |
| | | Shop shop= shopJoinMapper.selectJoinOne(Shop.class,queryWrapper); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode(); |
| | | if(Objects.nonNull(shop)&&StringUtils.isNotBlank(shop.getImgurl())){ |
| | | shop.setImgFullUrl(path+shop.getImgurl()); |
| | | } |
| | | shop.setImgFullUrl(path); |
| | | shop.setAreas(AreasServiceImpl.getAddressByAreaId(shop.getAreaId())); |
| | | if(shop.getLatitude()!=null && shop.getLongitude()!=null){ |
| | | shop.setLocationInfo(shop.getLatitude().doubleValue()+","+shop.getLongitude().doubleValue()); |
| | |
| | | shop.setProductList(list); |
| | | return shop; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Shop findOne(Shop shop) { |
| | |
| | | queryWrapper.selectAll(Shop.class); |
| | | if(pageWrap.getModel().getGoodsId()!=null){ |
| | | //查询某商品的供货价 |
| | | queryWrapper.select("(select s.price from shop_goods_relation s where s.ISDELETED=0 and s.shop_id = t.id and s.GOODS_ID="+pageWrap.getModel().getGoodsId()+") as goodsPrice "); |
| | | queryWrapper.select("(select s.price from shop_goods_relation s where s.ISDELETED=0 and s.shop_id = t.id and s.GOODS_ID="+pageWrap.getModel().getGoodsId()+" limit 1) as goodsPrice "); |
| | | } |
| | | queryWrapper.select("(select count(s.id) from shop_goods_relation s left join goods g on s.goods_id =g.id where g.status=0 and s.ISDELETED=0 and s.shop_id=t.id) as pricedGoodsNum "); |
| | | queryWrapper.selectAs(Labels::getName,Shop::getBigAreaName); |
| | | queryWrapper.selectAs(Member::getNickname,Shop::getNickName); |
| | | queryWrapper.selectAs(Member::getImgurl,Shop::getMemberImgurl); |
| | |
| | | IPage<Shop> result = shopJoinMapper.selectJoinPage(page, Shop.class, queryWrapper); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode(); |
| | | long goodsNum = goodsMapper.selectCount(new QueryWrapper<Goods>().lambda() |
| | | .eq(Goods::getIsdeleted,Constants.ZERO) |
| | | .eq(Goods::getStatus,Constants.ZERO)); |
| | | for(Shop model:result.getRecords()){ |
| | | model.setImgFullUrl(path); |
| | | model.setAreas( AreasServiceImpl.getAddressByAreaId(model.getAreaId())); |
| | | model.setGoodsNum(goodsNum); |
| | | if(model.getLatitude()!=null && model.getLongitude()!=null){ |
| | | model.setLocationInfo(model.getLatitude().doubleValue()+","+model.getLongitude().doubleValue()); |
| | | } |
| | | |
| | | } |
| | | return PageData.from(result ); |
| | | } |
| | | @Override |
| | | public PageData<ShopMoneyVO> findPageMoney(PageWrap<Shop> pageWrap){ |
| | | IPage<Shop> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<Shop> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | queryWrapper |
| | | .selectAll(Shop.class) |
| | | .select("(select sum(price) from goodsorder g where g.DISTRIBUTION_SHOP_ID=t.id and g.status in (1,2) and g.isdeleted=0) as jiesuanIng" ) |
| | | .select("(select g.create_date from withdraw_record g where g.MEMBER_ID=t.id and g.isdeleted=0 order by g.id desc limit 1 ) as withdrawDate" ) |
| | | .select("(select sum(g.amount) from withdraw_record g where g.MEMBER_ID=t.id and g.status=1 and g.isdeleted=0 ) as withdrawTotal" ) |
| | | .select("(select sum(g.amount) from withdraw_record g where g.MEMBER_ID=t.id and g.status=0 and g.isdeleted=0 ) as withdrawIng" ); |
| | | queryWrapper.eq(Shop::getIsdeleted, Constants.ZERO); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCode()) ,Shop::getCode,pageWrap.getModel().getCode()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getUsername()) ,Shop::getName,pageWrap.getModel().getUsername()); |
| | | queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()) ,Shop::getName,pageWrap.getModel().getName()); |
| | | queryWrapper.orderByDesc(Shop::getId); |
| | | IPage<ShopMoneyVO> result = shopJoinMapper.selectJoinPage(page, ShopMoneyVO.class, queryWrapper); |
| | | return PageData.from(result ); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public AccountResponse shopOpenidLogin(ShopLoginDTO dto){ |
| | | if(Objects.isNull(dto) |
| | | || StringUtils.isBlank(dto.getOpenid()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"静默登录失败,请联系管理员"); |
| | | } |
| | | Shop shop = shopMapper.selectOne(new QueryWrapper<Shop>().lambda().eq(Shop::getOpenId, dto.getOpenid()) |
| | | .eq(Shop::getIsdeleted,Constants.ZERO) |
| | | .last("limit 1") |
| | |
| | | AccountResponse accountResponse = new AccountResponse(); |
| | | accountResponse.setOpenid(dto.getOpenid()); |
| | | if(Objects.nonNull(shop)){ |
| | | if(Objects.isNull(dto.getMemberId()) |
| | | && ( Objects.isNull(shop.getMemberId()) |
| | | || !Constants.equalsInteger(shop.getMemberId(),dto.getMemberId()))){ |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getMemberId,dto.getMemberId()) |
| | | .eq(Shop::getId,shop.getId()) |
| | | ); |
| | | } |
| | | JwtPayLoad payLoad = new JwtPayLoad(Constants.SHOP_PREFIX+shop.getId()); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | String token = JwtTokenUtil.generateTokenForRedis(shop.getId(), Constants.ONE, JSONObject.toJSONString(shop), redisTemplate); |
| | | accountResponse.setToken(token); |
| | | accountResponse.setShop(this.getShopResponseInfo(shop)); |
| | | } |
| | | return accountResponse; |
| | | } |
| | |
| | | public AccountResponse shopPasswordLogin(ShopLoginDTO dto){ |
| | | if(StringUtils.isBlank(dto.getUserName()) |
| | | || StringUtils.isBlank(dto.getPassword()) |
| | | || StringUtils.isBlank(dto.getOpenid()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户名或密码不能为空"); |
| | | } |
| | |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); |
| | | } |
| | | //创建token |
| | | JwtPayLoad payLoad = new JwtPayLoad(Constants.SHOP_PREFIX+shop.getId()); |
| | | String token = JwtTokenUtil.generateToken(payLoad); |
| | | // JwtPayLoad payLoad = new JwtPayLoad(Constants.SHOP_PREFIX+shop.getId()); |
| | | // String token = JwtTokenUtil.generateToken(payLoad); |
| | | String token = JwtTokenUtil.generateTokenForRedis(shop.getId(), Constants.ONE, JSONObject.toJSONString(shop), redisTemplate); |
| | | AccountResponse accountResponse = new AccountResponse(); |
| | | accountResponse.setToken(token); |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getOpenId,dto.getOpenid()) |
| | | .set(Shop::getMemberId,dto.getMemberId()) |
| | | .eq(Shop::getId,shop.getId()) |
| | | ); |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getOpenId,null) |
| | | .eq(Shop::getOpenId,dto.getOpenid()) |
| | | .ne(Shop::getId,shop.getId()) |
| | | ); |
| | | accountResponse.setShop(this.getShopResponseInfo(shop)); |
| | | |
| | | if(StringUtils.isNotBlank(dto.getOpenid())){ |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getOpenId,dto.getOpenid()) |
| | | .eq(Shop::getId,shop.getId()) |
| | | ); |
| | | shopMapper.update(null,new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getOpenId,null) |
| | | .eq(Shop::getOpenId,dto.getOpenid()) |
| | | .ne(Shop::getId,shop.getId()) |
| | | ); |
| | | } |
| | | return accountResponse; |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public ShopInfoResponse getShopInfo(Integer shopId){ |
| | | ShopInfoResponse response = new ShopInfoResponse(); |
| | | |
| | | Shop shop = shopMapper.selectById(shopId); |
| | | if(Objects.isNull(shop)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode(); |
| | | BeanUtils.copyProperties(shop,response); |
| | | response.setImgurl(path + shop.getImgurl()); |
| | | response.setIdcardImg(path + shop.getIdcardImg()); |
| | | response.setIdcardImgBack(path + shop.getIdcardImgBack()); |
| | | response.setBusinessImg(path + shop.getBusinessImg()); |
| | | return this.getShopResponseInfo(shop) ; |
| | | } |
| | | |
| | | |
| | | public ShopInfoResponse getShopResponseInfo(Shop shop){ |
| | | ShopInfoResponse response = new ShopInfoResponse(); |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() ; |
| | | String shopFile = systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode(); |
| | | BeanUtils.copyProperties(shop,response); |
| | | response.setImgurl(StringUtils.isNotBlank(shop.getImgurl())?(path + shopFile + shop.getImgurl()):""); |
| | | response.setIdcardImg(StringUtils.isNotBlank(shop.getIdcardImg())?(path + shopFile + shop.getIdcardImg()):""); |
| | | response.setIdcardImgBack(StringUtils.isNotBlank(shop.getIdcardImgBack())?(path + shopFile + shop.getIdcardImgBack()):""); |
| | | response.setBusinessImg(StringUtils.isNotBlank(shop.getBusinessImg())?(path + shopFile + shop.getBusinessImg()):""); |
| | | response.setAreas(AreasServiceImpl.getAddressByAreaId(shop.getAreaId())); |
| | | if(StringUtils.isNotBlank(shop.getProgramCode())){ |
| | | String sharesFile = systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHARES_FILE).getCode(); |
| | | response.setProgramCode(path + sharesFile + shop.getProgramCode()); |
| | | } |
| | | if(StringUtils.isNotBlank(shop.getPosterImgCode())){ |
| | | String sharesFile = systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHARES_FILE).getCode(); |
| | | response.setPosterImgCode(path + sharesFile + shop.getPosterImgCode()); |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<MyCustomerResponse> myCustomer(MyCustomerRequest request, Integer shopId){ |
| | | List<Member> memberList = memberJoinMapper.selectJoinList(Member.class, |
| | | new MPJLambdaWrapper<Member>() |
| | | .selectAll(Member.class) |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .eq(Member::getBindShopId,shopId) |
| | | .and(StringUtils.isNotBlank(request.getMemberIfo()),i->i.like(Member::getPhone,request.getMemberIfo()).or().like(Member::getNickname,request.getMemberIfo())) |
| | | public PageData<Member> myCustomer(PageWrap<MyCustomerRequest> pageWrap, Integer shopId){ |
| | | IPage<Member> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | MyCustomerRequest model = pageWrap.getModel(); |
| | | |
| | | IPage<Member> result = memberJoinMapper.selectJoinPage(page,Member.class, new MPJLambdaWrapper<Member>() |
| | | .selectAll(Member.class) |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .eq(Member::getBindShopId,shopId) |
| | | .and(StringUtils.isNotBlank(model.getMemberInfo()),i->i.like(Member::getPhone,model.getMemberInfo()).or().like(Member::getNickname,model.getMemberInfo())) |
| | | ); |
| | | List<MyCustomerResponse> responseList = new ArrayList<>(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){ |
| | | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(result.getRecords())){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILE).getCode(); |
| | | memberList.forEach(member -> { |
| | | MyCustomerResponse response = new MyCustomerResponse(); |
| | | response.setNickName(member.getNickname()); |
| | | response.setPhone(member.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2")); |
| | | response.setBindShopDate(member.getBindShopDate()); |
| | | response.setImgFullUrl(StringUtils.isNotBlank(member.getImgurl())?path + member.getImgurl():""); |
| | | responseList.add(response); |
| | | result.getRecords().forEach(member -> { |
| | | member.setPhone(member.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})","$1****$2")); |
| | | member.setImgFullUrl(StringUtils.isNotBlank(member.getImgurl())?path + member.getImgurl():""); |
| | | }); |
| | | } |
| | | return responseList; |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public SaleReportResponse saleReport(SaleReportRequest request,String shopId){ |
| | | public SaleReportResponse saleReport(SaleReportRequest request,Integer shopId){ |
| | | SaleReportResponse saleReportResponse = new SaleReportResponse(); |
| | | saleReportResponse.setSaleTotal(BigDecimal.ZERO); |
| | | saleReportResponse.setOrderNum(Constants.ZERO); |
| | |
| | | .selectAll(Goodsorder.class) |
| | | .selectAs(Member::getPhone,Goodsorder::getPhone) |
| | | .selectAs(Member::getNickname,Goodsorder::getNickName) |
| | | .select(" select ifnull(sum(g.SHOP_SETTLEMENT),0) from goodsorder_detail g where t.id = g.ORDER_ID ",Goodsorder::getShopSettlement) |
| | | .leftJoin(Member.class,Member::getId,Goodsorder::getMemberId) |
| | | .eq(Goodsorder::getIsdeleted,Constants.ZERO) |
| | | .eq(Goodsorder::getDistributionShopId,shopId) |
| | | //今日 |
| | | .apply(Constants.equalsInteger(request.getDateType(),Constants.ZERO), " DATE(t.CREATE_DATE) = DATE(NOW()) ") |
| | | .apply(Objects.nonNull(request.getDateType())&&Constants.equalsInteger(request.getDateType(),Constants.ZERO), " DATE(t.CREATE_DATE) = DATE(NOW()) ") |
| | | //当月 |
| | | .apply(Constants.equalsInteger(request.getDateType(),Constants.ONE), " DATE_FORMAT(t.CREATE_DATE, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m')") |
| | | .apply(Objects.nonNull(request.getDateType())&&Constants.equalsInteger(request.getDateType(),Constants.ONE), " DATE_FORMAT(t.CREATE_DATE, '%Y-%m') = DATE_FORMAT(NOW(), '%Y-%m')") |
| | | //上月 |
| | | .apply(Constants.equalsInteger(request.getDateType(),Constants.TWO), " DATE_FORMAT(t.CREATE_DATE, '%Y-%m') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') ") |
| | | .apply(Objects.nonNull(request.getDateType())&&Constants.equalsInteger(request.getDateType(),Constants.TWO), " DATE_FORMAT(t.CREATE_DATE, '%Y-%m') = DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') ") |
| | | //固定月份 |
| | | .apply(Constants.equalsInteger(request.getDateType(),Constants.THREE)&&StringUtils.isNotBlank(request.getStartDate()), " DATE_FORMAT(t.CREATE_DATE, '%Y-%m') = DATE_FORMAT(DATE_SUB('"+request.getStartDate()+"', INTERVAL 1 MONTH), '%Y-%m') ") |
| | | .apply(Objects.nonNull(request.getDateType())&&Constants.equalsInteger(request.getDateType(),Constants.THREE)&&StringUtils.isNotBlank(request.getStartDate()), " DATE_FORMAT(t.CREATE_DATE, '%Y-%m') = DATE_FORMAT(DATE_SUB('"+request.getStartDate()+"', INTERVAL 1 MONTH), '%Y-%m') ") |
| | | //自定义日期 |
| | | .apply(Constants.equalsInteger(request.getDateType(),Constants.FOUR)&&StringUtils.isNotBlank(request.getStartDate()), " t.CREATE_DATE >= '"+request.getStartDate()+" 00:00:00'") |
| | | .apply(Constants.equalsInteger(request.getDateType(),Constants.FOUR)&&StringUtils.isNotBlank(request.getEndDate()), " t.CREATE_DATE <= '"+request.getEndDate()+" 23:59:59'") |
| | | .apply(Objects.nonNull(request.getDateType())&&Constants.equalsInteger(request.getDateType(),Constants.FOUR)&&StringUtils.isNotBlank(request.getStartDate()), " t.CREATE_DATE >= '"+request.getStartDate()+" 00:00:00'") |
| | | .apply(Objects.nonNull(request.getDateType())&&Constants.equalsInteger(request.getDateType(),Constants.FOUR)&&StringUtils.isNotBlank(request.getEndDate()), " t.CREATE_DATE <= '"+request.getEndDate()+" 23:59:59'") |
| | | .ne(Goodsorder::getStatus,Constants.OrderStatus.CLOSE.getKey()) |
| | | .orderByDesc(Goodsorder::getId) |
| | | ); |
| | | |
| | | if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(goodsorderList)) { |
| | | saleReportResponse.setSaleTotal(goodsorderList.stream().map(i->i.getPrice().subtract(i.getMailPrice())).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | saleReportResponse.setOrderNum(goodsorderList.size()); |
| | | if(Constants.equalsInteger(request.getQueryType(),Constants.ONE)){ |
| | | List<SaleReportOrderResponse> list = new ArrayList<>(); |
| | | goodsorderList.stream().forEach(goodsorder -> { |
| | | SaleReportOrderResponse response = new SaleReportOrderResponse(); |
| | | response.setId(goodsorder.getId()); |
| | | response.setCode(goodsorder.getCode()); |
| | | response.setPrice(goodsorder.getPrice()); |
| | | response.setMailPrice(goodsorder.getMailPrice()); |
| | | response.setCreateDate(goodsorder.getCreateDate()); |
| | | response.setNickName(goodsorder.getNickName()); |
| | | response.setPhone(goodsorder.getPhone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2")); |
| | | response.setShopSettlement(goodsorder.getShopSettlement()); |
| | | list.add(response); |
| | | }); |
| | | |
| | | saleReportResponse.setSaleReportOrderResponseList(list); |
| | | } |
| | | } |
| | | List<Integral> integralList = integralMapper.selectList(new QueryWrapper<Integral>().lambda() |
| | | .eq(Integral::getIsdeleted,Constants.ZERO) |
| | |
| | | return saleReportResponse; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public String setGoodsPrice(Shop dto){ |
| | |
| | | } |
| | | //默认sku信息 |
| | | GoodsSku goodsSku = goodsSkuList.get(0); |
| | | if(Constants.formatBigdecimal(goodsSku.getPrice()).compareTo(Constants.formatBigdecimal(dto.getGoodsPrice())) >=0){ |
| | | if(Constants.formatBigdecimal(goodsSku.getPrice()).compareTo(Constants.formatBigdecimal(dto.getGoodsPrice()))<=0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,供货价不允许大于商品销售价!"); |
| | | } |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | |
| | | shopGoodsRelationMapper.insert(add); |
| | | return "操作成功"; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void logOut(String token,Integer shopId){ |
| | | Shop shop = shopMapper.selectById(shopId); |
| | | if(Objects.nonNull(shop)&&StringUtils.isNotBlank(shop.getOpenId())){ |
| | | shopMapper.update(new UpdateWrapper<Shop>().lambda() |
| | | .set(Shop::getOpenId,null) |
| | | .eq(Shop::getId,shop.getId()) |
| | | ); |
| | | } |
| | | redisTemplate.delete(token); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |