Browse Source

商家端新增商家会员信息获取后台业务功能

multiwx
dy-hu 7 months ago
parent
commit
c1a9708b2d
  1. 2
      cereshop-admin/src/main/resources/mybatis/mapper/buyer/CereBuyerUserDAO.xml
  2. 212
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/BusinessBuyerUserController.java
  3. 66
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/business/BusinessBuyerUserDAO.java
  4. 15
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/channel/ChannelDAO.java
  5. 29
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/credit/CereCreditRecordDAO.java
  6. 31
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/credit/CereCreditSignSettingDAO.java
  7. 12
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CereBuyerLabelDAO.java
  8. 6
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/order/CereShopOrderDAO.java
  9. 37
      cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerComment.java
  10. 50
      cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerOrder.java
  11. 108
      cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerUser.java
  12. 133
      cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerUserDetail.java
  13. 96
      cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerUserExportDTO.java
  14. 24
      cereshop-business/src/main/java/com/shop/cereshop/business/page/channel/ChannelDTO.java
  15. 24
      cereshop-business/src/main/java/com/shop/cereshop/business/page/credit/CereCreditRecordPage.java
  16. 30
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerBlackListParam.java
  17. 94
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerGetAllParam.java
  18. 30
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerGetByIdParam.java
  19. 30
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerGetLabelsParam.java
  20. 32
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerSaveUserLabelParam.java
  21. 16
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessUpdateCreditParam.java
  22. 15
      cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessUserSearchParam.java
  23. 13
      cereshop-business/src/main/java/com/shop/cereshop/business/param/channel/ChannelGetAllParam.java
  24. 20
      cereshop-business/src/main/java/com/shop/cereshop/business/param/channel/ChannelParam.java
  25. 24
      cereshop-business/src/main/java/com/shop/cereshop/business/param/credit/CreditRecordGetAllParam.java
  26. 16
      cereshop-business/src/main/java/com/shop/cereshop/business/param/credit/UpdateCreditParam.java
  27. 83
      cereshop-business/src/main/java/com/shop/cereshop/business/service/buyer/CereBusinessBuyerUserService.java
  28. 255
      cereshop-business/src/main/java/com/shop/cereshop/business/service/buyer/impl/CereBusinessBuyerUserServiceImpl.java
  29. 38
      cereshop-business/src/main/java/com/shop/cereshop/business/service/channel/ChannelService.java
  30. 120
      cereshop-business/src/main/java/com/shop/cereshop/business/service/channel/impl/ChannelServiceImpl.java
  31. 24
      cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/CereCreditRecordService.java
  32. 31
      cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/CereCreditSignSettingService.java
  33. 53
      cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/impl/CereCreditRecordServiceImpl.java
  34. 70
      cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/impl/CereCreditSignSettingServiceImpl.java
  35. 15
      cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CereBuyerLabelService.java
  36. 36
      cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CereBuyerLabelServiceImpl.java
  37. 3
      cereshop-business/src/main/resources/application-business-dev.yml
  38. 3
      cereshop-business/src/main/resources/application-business-prod.yml
  39. 3
      cereshop-business/src/main/resources/application-business-test.yml
  40. 347
      cereshop-business/src/main/resources/mybatis/mapper/business/BusinessBuyerUserDAO.xml
  41. 18
      cereshop-business/src/main/resources/mybatis/mapper/buyer/CereBuyerUserDAO.xml
  42. 31
      cereshop-business/src/main/resources/mybatis/mapper/label/CereBuyerLabelDAO.xml

2
cereshop-admin/src/main/resources/mybatis/mapper/buyer/CereBuyerUserDAO.xml

@ -229,7 +229,7 @@
GROUP BY buyer_user_id) b ON a.buyer_user_id=b.buyer_user_id
LEFT JOIN cere_buyer_label c ON a.buyer_user_id=c.buyer_user_id
LEFT JOIN cere_platform_member_level d ON a.member_level_id=d.member_level_id
where 1=1
where a.project = 0
<if test="name!=null and name!=''">
and (a.wechat_name like concat('%',#{name},'%') or
a.`name` like concat('%',#{name},'%'))

212
cereshop-business/src/main/java/com/shop/cereshop/business/controller/BusinessBuyerUserController.java

@ -0,0 +1,212 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.controller;
import com.shop.cereshop.business.annotation.NoRepeatSubmit;
import com.shop.cereshop.business.annotation.NoRepeatWebLog;
import com.shop.cereshop.business.page.buyer.*;
import com.shop.cereshop.business.param.buyer.*;
import com.shop.cereshop.business.service.buyer.CereBusinessBuyerUserService;
import com.shop.cereshop.business.service.buyer.CereBuyerUserService;
import com.shop.cereshop.business.service.channel.ChannelService;
import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.channel.Channel;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.poi.export.ExcelExportUtils;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.commons.utils.GsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 客户管理
*/
@RestController
@RequestMapping("businessBuyer")
/**
* 注解方式生成日志对象指定topic生成对象类名
*/
@Slf4j(topic = "BuyerUserController")
@Api(value = "客户管理模块", tags = "客户管理模块")
public class BusinessBuyerUserController {
@Autowired
private CereBusinessBuyerUserService cereBuyerUserService;
@Autowired
private ChannelService channelService;
/**
* 客户管理查询
* @param param
* @return
*/
@PostMapping(value = "getAll")
@ApiOperation(value = "客户管理查询")
public Result<Page<BuyerUser>> getAll(@RequestBody BusinessBuyerGetAllParam param, HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
param.setProject(String.valueOf(user.getBusinessId()));
Page page=cereBuyerUserService.getAll(param);
return new Result(page);
}
/**
* 客户详情查询
* @param param
* @return
*/
@PostMapping(value = "getById")
@ApiOperation(value = "客户详情查询")
public Result<BusinessBuyerUserDetail> getById(@RequestBody BusinessBuyerGetByIdParam param) throws CoBusinessException{
BusinessBuyerUserDetail detail=cereBuyerUserService.getById(param);
return new Result(detail);
}
/**
* 客户绑定标签查询
* @param param
* @return
*/
@PostMapping(value = "getUserLabels")
@ApiOperation(value = "客户绑定标签查询")
public Result<List<CerePlatformLabel>> getUserLabels(@RequestBody BusinessBuyerGetLabelsParam param) throws CoBusinessException{
List<CerePlatformLabel> list=cereBuyerUserService.getUserLabels(param);
return new Result(list);
}
/**
* 标签查询
* @param param
* @return
*/
@PostMapping(value = "getLabels")
@ApiOperation(value = "标签查询")
public Result<List<CerePlatformLabel>> getLabels(@RequestBody BusinessBuyerGetLabelsParam param) throws CoBusinessException{
List<CerePlatformLabel> list=cereBuyerUserService.getLabels(param);
return new Result(list);
}
/**
* 贴标签
* @param param
* @return
*/
@PostMapping(value = "saveUserLabel")
@NoRepeatSubmit
@ApiOperation(value = "贴标签")
@NoRepeatWebLog
public Result saveUserLabel(@RequestBody BusinessBuyerSaveUserLabelParam param,
HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
cereBuyerUserService.saveUserLabel(param,user);
return new Result(user.getUsername(),"贴标签", GsonUtil.objectToGson(param));
}
/**
* 加入或取消黑名单
* @param param
* @return
*/
@PostMapping(value = "blacklist")
@NoRepeatSubmit
@ApiOperation(value = "加入和取消黑名单")
@NoRepeatWebLog
public Result blacklist(@RequestBody BusinessBuyerBlackListParam param,
HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
cereBuyerUserService.blacklist(param,user);
return new Result(user.getUsername(),"加入或取消黑名单", GsonUtil.objectToGson(param));
}
/**
* 更新积分
* @param param
* @return
*/
@PostMapping(value = "updateCredit")
@NoRepeatSubmit
@ApiOperation(value = "更新积分")
@NoRepeatWebLog
public Result updateCredit(@RequestBody BusinessUpdateCreditParam param,
HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
cereBuyerUserService.updateCredit(param,user);
return new Result(user.getUsername(),"更改积分", GsonUtil.objectToGson(param));
}
/**
* 搜索用户信息
* @param param
* @return
*/
@PostMapping(value = "searchUser")
@NoRepeatSubmit
@ApiOperation(value = "搜索用户信息")
@NoRepeatWebLog
public Result<Page<CereBuyerUser>> searchUser(@RequestBody BusinessUserSearchParam param) {
Page<CereBuyerUser> page = cereBuyerUserService.searchUser(param);
return new Result(page);
}
@PostMapping(value = "export")
@ApiOperation(value = "用户列表导出")
public void export(@RequestBody BusinessBuyerGetAllParam param, HttpServletRequest request, HttpServletResponse response) throws CoBusinessException {
param.setPage(null);
param.setPageSize(null);
Page<BusinessBuyerUser> page = cereBuyerUserService.getAll(param);
List<BusinessBuyerUserExportDTO> list = new ArrayList<>();
List<String> channelCodeList = page.getList().stream().filter(obj -> StringUtils.isNotBlank(obj.getChannelCode()))
.map(BusinessBuyerUser::getChannelCode).distinct().collect(Collectors.toList());
Map<String, String> channelNameMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(channelCodeList)) {
List<Channel> channelList = channelService.selectByChannelCodeList(channelCodeList);
channelNameMap = channelList.stream().collect(Collectors.toMap(Channel::getChannelCode, Channel::getChannelName));
}
for (BusinessBuyerUser buyerUser:page.getList()) {
BusinessBuyerUserExportDTO dto = new BusinessBuyerUserExportDTO();
BeanUtils.copyProperties(buyerUser, dto);
IntegerEnum terminalEnum = IntegerEnum.terminalMap.get(buyerUser.getTerminal());
if (terminalEnum != null) {
dto.setTerminal(terminalEnum.getName());
}
String channelCode = buyerUser.getChannelCode();
if (channelCode != null) {
dto.setChannelName(channelNameMap.get(channelCode));
}
list.add(dto);
}
//定义导出的excel名字
String excelName = "用户列表";
ExcelExportUtils.exportExcel(request, response, excelName, list, BuyerUserExportDTO.class);
}
}

66
cereshop-business/src/main/java/com/shop/cereshop/business/dao/business/BusinessBuyerUserDAO.java

@ -0,0 +1,66 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.dao.business;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.business.page.buyer.*;
import com.shop.cereshop.business.param.buyer.BusinessBuyerGetAllParam;
import com.shop.cereshop.business.param.buyer.BusinessBuyerGetByIdParam;
import com.shop.cereshop.business.param.buyer.BusinessBuyerGetLabelsParam;
import com.shop.cereshop.commons.domain.buyer.CereBuyerReceive;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
@Mapper
public interface BusinessBuyerUserDAO extends BaseMapper<CereBuyerUser> {
int deleteByPrimaryKey(Long buyerUserId);
int insertSelective(CereBuyerUser record);
CereBuyerUser selectByPrimaryKey(Long buyerUserId);
int updateByPrimaryKeySelective(CereBuyerUser record);
int updateByPrimaryKey(CereBuyerUser record);
List<BusinessBuyerUser> getAll(BusinessBuyerGetAllParam param);
BusinessBuyerUserDetail getById(@Param("buyerUserId") Long buyerUserId);
List<String> findLabels(@Param("buyerUserId") Long buyerUserId);
Integer findOrders(@Param("buyerUserId") Long buyerUserId);
Integer findPays(@Param("buyerUserId") Long buyerUserId);
Integer findProducts(@Param("buyerUserId") Long buyerUserId);
BigDecimal findPrice(@Param("buyerUserId") Long buyerUserId);
Integer findAfters(@Param("buyerUserId") Long buyerUserId);
Integer findAfterOrders(@Param("buyerUserId") Long buyerUserId);
Integer findSuccessAfters(@Param("buyerUserId") Long buyerUserId);
List<BusinessBuyerOrder> findOrderList(BusinessBuyerGetByIdParam param);
List<BusinessBuyerComment> findComments(@Param("buyerUserId") Long buyerUserId);
List<CereBuyerReceive> findReceives(@Param("buyerUserId") Long buyerUserId);
List<CerePlatformLabel> getLabels(BusinessBuyerGetLabelsParam param);
List<CerePlatformLabel> getUserLabels(BusinessBuyerGetLabelsParam param);
int increaseCredit(@Param("buyerUserId") long buyerUserId, @Param("credit") Integer credit);
}

15
cereshop-business/src/main/java/com/shop/cereshop/business/dao/channel/ChannelDAO.java

@ -0,0 +1,15 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.dao.channel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.channel.Channel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ChannelDAO extends BaseMapper<Channel> {
}

29
cereshop-business/src/main/java/com/shop/cereshop/business/dao/credit/CereCreditRecordDAO.java

@ -0,0 +1,29 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.dao.credit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.business.page.credit.CereCreditRecordPage;
import com.shop.cereshop.business.param.credit.CreditRecordGetAllParam;
import com.shop.cereshop.commons.domain.credit.CereCreditRecord;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* Mapper 接口
* 积分流水表
* </p>
*
* @author JustArgo
* @date 2021-12-04
*/
@Mapper
public interface CereCreditRecordDAO extends BaseMapper<CereCreditRecord> {
List<CereCreditRecordPage> getAll(CreditRecordGetAllParam param);
}

31
cereshop-business/src/main/java/com/shop/cereshop/business/dao/credit/CereCreditSignSettingDAO.java

@ -0,0 +1,31 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.dao.credit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.credit.CereCreditSignSetting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* 积分签到配置
* </p>
*
* @author JustArgo
* @date 2021-12-04
*/
@Mapper
public interface CereCreditSignSettingDAO extends BaseMapper<CereCreditSignSetting> {
List<CereCreditSignSetting> getAll(PageParam param);
int selectExistsDay(@Param("day") Integer day, @Param("id") Long id);
}

12
cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CereBuyerLabelDAO.java

@ -5,12 +5,24 @@
*/
package com.shop.cereshop.business.dao.label;
import com.shop.cereshop.business.param.buyer.BusinessBuyerSaveUserLabelParam;
import com.shop.cereshop.commons.domain.label.CereBuyerLabel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CereBuyerLabelDAO extends BaseMapper<CereBuyerLabel> {
int insertSelective(CereBuyerLabel record);
void deleteLabelUser(@Param("ids") List<Long> ids);
void insertBatch(@Param("list") List<CereBuyerLabel> list);
List<Long> findAlreadyByUser(BusinessBuyerSaveUserLabelParam param);
List<Long> findByBuyerUserId(Long buyerUserId);
}

6
cereshop-business/src/main/java/com/shop/cereshop/business/dao/order/CereShopOrderDAO.java

@ -118,4 +118,10 @@ public interface CereShopOrderDAO extends BaseMapper<CereShopOrder> {
List<CereShopOrder> findByParentId(@Param("parentId") Long parentId);
List<CereShopOrder> findByFormid(@Param("orderFormId") String orderFormId);
Integer selectChannelOrderUserCount(String channelCode);
Integer selectChannelOrderCount(String channelCode);
BigDecimal selectChannelOrderAmount(String channelCode);
}

37
cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerComment.java

@ -0,0 +1,37 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.page.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 客户评论返回数据实体类
*/
@Data
@ApiModel(value = "BuyerComment", description = "客户评论返回数据实体类")
public class BusinessBuyerComment {
/**
* 评论id
*/
@ApiModelProperty(value = "评论id")
private Long commentId;
/**
* 店铺名称
*/
@ApiModelProperty(value = "店铺名称")
private String shopName;
/**
* 商品名称
*/
@ApiModelProperty(value = "商品名称")
private String productName;
}

50
cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerOrder.java

@ -0,0 +1,50 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.page.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 客户订单返回数据实体类
*/
@Data
@ApiModel(value = "BuyerOrder", description = "客户订单返回数据实体类")
public class BusinessBuyerOrder {
/**
* 订单编号
*/
@ApiModelProperty(value = "订单编号")
private String orderFormid;
/**
* 店铺名称
*/
@ApiModelProperty(value = "店铺名称")
private String shopName;
/**
* 商品数量
*/
@ApiModelProperty(value = "商品数量")
private Integer products;
/**
* 订单金额
*/
@ApiModelProperty(value = "订单金额")
private BigDecimal price;
/**
* 订单状态 1-待付款 2-待发货 3-待收货 4-已完成 5-已关闭
*/
@ApiModelProperty(value = "订单状态 1-待付款 2-待发货 3-待收货 4-已完成 5-已关闭")
private Integer state;
}

108
cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerUser.java

@ -0,0 +1,108 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.page.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 商家会员返回数据实体类
*/
@Data
@ApiModel(value = "BuyerUser", description = "客户返回数据实体类")
public class BusinessBuyerUser {
/**
* 用户id
*/
@ApiModelProperty(value = "用户id")
private Long buyerUserId;
/**
* 用户昵称
*/
@ApiModelProperty(value = "用户昵称")
private String name;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 会员等级名称
*/
@ApiModelProperty(value = "会员等级名称")
private String memberLevelName;
/**
* 积分
*/
@ApiModelProperty("积分")
private Integer credit;
/**
* 消费总额
*/
@ApiModelProperty(value = "消费总额")
private BigDecimal total;
/**
* 购买次数
*/
@ApiModelProperty(value = "购买次数")
private Integer buyers;
/**
* 最近消费时间
*/
@ApiModelProperty(value = "最近消费时间")
private String time;
/**
* 注册时间
*/
@ApiModelProperty(value = "注册时间")
private String createTime;
/**
* 是否加入黑名单 1- 0-
*/
@ApiModelProperty(value = "是否加入黑名单 1-是 0-否")
private Integer ifBlack;
@ApiModelProperty("标签id列表")
private List<Long> labelIds;
/**
* 注册ip
*/
@ApiModelProperty(value = "注册ip")
private String registerIp;
/**
* 上次登录的ip
*/
@ApiModelProperty(value = "上次登录的ip")
private String lastLoginIp;
/**
* 注册来源
*/
@ApiModelProperty(value = "注册来源")
private Integer terminal;
/**
* 注册渠道
*/
@ApiModelProperty(value = "注册渠道")
private String channelCode;
}

133
cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerUserDetail.java

@ -0,0 +1,133 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.page.buyer;
import com.shop.cereshop.commons.domain.buyer.CereBuyerReceive;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 客户详情返回数据实体类
*/
@Data
@ApiModel(value = "BuyerUserDetail", description = "客户详情返回数据实体类")
public class BusinessBuyerUserDetail {
/**
* 客户id
*/
@ApiModelProperty(value = "客户id")
private Long buyerUserId;
/**
* 用户昵称
*/
@ApiModelProperty(value = "用户昵称")
private String name;
/**
* 头像
*/
@ApiModelProperty(value = "头像")
private String headImage;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 性别
*/
@ApiModelProperty(value = "性别")
private String sex;
/**
* 生日
*/
@ApiModelProperty(value = "生日")
private String birthday;
/**
* 注册时间
*/
@ApiModelProperty(value = "注册时间")
private String createTime;
@ApiModelProperty("标签id列表")
private List<Long> labelIds;
/**
* 标签数据
*/
@ApiModelProperty(value = "标签数据")
private List<String> labels;
/**
* 下单数
*/
@ApiModelProperty(value = "下单数")
private Integer orders;
/**
* 支付成功数
*/
@ApiModelProperty(value = "支付成功数")
private Integer pays;
/**
* 购买商品数
*/
@ApiModelProperty(value = "购买商品数")
private Integer products;
/**
* 累计消费额
*/
@ApiModelProperty(value = "累计消费额")
private BigDecimal price;
/**
* 售后次数
*/
@ApiModelProperty(value = "售后次数")
private Integer afters;
/**
* 售后单数
*/
@ApiModelProperty(value = "售后单数")
private Integer afterOrders;
/**
* 售后成功单数
*/
@ApiModelProperty(value = "售后成功单数")
private Integer successAfters;
/**
* 订单列表
*/
@ApiModelProperty(value = "订单列表")
private List<BusinessBuyerOrder> orderList;
/**
* 评论列表
*/
@ApiModelProperty(value = "评论列表")
private List<BusinessBuyerComment> comments;
/**
* 收货地址列表
*/
@ApiModelProperty(value = "收货地址列表")
private List<CereBuyerReceive> receives;
}

96
cereshop-business/src/main/java/com/shop/cereshop/business/page/buyer/BusinessBuyerUserExportDTO.java

@ -0,0 +1,96 @@
package com.shop.cereshop.business.page.buyer;
import com.shop.cereshop.commons.poi.export.ExcelResources;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class BusinessBuyerUserExportDTO {
/**
* 客户id
*/
@ApiModelProperty(value = "客户id")
@ExcelResources(order=0,title = "客户id",cloumn = 15)
private Long buyerUserId;
/**
* 客户昵称
*/
@ApiModelProperty(value = "客户昵称")
@ExcelResources(order=1,title = "客户昵称",cloumn = 15)
private String name;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
@ExcelResources(order=2,title = "手机号",cloumn = 15)
private String phone;
/**
* 会员等级
*/
@ApiModelProperty(value = "会员等级")
@ExcelResources(order=3,title = "会员等级",cloumn = 15)
private String memberLevelName;
/**
* 消费总额
*/
@ApiModelProperty(value = "消费总额")
@ExcelResources(order=4,title = "消费总额",cloumn = 15)
private BigDecimal total;
/**
* 购买次数
*/
@ApiModelProperty(value = "购买次数")
@ExcelResources(order=5,title = "购买次数",cloumn = 15)
private Integer buyers;
/**
* 上次消费时间
*/
@ApiModelProperty(value = "上次消费时间")
@ExcelResources(order=6,title = "上次消费时间",cloumn = 15)
private String time;
/**
* 注册时间
*/
@ApiModelProperty(value = "注册时间")
@ExcelResources(order=7,title = "注册时间",cloumn = 15)
private String createTime;
/**
* 注册ip
*/
@ApiModelProperty(value = "注册ip")
@ExcelResources(order=8,title = "注册ip",cloumn = 15)
private String registerIp;
/**
* 最后登录ip
*/
@ApiModelProperty(value = "最后登录ip")
@ExcelResources(order=9,title = "最后登录ip",cloumn = 15)
private String lastLoginIp;
/**
* 注册来源
*/
@ApiModelProperty(value = "注册来源")
@ExcelResources(order=10,title = "注册来源",cloumn = 15)
private String terminal;
/**
* 注册渠道
*/
@ApiModelProperty(value = "注册渠道")
@ExcelResources(order=11,title = "注册渠道",cloumn = 15)
private String channelName;
}

24
cereshop-business/src/main/java/com/shop/cereshop/business/page/channel/ChannelDTO.java

@ -0,0 +1,24 @@
package com.shop.cereshop.business.page.channel;
import com.shop.cereshop.commons.domain.channel.Channel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ChannelDTO extends Channel {
@ApiModelProperty("注册人数")
private Integer registerCount;
@ApiModelProperty("下单人数")
private Integer orderUserCount;
@ApiModelProperty("下单数")
private Integer orderCount;
@ApiModelProperty("下单金额")
private BigDecimal orderAmount;
}

24
cereshop-business/src/main/java/com/shop/cereshop/business/page/credit/CereCreditRecordPage.java

@ -0,0 +1,24 @@
package com.shop.cereshop.business.page.credit;
import com.shop.cereshop.commons.domain.credit.CereCreditRecord;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("直播间商品分页查询")
public class CereCreditRecordPage extends CereCreditRecord {
/**
* 用户昵称
*/
@ApiModelProperty("用户昵称")
private String name;
/**
* 用户手机号
*/
@ApiModelProperty("用户手机号")
private String phone;
}

30
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerBlackListParam.java

@ -0,0 +1,30 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 贴标签请求
*/
@Data
@ApiModel(value = "BuyerSaveUserLabelParam", description = "贴标签请求")
public class BusinessBuyerBlackListParam {
/**
* 客户id
*/
@ApiModelProperty(value = "客户id")
private Long buyerUserId;
/**
* 是否加入黑名单 1- 0-
*/
@ApiModelProperty(value = "是否加入黑名单 1-是 0-否")
private Integer ifBlack;
}

94
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerGetAllParam.java

@ -0,0 +1,94 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.buyer;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.utils.EmptyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 获取客户列表请求
*/
@Data
@ApiModel(value = "BuyerGetAllParam", description = "获取客户列表请求")
public class BusinessBuyerGetAllParam extends PageParam {
/**
* 用户昵称
*/
@ApiModelProperty(value = "用户昵称")
private String name;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 标签id
*/
@ApiModelProperty(value = "标签id")
private Long labelId;
/**
* 最近消费时间日期数组
*/
@ApiModelProperty(value = "最近消费时间日期数组")
private List<String> dates;
public void setDates(List<String> dates) {
if(!EmptyUtils.isEmpty(dates)&&dates.size()>1){
this.startTime=dates.get(0)+" 00:00:00";
this.endTime=dates.get(1)+" 23:59:59";
}
}
/**
* 累计消费金额最小值
*/
@ApiModelProperty(value = "累计消费金额最小值")
private BigDecimal minMoney;
/**
* 累计消费金额最大值
*/
@ApiModelProperty(value = "累计消费金额最大值")
private BigDecimal maxMoney;
/**
* 购买次数最小值
*/
@ApiModelProperty(value = "购买次数最小值")
private Integer minBuyers;
/**
* 购买次数最大值
*/
@ApiModelProperty(value = "购买次数最大值")
private Integer maxBuyers;
/**
* 申请开始时间
*/
@ApiModelProperty(value = "申请开始时间")
private String startTime;
/**
* 申请结束时间
*/
@ApiModelProperty(value = "申请结束时间")
private String endTime;
@ApiModelProperty(value = "商家id")
private String project;
}

30
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerGetByIdParam.java

@ -0,0 +1,30 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取客户详情请求
*/
@Data
@ApiModel(value = "BuyerGetByIdParam", description = "获取客户详情请求")
public class BusinessBuyerGetByIdParam {
/**
* 客户id
*/
@ApiModelProperty(value = "客户id")
private Long buyerUserId;
/**
* 订单编号
*/
@ApiModelProperty(value = "订单编号")
private String orderFormid;
}

30
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerGetLabelsParam.java

@ -0,0 +1,30 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取标签列表请求
*/
@Data
@ApiModel(value = "BuyerGetLabelsParam", description = "获取标签列表请求")
public class BusinessBuyerGetLabelsParam {
/**
* 标签名称
*/
@ApiModelProperty(value = "标签名称")
private String labelName;
/**
* 客户id
*/
@ApiModelProperty(value = "客户id")
private Long buyerUserId;
}

32
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessBuyerSaveUserLabelParam.java

@ -0,0 +1,32 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 贴标签请求
*/
@Data
@ApiModel(value = "BuyerSaveUserLabelParam", description = "贴标签请求")
public class BusinessBuyerSaveUserLabelParam {
/**
* 关联客户id
*/
@ApiModelProperty(value = "关联客户id")
private Long buyerUserId;
/**
* 关联平台标签id数组
*/
@ApiModelProperty(value = "关联平台标签id数组")
private List<Long> buyerLabelIds;
}

16
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessUpdateCreditParam.java

@ -0,0 +1,16 @@
package com.shop.cereshop.business.param.buyer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("修改积分的参数")
public class BusinessUpdateCreditParam {
@ApiModelProperty("用户id")
private Long buyerUserId;
@ApiModelProperty("积分值 扣减积分则传负数")
private Integer credit;
}

15
cereshop-business/src/main/java/com/shop/cereshop/business/param/buyer/BusinessUserSearchParam.java

@ -0,0 +1,15 @@
package com.shop.cereshop.business.param.buyer;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("用户搜索条件")
public class BusinessUserSearchParam extends PageParam {
@ApiModelProperty("buyerUserId/openId/昵称/手机号")
private String searchKey;
}

13
cereshop-business/src/main/java/com/shop/cereshop/business/param/channel/ChannelGetAllParam.java

@ -0,0 +1,13 @@
package com.shop.cereshop.business.param.channel;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* 获取渠道列表请求
*/
@Data
@ApiModel(value = "ChannelGetAllParam", description = "获取渠道列表请求")
public class ChannelGetAllParam extends PageParam {
}

20
cereshop-business/src/main/java/com/shop/cereshop/business/param/channel/ChannelParam.java

@ -0,0 +1,20 @@
package com.shop.cereshop.business.param.channel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 渠道参数
*/
@Data
@ApiModel(value = "ChannelParam", description = "渠道参数")
public class ChannelParam {
@ApiModelProperty("渠道id")
private Long id;
@ApiModelProperty("渠道名称")
private String channelName;
}

24
cereshop-business/src/main/java/com/shop/cereshop/business/param/credit/CreditRecordGetAllParam.java

@ -0,0 +1,24 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.credit;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取积分记录请求
* @author
*/
@Data
@ApiModel(value = "CreditRecordGetAllParam", description = "获取积分记录请求")
public class CreditRecordGetAllParam extends PageParam {
@ApiModelProperty("搜索关键词")
private String search;
}

16
cereshop-business/src/main/java/com/shop/cereshop/business/param/credit/UpdateCreditParam.java

@ -0,0 +1,16 @@
package com.shop.cereshop.business.param.credit;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("修改积分的参数")
public class UpdateCreditParam {
@ApiModelProperty("用户id")
private Long buyerUserId;
@ApiModelProperty("积分值 扣减积分则传负数")
private Integer credit;
}

83
cereshop-business/src/main/java/com/shop/cereshop/business/service/buyer/CereBusinessBuyerUserService.java

@ -0,0 +1,83 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.buyer;
import com.shop.cereshop.business.page.buyer.BusinessBuyerUser;
import com.shop.cereshop.business.page.buyer.BusinessBuyerUserDetail;
import com.shop.cereshop.business.param.buyer.*;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.util.List;
public interface CereBusinessBuyerUserService {
/**
* 分页查询客户
* @param param
* @return
* @throws CoBusinessException
*/
Page<BusinessBuyerUser> getAll(BusinessBuyerGetAllParam param) throws CoBusinessException;
/**
* 根据主键查询客户
* @param param
* @return
* @throws CoBusinessException
*/
BusinessBuyerUserDetail getById(BusinessBuyerGetByIdParam param) throws CoBusinessException;
/**
* 查询客户标签
* @param param
* @return
* @throws CoBusinessException
*/
List<CerePlatformLabel> getLabels(BusinessBuyerGetLabelsParam param) throws CoBusinessException;
/**
* 保存用户标签
* @param param
* @param user
* @throws CoBusinessException
*/
void saveUserLabel(BusinessBuyerSaveUserLabelParam param, CerePlatformBusinessUser user) throws CoBusinessException;
/**
* 将客户加入/取消黑名单
* @param param
* @param user
* @throws CoBusinessException
*/
void blacklist(BusinessBuyerBlackListParam param, CerePlatformBusinessUser user) throws CoBusinessException;
/**
* 条件查询标签
* @param param
* @return
* @throws CoBusinessException
*/
List<CerePlatformLabel> getUserLabels(BusinessBuyerGetLabelsParam param) throws CoBusinessException;
/**
* 增加/减少客户积分
* @param param
* @param user
* @throws CoBusinessException
*/
void updateCredit(BusinessUpdateCreditParam param, CerePlatformBusinessUser user) throws CoBusinessException;
/**
* 搜索用户
* @param param
* @return
*/
Page<CereBuyerUser> searchUser(BusinessUserSearchParam param);
}

255
cereshop-business/src/main/java/com/shop/cereshop/business/service/buyer/impl/CereBusinessBuyerUserServiceImpl.java

@ -0,0 +1,255 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.buyer.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.business.BusinessBuyerUserDAO;
import com.shop.cereshop.business.dao.credit.CereCreditRecordDAO;
import com.shop.cereshop.business.page.buyer.BusinessBuyerUser;
import com.shop.cereshop.business.page.buyer.BusinessBuyerUserDetail;
import com.shop.cereshop.business.param.buyer.*;
import com.shop.cereshop.business.service.buyer.CereBusinessBuyerUserService;
import com.shop.cereshop.business.service.label.CereBuyerLabelService;
import com.shop.cereshop.business.service.log.CerePlatformLogService;
import com.shop.cereshop.business.utils.EncodeUtil;
import com.shop.cereshop.commons.cache.constants.CacheKeyConstants;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.constant.CreditOptTypeEnum;
import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.buyer.CereBuyerReceive;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.credit.CereCreditRecord;
import com.shop.cereshop.commons.domain.label.CereBuyerLabel;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Service
public class CereBusinessBuyerUserServiceImpl implements CereBusinessBuyerUserService {
@Autowired
private BusinessBuyerUserDAO businessBuyerUserDAO;
@Autowired
private CereBuyerLabelService cereBuyerLabelService;
@Autowired
private CerePlatformLogService cerePlatformLogService;
@Autowired
private RedissonClient redissonClient;
@Autowired
private CereCreditRecordDAO cereCreditRecordDAO;
@Autowired
private EncodeUtil encodeUtil;
@Override
public Page<BusinessBuyerUser> getAll(BusinessBuyerGetAllParam param) throws CoBusinessException {
if (param.getPage() != null && param.getPageSize() != null) {
PageHelper.startPage(param.getPage(),param.getPageSize());
}
long start = System.currentTimeMillis();
log.info("start " + start);
List<BusinessBuyerUser> list = businessBuyerUserDAO.getAll(param);
log.info("end " + (System.currentTimeMillis() - start));
for(BusinessBuyerUser user:list) {
List<Long> labelIds = cereBuyerLabelService.findByBuyerUserId(user.getBuyerUserId());
user.setLabelIds(labelIds);
user.setPhone(encodeUtil.encodePhone(user.getPhone()));
user.setName(encodeUtil.encodeInfo(user.getName()));
}
PageInfo<BusinessBuyerUser> pageInfo=new PageInfo<>(list);
Page<BusinessBuyerUser> page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
@Override
public BusinessBuyerUserDetail getById(BusinessBuyerGetByIdParam param) throws CoBusinessException {
//查询客户数据
BusinessBuyerUserDetail detail=businessBuyerUserDAO.getById(param.getBuyerUserId());
if(detail!=null){
detail.setName(encodeUtil.encodeInfo(detail.getName()));
detail.setPhone(encodeUtil.encodePhone(detail.getPhone()));
//查询用户标签数据
detail.setLabels(businessBuyerUserDAO.findLabels(param.getBuyerUserId()));
//查询标签id
detail.setLabelIds(cereBuyerLabelService.findByBuyerUserId(detail.getBuyerUserId()));
//查询下单数
detail.setOrders(businessBuyerUserDAO.findOrders(param.getBuyerUserId()));
//查询支付成功数
detail.setPays(businessBuyerUserDAO.findPays(param.getBuyerUserId()));
//查询购买商品数
detail.setProducts(businessBuyerUserDAO.findProducts(param.getBuyerUserId()));
//查询累计消费额
detail.setPrice(businessBuyerUserDAO.findPrice(param.getBuyerUserId()));
//查询售后次数
detail.setAfters(businessBuyerUserDAO.findAfters(param.getBuyerUserId()));
//查询售后单数
detail.setAfterOrders(businessBuyerUserDAO.findAfterOrders(param.getBuyerUserId()));
//查询售后成功单数
detail.setSuccessAfters(businessBuyerUserDAO.findSuccessAfters(param.getBuyerUserId()));
//查询订单列表
detail.setOrderList(businessBuyerUserDAO.findOrderList(param));
//查询评论列表
detail.setComments(businessBuyerUserDAO.findComments(param.getBuyerUserId()));
//查询收货地址列表
List<CereBuyerReceive> receiveList = businessBuyerUserDAO.findReceives(param.getBuyerUserId());
for (CereBuyerReceive receive:receiveList) {
receive.setReceivePhone(encodeUtil.encodePhone(receive.getReceivePhone()));
receive.setReceiveName(encodeUtil.encodeInfo(receive.getReceiveName()));
receive.setReceiveAdress(encodeUtil.encodeInfo(receive.getReceiveAdress()));
receive.setAddress(encodeUtil.encodeInfo(receive.getAddress()));
}
detail.setReceives(receiveList);
}
return detail;
}
@Override
public List<CerePlatformLabel> getLabels(BusinessBuyerGetLabelsParam param) throws CoBusinessException {
return businessBuyerUserDAO.getLabels(param);
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void saveUserLabel(BusinessBuyerSaveUserLabelParam param, CerePlatformBusinessUser user) throws CoBusinessException {
String time= TimeUtils.yyMMddHHmmss();
if(!EmptyUtils.isEmpty(param.getBuyerLabelIds())){
//查询客户已有标签的
List<Long> ids=cereBuyerLabelService.findAlreadyByUser(param);
if(!EmptyUtils.isEmpty(ids)){
//过滤已有标签
for (int i = 0; i < param.getBuyerLabelIds().size(); i++) {
if(ids.contains(param.getBuyerLabelIds().get(i))){
param.getBuyerLabelIds().remove(i);
i--;
}
}
}
if(!EmptyUtils.isEmpty(param.getBuyerLabelIds())){
for (Long id:param.getBuyerLabelIds()) {
CereBuyerLabel cereBuyerLabel=new CereBuyerLabel();
cereBuyerLabel.setBuyerUserId(param.getBuyerUserId());
cereBuyerLabel.setBuyerLabelId(id);
cereBuyerLabelService.insert(cereBuyerLabel);
//新增日志
cerePlatformLogService.addLog(user,"客户管理","商家端操作","贴标签",param.getBuyerUserId(),time);
}
}
}
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void blacklist(BusinessBuyerBlackListParam param, CerePlatformBusinessUser user) throws CoBusinessException {
String time =TimeUtils.yyMMddHHmmss();
String describe="";
CereBuyerUser cereBuyerUser=new CereBuyerUser();
cereBuyerUser.setBuyerUserId(param.getBuyerUserId());
cereBuyerUser.setIfBlack(param.getIfBlack());
cereBuyerUser.setUpdateTime(time);
businessBuyerUserDAO.updateByPrimaryKeySelective(cereBuyerUser);
if(IntegerEnum.YES.getCode().equals(param.getIfBlack())){
//加入黑名单
describe="加入黑名单";
}else {
//取消黑名单
describe="取消黑名单";
}
//新增日志
cerePlatformLogService.addLog(user,"客户管理","商家端操作",describe,param.getBuyerUserId(),time);
}
@Override
public List<CerePlatformLabel> getUserLabels(BusinessBuyerGetLabelsParam param) throws CoBusinessException {
return businessBuyerUserDAO.getUserLabels(param);
}
@Override
public void updateCredit(BusinessUpdateCreditParam param, CerePlatformBusinessUser user) throws CoBusinessException {
//定义加锁key
String key = CacheKeyConstants.CREDIT_LOCK + param.getBuyerUserId();
//加锁
RLock redissonLock = redissonClient.getLock(key);
String time = TimeUtils.yyMMddHHmmss();
long buyerUserId = param.getBuyerUserId();
Integer credit = param.getCredit();
if (credit == 0) {
return;
}
Integer absCredit = Math.abs(param.getCredit());
boolean notEnoughCredit = false;
try {
redissonLock.lock();
CereBuyerUser buyerUser = businessBuyerUserDAO.selectById(buyerUserId);
if (credit < 0 && buyerUser.getCredit() < absCredit) {
notEnoughCredit = true;
} else {
CreditOptTypeEnum typeEnum = CreditOptTypeEnum.ADMIN_ADD;
String describe = "增加"+absCredit+"积分";
if (credit < 0) {
typeEnum = CreditOptTypeEnum.ADMIN_SUB;
describe = "扣减"+absCredit+"积分";
}
businessBuyerUserDAO.increaseCredit(buyerUserId, param.getCredit());
//增加积分记录
CereCreditRecord record = CreditOptTypeEnum.initRecord(typeEnum);
record.setBuyerUserId(buyerUserId);
record.setCreateTime(time);
record.setUpdateTime(time);
record.setCredit(absCredit);
record.setRemainCredit(buyerUser.getCredit() + credit);
cereCreditRecordDAO.insert(record);
//新增日志
cerePlatformLogService.addLog(user,"客户管理","商家端操作",describe,param.getBuyerUserId(),time);
}
} catch (Exception e) {
log.error("increaseCredit fail: buyerUserId = {}, credit = {}" + e.getMessage(),
buyerUserId, credit, e);
} finally {
redissonLock.unlock();
}
if (notEnoughCredit) {
throw new CoBusinessException(CoReturnFormat.CREDIT_NOT_ENOUGH);
}
}
@Override
public Page<CereBuyerUser> searchUser(BusinessUserSearchParam param) {
PageHelper.startPage(param.getPage(),param.getPageSize());
LambdaQueryWrapper<CereBuyerUser> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CereBuyerUser::getBuyerUserId, param.getSearchKey())
.or()
.eq(CereBuyerUser::getWechatOpenId, param.getSearchKey())
.or()
.like(CereBuyerUser::getName, param.getSearchKey())
.or()
.eq(CereBuyerUser::getPhone, param.getSearchKey());
List<CereBuyerUser> userList = businessBuyerUserDAO.selectList(wrapper);
PageInfo<CereBuyerUser> pageInfo=new PageInfo<>(userList);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
}

38
cereshop-business/src/main/java/com/shop/cereshop/business/service/channel/ChannelService.java

@ -0,0 +1,38 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.channel;
import com.shop.cereshop.business.page.channel.ChannelDTO;
import com.shop.cereshop.business.param.channel.ChannelGetAllParam;
import com.shop.cereshop.business.param.channel.ChannelParam;
import com.shop.cereshop.commons.domain.channel.Channel;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.util.List;
/**
* <p>
* 业务接口
* 渠道表
* </p>
*
* @author
* @date 2022-08-25
*/
public interface ChannelService {
void save(ChannelParam param, CerePlatformUser user) throws CoBusinessException;
void update(ChannelParam param, CerePlatformUser user) throws CoBusinessException;
void delete(ChannelParam param, CerePlatformUser user) throws CoBusinessException;
Page<ChannelDTO> getAll(ChannelGetAllParam param) throws CoBusinessException;
List<Channel> selectByChannelCodeList(List<String> channelCodeList);
}

120
cereshop-business/src/main/java/com/shop/cereshop/business/service/channel/impl/ChannelServiceImpl.java

@ -0,0 +1,120 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.channel.impl;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.business.BusinessBuyerUserDAO;
import com.shop.cereshop.business.dao.channel.ChannelDAO;
import com.shop.cereshop.business.dao.order.CereShopOrderDAO;
import com.shop.cereshop.business.page.channel.ChannelDTO;
import com.shop.cereshop.business.param.channel.ChannelGetAllParam;
import com.shop.cereshop.business.param.channel.ChannelParam;
import com.shop.cereshop.business.service.channel.ChannelService;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.domain.channel.Channel;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 业务实现类
* 渠道表
* </p>
*
* @author
* @date 2022-08-25
*/
@Slf4j
@Service
public class ChannelServiceImpl implements ChannelService {
@Autowired
private ChannelDAO channelDAO;
@Value("${channelRegisterUrl}")
private String channelRegisterUrl;
@Autowired
private BusinessBuyerUserDAO businessBuyerUserDAO;
@Autowired
private CereShopOrderDAO cereShopOrderDAO;
@Override
public void save(ChannelParam param, CerePlatformUser user) throws CoBusinessException {
Channel channel = new Channel();
String now = TimeUtils.yyMMddHHmmss();
channel.setChannelName(param.getChannelName());
int count = 0;
while (true) {
if (count > 100) {
throw new CoBusinessException(CoReturnFormat.SYS_ERROR);
}
String channelCode = IdUtil.simpleUUID().substring(0,6);
int existsCount = channelDAO.selectCount(Wrappers.<Channel>lambdaQuery().eq(Channel::getChannelCode, channelCode));
if (existsCount == 0) {
channel.setChannelCode(channelCode);
break;
}
count++;
}
channel.setRegisterUrl(channelRegisterUrl + channel.getChannelCode());
channel.setCreateTime(now);
channel.setUpdateTime(now);
channelDAO.insert(channel);
}
@Override
public void update(ChannelParam param, CerePlatformUser user) throws CoBusinessException {
Channel channel = new Channel();
channel.setId(param.getId());
channel.setChannelName(param.getChannelName());
channelDAO.updateById(channel);
}
@Override
public void delete(ChannelParam param, CerePlatformUser user) throws CoBusinessException {
channelDAO.deleteById(param.getId());
}
@Override
public Page<ChannelDTO> getAll(ChannelGetAllParam param) throws CoBusinessException {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<Channel> list=channelDAO.selectList(Wrappers.emptyWrapper());
List<ChannelDTO> channelDTOList = new ArrayList<>();
for (Channel channel:list) {
ChannelDTO channelDTO = new ChannelDTO();
BeanUtils.copyProperties(channel, channelDTO);
channelDTO.setRegisterCount(businessBuyerUserDAO.selectCount(Wrappers.<CereBuyerUser>lambdaQuery().eq(CereBuyerUser::getChannelCode, channel.getChannelCode())));
channelDTO.setOrderUserCount(cereShopOrderDAO.selectChannelOrderUserCount(channel.getChannelCode()));
channelDTO.setOrderCount(cereShopOrderDAO.selectChannelOrderCount(channel.getChannelCode()));
channelDTO.setOrderAmount(cereShopOrderDAO.selectChannelOrderAmount(channel.getChannelCode()));
channelDTOList.add(channelDTO);
}
PageInfo<ChannelDTO> pageInfo=new PageInfo<>(channelDTOList);
return new Page<>(pageInfo.getList(),pageInfo.getTotal());
}
@Override
public List<Channel> selectByChannelCodeList(List<String> channelCodeList) {
return channelDAO.selectList(Wrappers.<Channel>lambdaQuery().in(Channel::getChannelCode, channelCodeList));
}
}

24
cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/CereCreditRecordService.java

@ -0,0 +1,24 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.credit;
import com.shop.cereshop.business.param.credit.CreditRecordGetAllParam;
import com.shop.cereshop.commons.domain.common.Page;
/**
* <p>
* 业务接口
* 积分流水表
* </p>
*
* @author JustArgo
* @date 2021-12-04
*/
public interface CereCreditRecordService {
Page getAll(CreditRecordGetAllParam param);
}

31
cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/CereCreditSignSettingService.java

@ -0,0 +1,31 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.credit;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.credit.CereCreditSignSetting;
import com.shop.cereshop.commons.exception.CoBusinessException;
/**
* <p>
* 业务接口
* 积分签到配置
* </p>
*
* @author JustArgo
* @date 2021-12-04
*/
public interface CereCreditSignSettingService {
Page getAll(PageParam param);
int save(CereCreditSignSetting param) throws CoBusinessException;
int update(CereCreditSignSetting param) throws CoBusinessException;
int delete(Long id);
}

53
cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/impl/CereCreditRecordServiceImpl.java

@ -0,0 +1,53 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.credit.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.credit.CereCreditRecordDAO;
import com.shop.cereshop.business.page.credit.CereCreditRecordPage;
import com.shop.cereshop.business.param.credit.CreditRecordGetAllParam;
import com.shop.cereshop.business.service.credit.CereCreditRecordService;
import com.shop.cereshop.business.utils.EncodeUtil;
import com.shop.cereshop.commons.domain.common.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 业务实现类
* 积分流水表
* </p>
*
* @author JustArgo
* @date 2021-12-04
*/
@Slf4j
@Service
public class CereCreditRecordServiceImpl implements CereCreditRecordService {
@Autowired
private CereCreditRecordDAO cereCreditRecordDAO;
@Autowired
private EncodeUtil encodeUtil;
@Override
public Page getAll(CreditRecordGetAllParam param) {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<CereCreditRecordPage> list=cereCreditRecordDAO.getAll(param);
for (CereCreditRecordPage record:list) {
record.setName(encodeUtil.encodeInfo(record.getName()));
record.setPhone(encodeUtil.encodePhone(record.getPhone()));
}
PageInfo<CereCreditRecordPage> pageInfo=new PageInfo<>(list);
Page<CereCreditRecordPage> page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
}

70
cereshop-business/src/main/java/com/shop/cereshop/business/service/credit/impl/CereCreditSignSettingServiceImpl.java

@ -0,0 +1,70 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.service.credit.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.credit.CereCreditSignSettingDAO;
import com.shop.cereshop.business.service.credit.CereCreditSignSettingService;
import com.shop.cereshop.commons.constant.CoReturnFormat;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.common.PageParam;
import com.shop.cereshop.commons.domain.credit.CereCreditSignSetting;
import com.shop.cereshop.commons.exception.CoBusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 业务实现类
* 积分签到配置
* </p>
*
* @author JustArgo
* @date 2021-12-04
*/
@Slf4j
@Service
public class CereCreditSignSettingServiceImpl implements CereCreditSignSettingService {
@Autowired
private CereCreditSignSettingDAO cereCreditSignSettingDAO;
@Override
public Page getAll(PageParam param) {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<CereCreditSignSetting> list=cereCreditSignSettingDAO.getAll(param);
PageInfo<CereCreditSignSetting> pageInfo=new PageInfo<>(list);
Page<CereCreditSignSetting> page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
@Override
public int save(CereCreditSignSetting param) throws CoBusinessException {
int count = cereCreditSignSettingDAO.selectExistsDay(param.getDay(), param.getId());
if (count > 0) {
throw new CoBusinessException(CoReturnFormat.CREDIT_SETTING_EXISTS);
}
return cereCreditSignSettingDAO.insert(param);
}
@Override
public int update(CereCreditSignSetting param) throws CoBusinessException {
int count = cereCreditSignSettingDAO.selectExistsDay(param.getDay(), param.getId());
if (count > 0) {
throw new CoBusinessException(CoReturnFormat.CREDIT_SETTING_EXISTS);
}
return cereCreditSignSettingDAO.updateById(param);
}
@Override
public int delete(Long id) {
return cereCreditSignSettingDAO.deleteById(id);
}
}

15
cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CereBuyerLabelService.java

@ -5,5 +5,20 @@
*/
package com.shop.cereshop.business.service.label;
import com.shop.cereshop.business.param.buyer.BusinessBuyerSaveUserLabelParam;
import com.shop.cereshop.commons.domain.label.CereBuyerLabel;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.util.List;
public interface CereBuyerLabelService {
void insert(CereBuyerLabel cereBuyerLabel) throws CoBusinessException;
void deleteLabelUser(List<Long> ids) throws CoBusinessException;
void insertBatch(List<CereBuyerLabel> collect);
List<Long> findAlreadyByUser(BusinessBuyerSaveUserLabelParam param);
List<Long> findByBuyerUserId(Long buyerUserId);
}

36
cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CereBuyerLabelServiceImpl.java

@ -5,9 +5,45 @@
*/
package com.shop.cereshop.business.service.label.impl;
import com.shop.cereshop.business.dao.label.CereBuyerLabelDAO;
import com.shop.cereshop.business.param.buyer.BusinessBuyerSaveUserLabelParam;
import com.shop.cereshop.business.service.label.CereBuyerLabelService;
import com.shop.cereshop.commons.domain.label.CereBuyerLabel;
import com.shop.cereshop.commons.exception.CoBusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CereBuyerLabelServiceImpl implements CereBuyerLabelService {
@Autowired
private CereBuyerLabelDAO cereBuyerLabelDAO;
@Override
public void insert(CereBuyerLabel cereBuyerLabel) throws CoBusinessException {
cereBuyerLabelDAO.insert(cereBuyerLabel);
}
@Override
public void deleteLabelUser(List<Long> ids) throws CoBusinessException {
cereBuyerLabelDAO.deleteLabelUser(ids);
}
@Override
public void insertBatch(List<CereBuyerLabel> collect) {
cereBuyerLabelDAO.insertBatch(collect);
}
@Override
public List<Long> findAlreadyByUser(BusinessBuyerSaveUserLabelParam param) {
return cereBuyerLabelDAO.findAlreadyByUser(param);
}
@Override
public List<Long> findByBuyerUserId(Long buyerUserId) {
return cereBuyerLabelDAO.findByBuyerUserId(buyerUserId);
}
}

3
cereshop-business/src/main/resources/application-business-dev.yml

@ -198,6 +198,9 @@ refreshSkuRealInfoUrl: ${spring.domain}/product/refreshSkuRealInfo
#渠道券活动url
channelCouponActivityUrl: ${spring.domain}/h5/#/pages_category_page2/channelCouponSeaMee/index?
#渠道注册链接
channelRegisterUrl: ${spring.domain}/h5/#/pages_category_page2/userModule/register?
xspay:
url: https://uwebgatetest.hnapay.com/webgate/unifiedAPI.htm
mer_code: 10000000381

3
cereshop-business/src/main/resources/application-business-prod.yml

@ -197,3 +197,6 @@ refreshSkuRealInfoUrl: ${spring.domain}/product/refreshSkuRealInfo
#渠道券活动url
channelCouponActivityUrl: ${spring.domain}/h5/#/pages_category_page2/channelCouponSeaMee/index?
#渠道注册链接
channelRegisterUrl: ${spring.domain}/h5/#/pages_category_page2/userModule/register?

3
cereshop-business/src/main/resources/application-business-test.yml

@ -197,3 +197,6 @@ refreshSkuRealInfoUrl: ${spring.domain}/product/refreshSkuRealInfo
#渠道券活动url
channelCouponActivityUrl: ${spring.domain}/h5/#/pages_category_page2/channelCouponSeaMee/index?
#渠道注册链接
channelRegisterUrl: ${spring.domain}/h5/#/pages_category_page2/userModule/register?

347
cereshop-business/src/main/resources/mybatis/mapper/business/BusinessBuyerUserDAO.xml

@ -0,0 +1,347 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.shop.cereshop.business.dao.business.BusinessBuyerUserDAO">
<resultMap id="BaseResultMap" type="com.shop.cereshop.commons.domain.buyer.CereBuyerUser">
<id column="buyer_user_id" jdbcType="BIGINT" property="buyerUserId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="sex" jdbcType="VARCHAR" property="sex" />
<result column="birthday" jdbcType="VARCHAR" property="birthday" />
<result column="wechat_open_id" jdbcType="VARCHAR" property="wechatOpenId" />
<result column="wechat_union_id" jdbcType="VARCHAR" property="wechatUnionId" />
<result column="wechat_name" jdbcType="VARCHAR" property="wechatName" />
<result column="wechat_number" jdbcType="VARCHAR" property="wechatNumber" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="head_image" jdbcType="VARCHAR" property="headImage" />
<result column="state" jdbcType="BIT" property="state" />
<result column="if_black" jdbcType="BIT" property="ifBlack" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="token" jdbcType="VARCHAR" property="token" />
<result column="create_time" jdbcType="VARCHAR" property="createTime" />
<result column="update_time" jdbcType="VARCHAR" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
buyer_user_id, `name`, sex, birthday, wechat_open_id, wechat_union_id, wechat_name,
wechat_number, phone, `password`, head_image, `state`,if_black, remark, token, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from cere_buyer_user
where buyer_user_id = #{buyerUserId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from cere_buyer_user
where buyer_user_id = #{buyerUserId,jdbcType=BIGINT}
</delete>
<insert id="insertSelective" keyColumn="buyer_user_id" keyProperty="buyerUserId" parameterType="com.shop.cereshop.commons.domain.buyer.CereBuyerUser" useGeneratedKeys="true">
insert into cere_buyer_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name!=''">
`name`,
</if>
<if test="sex != null and sex!=''">
sex,
</if>
<if test="birthday != null and birthday!=''">
birthday,
</if>
<if test="wechatOpenId != null and wechatOpenId!=''">
wechat_open_id,
</if>
<if test="wechatUnionId != null and wechatUnionId!=''">
wechat_union_id,
</if>
<if test="wechatName != null and wechatName!=''">
wechat_name,
</if>
<if test="wechatNumber != null and wechatNumber!=''">
wechat_number,
</if>
<if test="phone != null and phone!=''">
phone,
</if>
<if test="password != null and password!=''">
`password`,
</if>
<if test="headImage != null and headImage!=''">
head_image,
</if>
<if test="state != null">
`state`,
</if>
<if test="ifBlack != null">
if_black,
</if>
<if test="remark != null and remark!=''">
remark,
</if>
<if test="token != null and token!=''">
token,
</if>
<if test="createTime != null and createTime!=''">
create_time,
</if>
<if test="updateTime != null and updateTime!=''">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name!=''">
#{name,jdbcType=VARCHAR},
</if>
<if test="sex != null and sex!=''">
#{sex,jdbcType=VARCHAR},
</if>
<if test="birthday != null and birthday!=''">
#{birthday,jdbcType=VARCHAR},
</if>
<if test="wechatOpenId != null and wechatOpenId!=''">
#{wechatOpenId,jdbcType=VARCHAR},
</if>
<if test="wechatUnionId != null and wechatUnionId!=''">
#{wechatUnionId,jdbcType=VARCHAR},
</if>
<if test="wechatName != null and wechatName!=''">
#{wechatName,jdbcType=VARCHAR},
</if>
<if test="wechatNumber != null and wechatNumber!=''">
#{wechatNumber,jdbcType=VARCHAR},
</if>
<if test="phone != null and phone!=''">
#{phone,jdbcType=VARCHAR},
</if>
<if test="password != null and password!=''">
#{password,jdbcType=VARCHAR},
</if>
<if test="headImage != null and headImage!=''">
#{headImage,jdbcType=VARCHAR},
</if>
<if test="state != null">
#{state,jdbcType=BIT},
</if>
<if test="ifBlack != null">
#{ifBlack,jdbcType=BIT},
</if>
<if test="remark != null and remark!=''">
#{remark,jdbcType=VARCHAR},
</if>
<if test="token != null and token!=''">
#{token,jdbcType=VARCHAR},
</if>
<if test="createTime != null and createTime!=''">
#{createTime,jdbcType=VARCHAR},
</if>
<if test="updateTime != null and updateTime!=''">
#{updateTime,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shop.cereshop.commons.domain.buyer.CereBuyerUser">
update cere_buyer_user
<set>
<if test="name != null and name!=''">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="sex != null and sex!=''">
sex = #{sex,jdbcType=VARCHAR},
</if>
<if test="birthday != null and birthday!=''">
birthday = #{birthday,jdbcType=VARCHAR},
</if>
<if test="wechatOpenId != null and wechatOpenId!=''">
wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR},
</if>
<if test="wechatUnionId != null and wechatUnionId!=''">
wechat_union_id = #{wechatUnionId,jdbcType=VARCHAR},
</if>
<if test="wechatName != null and wechatName!=''">
wechat_name = #{wechatName,jdbcType=VARCHAR},
</if>
<if test="wechatNumber != null and wechatNumber!=''">
wechat_number = #{wechatNumber,jdbcType=VARCHAR},
</if>
<if test="phone != null and phone!=''">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="password != null and password!=''">
`password` = #{password,jdbcType=VARCHAR},
</if>
<if test="headImage != null and headImage!=''">
head_image = #{headImage,jdbcType=VARCHAR},
</if>
<if test="state != null">
`state` = #{state,jdbcType=BIT},
</if>
<if test="ifBlack != null">
if_black = #{ifBlack,jdbcType=BIT},
</if>
<if test="remark != null and remark!=''">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="token != null and token!=''">
token = #{token,jdbcType=VARCHAR},
</if>
<if test="createTime != null and createTime!=''">
create_time = #{createTime,jdbcType=VARCHAR},
</if>
<if test="updateTime != null and updateTime!=''">
update_time = #{updateTime,jdbcType=VARCHAR},
</if>
</set>
where buyer_user_id = #{buyerUserId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.shop.cereshop.commons.domain.buyer.CereBuyerUser">
update cere_buyer_user
set `name` = #{name,jdbcType=VARCHAR},
sex = #{sex,jdbcType=VARCHAR},
birthday = #{birthday,jdbcType=VARCHAR},
wechat_open_id = #{wechatOpenId,jdbcType=VARCHAR},
wechat_union_id = #{wechatUnionId,jdbcType=VARCHAR},
wechat_name = #{wechatName,jdbcType=VARCHAR},
wechat_number = #{wechatNumber,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
`password` = #{password,jdbcType=VARCHAR},
head_image = #{headImage,jdbcType=VARCHAR},
`state` = #{state,jdbcType=BIT},
if_black = #{ifBlack,jdbcType=BIT},
remark = #{remark,jdbcType=VARCHAR},
token = #{token,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=VARCHAR}
where buyer_user_id = #{buyerUserId,jdbcType=BIGINT}
</update>
<update id="increaseCredit">
update cere_buyer_user
set credit = credit + #{credit}
where buyer_user_id = #{buyerUserId}
</update>
<select id="getAll" parameterType="com.shop.cereshop.business.param.buyer.BusinessBuyerGetAllParam" resultType="com.shop.cereshop.business.page.buyer.BusinessBuyerUser">
SELECT a.buyer_user_id,IF(a.wechat_name IS NULL,a.`name`,a.wechat_name) `name`,d.member_level_name,
a.phone,a.credit,IF(b.total IS NULL,0,b.total) total,IF(b.buyers IS NULL,0,b.buyers) buyers,
a.create_time, a.if_black, b.time, a.register_ip, a.last_login_ip,
a.terminal, a.channel_code
from cere_buyer_user a
LEFT JOIN (SELECT buyer_user_id,SUM(price) total,COUNT(order_id) buyers,MAX(create_time) time from cere_shop_order where state in (2,3,4)
GROUP BY buyer_user_id) b ON a.buyer_user_id=b.buyer_user_id
LEFT JOIN cere_buyer_label c ON a.buyer_user_id=c.buyer_user_id
LEFT JOIN cere_platform_member_level d ON a.member_level_id=d.member_level_id
where 1=1
<if test="name!=null and name!=''">
and (a.wechat_name like concat('%',#{name},'%') or
a.`name` like concat('%',#{name},'%'))
</if>
<if test="phone!=null and phone!=''">
and a.phone like concat('%',#{phone},'%')
</if>
<if test="project!=null and project!=''">
and a.project = #{project}
</if>
<if test="labelId!=null">
and c.buyer_label_id=#{labelId}
</if>
<if test="minMoney!=null">
and b.total&gt;=#{minMoney}
</if>
<if test="maxMoney!=null">
and b.total&lt;=#{maxMoney}
</if>
<if test="minBuyers!=null">
and b.buyers&gt;=#{minBuyers}
</if>
<if test="maxBuyers!=null">
and b.buyers&lt;=#{maxBuyers}
</if>
GROUP BY a.buyer_user_id
<if test="startTime!=null and startTime!=''">
HAVING b.time&gt;=#{startTime} and b.time&lt;=#{endTime}
</if>
order by a.create_time desc
</select>
<select id="getById" parameterType="java.lang.Object" resultType="com.shop.cereshop.business.page.buyer.BusinessBuyerUserDetail">
SELECT buyer_user_id,IF(wechat_name IS NULL,`name`,wechat_name) `name`,
phone,sex,birthday,create_time,head_image from cere_buyer_user
where buyer_user_id=#{buyerUserId}
</select>
<select id="findLabels" parameterType="java.lang.Object" resultType="java.lang.String">
SELECT b.label_name from cere_buyer_label a
LEFT JOIN cere_platform_label b ON a.buyer_label_id=b.buyer_label_id
where a.buyer_user_id=#{buyerUserId}
</select>
<select id="findOrders" parameterType="java.lang.Object" resultType="java.lang.Integer">
SELECT COUNT(*) from cere_shop_order where buyer_user_id=#{buyerUserId}
</select>
<select id="findPays" parameterType="java.lang.Object" resultType="java.lang.Integer">
SELECT COUNT(*) from cere_shop_order where buyer_user_id=#{buyerUserId} and state in (2,3,4)
</select>
<select id="findProducts" parameterType="java.lang.Object" resultType="java.lang.Integer">
SELECT COUNT(*) from cere_order_product a
LEFT JOIN cere_shop_order b ON a.order_id=b.order_id
where b.buyer_user_id=#{buyerUserId}
</select>
<select id="findPrice" parameterType="java.lang.Object" resultType="java.math.BigDecimal">
SELECT SUM(price) from cere_shop_order where buyer_user_id=#{buyerUserId} and state in (2,3,4)
</select>
<select id="findAfters" parameterType="java.lang.Object" resultType="java.lang.Integer">
SELECT COUNT(*) from cere_order_after a
LEFT JOIN cere_shop_order b ON a.order_id=b.order_id
where b.buyer_user_id=#{buyerUserId}
</select>
<select id="findAfterOrders" parameterType="java.lang.Object" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT a.order_id) from cere_order_after a
LEFT JOIN cere_shop_order b ON a.order_id=b.order_id
where b.buyer_user_id=#{buyerUserId}
</select>
<select id="findSuccessAfters" parameterType="java.lang.Object" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT a.order_id) from cere_order_after a
LEFT JOIN cere_shop_order b ON a.order_id=b.order_id
where b.buyer_user_id=#{buyerUserId} and a.after_state=2
</select>
<select id="findOrderList" parameterType="com.shop.cereshop.business.param.buyer.BusinessBuyerGetByIdParam" resultType="com.shop.cereshop.business.page.buyer.BusinessBuyerOrder">
SELECT a.order_formid,b.shop_name,COUNT(c.product_id) products,a.price,a.state from cere_shop_order a
LEFT JOIN cere_platform_shop b ON a.shop_id=b.shop_id
LEFT JOIN cere_order_product c ON a.order_id=c.order_id
where a.buyer_user_id=#{buyerUserId}
<if test="orderFormid!=null and orderFormid!=''">
and a.order_formid like concat('%',#{orderFormid},'%')
</if>
GROUP BY c.product_id
</select>
<select id="findComments" parameterType="java.lang.Object" resultType="com.shop.cereshop.business.page.buyer.BusinessBuyerComment">
SELECT a.shop_name,a.comment_id,b.product_name from cere_shop_comment a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
where a.buyer_user_id=#{buyerUserId}
</select>
<select id="findReceives" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.buyer.CereBuyerReceive">
SELECT * FROM cere_buyer_receive where buyer_user_id=#{buyerUserId}
</select>
<select id="getLabels" parameterType="com.shop.cereshop.business.param.buyer.BusinessBuyerGetLabelsParam" resultType="com.shop.cereshop.commons.domain.label.CerePlatformLabel">
SELECT buyer_label_id,label_name FROM cere_platform_label
where 1=1
<if test="labelName!=null and labelName!=''">
and label_name like concat('%',#{labelName},'%')
</if>
</select>
<select id="getUserLabels" parameterType="com.shop.cereshop.business.param.buyer.BusinessBuyerGetLabelsParam" resultType="com.shop.cereshop.commons.domain.label.CerePlatformLabel">
SELECT b.* FROM cere_buyer_label a
LEFT JOIN cere_platform_label b ON a.buyer_label_id=b.buyer_label_id
where a.buyer_user_id=#{buyerUserId}
</select>
</mapper>

18
cereshop-business/src/main/resources/mybatis/mapper/buyer/CereBuyerUserDAO.xml

@ -302,4 +302,22 @@
join cere_pay_log b on a.order_formid = b.order_formid and b.state = '支付'
group by a.shop_id, a.buyer_user_id
</select>
<select id="selectChannelOrderUserCount" resultType="java.lang.Integer">
select count(distinct a.buyer_user_id) from cere_shop_order a
join cere_buyer_user b on b.buyer_user_id = a.buyer_user_id
where b.channel_code = #{channelCode} and a.payment_state = 1
</select>
<select id="selectChannelOrderCount" resultType="java.lang.Integer">
select count(distinct a.order_id) from cere_shop_order a
join cere_buyer_user b on b.buyer_user_id = a.buyer_user_id
where b.channel_code = #{channelCode} and a.payment_state = 1
</select>
<select id="selectChannelOrderAmount" resultType="java.math.BigDecimal">
select ifnull(sum(price), 0) from cere_shop_order a
join cere_buyer_user b on b.buyer_user_id = a.buyer_user_id
where b.channel_code = #{channelCode} and a.payment_state = 1
</select>
</mapper>

31
cereshop-business/src/main/resources/mybatis/mapper/label/CereBuyerLabelDAO.xml

@ -24,4 +24,35 @@
</if>
</trim>
</insert>
<delete id="deleteLabelUser" parameterType="java.util.List">
DELETE FROM cere_buyer_label where buyer_label_id in (
<foreach collection="ids" item="id" index="index" separator=",">
#{id}
</foreach>
)
</delete>
<insert id="insertBatch" parameterType="java.util.List">
insert into cere_buyer_label (buyer_user_id, buyer_label_id) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.buyerUserId},
#{item.buyerLabelId}
)
</foreach>
</insert>
<select id="findAlreadyByUser" parameterType="com.shop.cereshop.business.param.buyer.BusinessBuyerSaveUserLabelParam" resultType="java.lang.Long">
SELECT buyer_label_id FROM cere_buyer_label where buyer_user_id=#{buyerUserId}
and buyer_label_id in (
<foreach collection="buyerLabelIds" item="id" index="index" separator=",">
#{id}
</foreach>
)
</select>
<select id="findByBuyerUserId" resultType="java.lang.Long">
SELECT buyer_label_id FROM cere_buyer_label where buyer_user_id = #{buyerUserId}
</select>
</mapper>
Loading…
Cancel
Save