| @@ -0,0 +1,78 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.domain.dto.WxCreditHistoryDto; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.util.Assert; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import org.slf4j.Logger; | |||||
| import com.iformall.domain.po.WxCreditHistory; | |||||
| import com.iformall.service.WxCreditHistoryService; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.stream.Collectors; | |||||
| @RestController | |||||
| @RequestMapping("wxCreditHistory") | |||||
| public class WxCreditHistoryController extends BaseController | |||||
| { | |||||
| @Autowired | |||||
| private WxCreditHistoryService wxCreditHistoryService; | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @ApiOperation("分页列表接口") | |||||
| @GetMapping("list") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||||
| public ResultData list(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) { | |||||
| if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory(); | |||||
| final PageInfo<WxCreditHistoryVo> page = wxCreditHistoryService.listAsPageMore(wxCreditHistory, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("add") | |||||
| public ResultData add(@RequestBody WxCreditHistory wxCreditHistory) { | |||||
| //Assert.notNull(wxCreditHistory.getName(), "角色名不能为空"); | |||||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新接口") | |||||
| @PostMapping("update") | |||||
| public ResultData update(@RequestBody WxCreditHistory wxCreditHistory) { | |||||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData delete(Long id) { | |||||
| wxCreditHistoryService.deleteById(id); | |||||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||||
| public ResultData findById(Long id) { | |||||
| return new ResultData(Result.SUCCESS,"查询成功",wxCreditHistoryService.getById(id)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,18 @@ | |||||
| DROP TABLE IF EXISTS `wx_credit_history`; | |||||
| CREATE TABLE `wx_credit_history` ( | |||||
| `id` bigint(64) NOT NULL COMMENT '主键ID', | |||||
| `tenant_id` varchar(50) NOT NULL COMMENT '租户ID', | |||||
| `c_user_id` bigint(64) NOT NULL COMMENT '用户ID', | |||||
| `credit_amount` int(11) NOT NULL COMMENT '总积分', | |||||
| `credit_num` int(11) NOT NULL COMMENT '每笔积分明细', | |||||
| `credit_type` tinyint(2) NOT NULL COMMENT '积分类型(操作说明)', | |||||
| `create_date` datetime(0) NOT NULL COMMENT '创建日期', | |||||
| `receipt_url` varchar(256) NULL DEFAULT NULL COMMENT '小票URL', | |||||
| `operator_type` tinyint(2) NOT NULL COMMENT '操作人类型', | |||||
| `operator_id` bigint(64) NOT NULL COMMENT '操作人ID', | |||||
| `merchant_id` bigint(11) NULL DEFAULT NULL COMMENT '商户ID', | |||||
| `coupon_id` bigint(64) NULL DEFAULT NULL COMMENT '券ID(积分兑换券时生成)', | |||||
| `business_id` bigint(64) NULL DEFAULT NULL COMMENT '业态ID(计算新增积分时使用)', | |||||
| `spend` int(11) NULL DEFAULT NULL COMMENT '花费', | |||||
| PRIMARY KEY (`id`) USING BTREE | |||||
| ) ENGINE = InnoDB ROW_FORMAT = Dynamic COMMENT='积分记录'; | |||||
| @@ -0,0 +1,4 @@ | |||||
| package com.iformall.domain.dto; | |||||
| public class WxCreditHistoryDto { | |||||
| } | |||||
| @@ -21,7 +21,7 @@ public class MallUserInfo implements Serializable { | |||||
| protected Long id; | protected Long id; | ||||
| @Transient | @Transient | ||||
| protected List<String> ids; | |||||
| protected List<Long> ids; | |||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| @@ -37,13 +37,6 @@ public class MallUserInfo implements Serializable { | |||||
| return sortColumns; | return sortColumns; | ||||
| } | } | ||||
| public List<String> getIds() { | |||||
| return ids; | |||||
| } | |||||
| public void setIds(List<String> ids) { | |||||
| this.ids = ids; | |||||
| } | |||||
| /**租户ID**/ | /**租户ID**/ | ||||
| @@ -0,0 +1,150 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import javax.persistence.*; | |||||
| import java.util.*; | |||||
| import java.math.*; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.List; | |||||
| import javax.persistence.Id; | |||||
| import java.io.Serializable; | |||||
| @Table(name = "wx_credit_history") | |||||
| @Data | |||||
| public class WxCreditHistory implements Serializable { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected String sortColumns; | |||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="startTime") | |||||
| private Date startTime; | |||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="endTime") | |||||
| private Date endTime; | |||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") | |||||
| private String phone; | |||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="姓名",name="name") | |||||
| private String name; | |||||
| /**租户ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||||
| private String tenantId; | |||||
| /**用户ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户ID",name="cUserId") | |||||
| private Long cUserId; | |||||
| /**总积分*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="总积分",name="creditAmount") | |||||
| private Integer creditAmount; | |||||
| /**每笔积分明细*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="每笔积分明细",name="creditNum") | |||||
| private Integer creditNum; | |||||
| /**积分类型*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分类型",name="creditType") | |||||
| private Integer creditType; | |||||
| /**创建日期*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") | |||||
| private Date createDate; | |||||
| /**小票URL*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小票URL",name="receiptUrl") | |||||
| private String receiptUrl; | |||||
| /**操作人类型*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="操作人类型",name="operatorType") | |||||
| private Integer operatorType; | |||||
| /**操作人ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") | |||||
| private Long operatorId; | |||||
| /**商户ID*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") | |||||
| private Long merchantId; | |||||
| /**券ID(积分兑换券时生成)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="券ID(积分兑换券时生成)",name="couponId") | |||||
| private Long couponId; | |||||
| /**业态ID(计算新增积分时使用)*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="业态ID(计算新增积分时使用)",name="businessId") | |||||
| private Long businessId; | |||||
| /**花费*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="花费",name="spend") | |||||
| private Integer spend; | |||||
| public static enum Field | |||||
| { | |||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||||
| ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") | |||||
| ,CUserId_ASC("`c_user_id` ASC"),CUserId_DESC("`c_user_id` DESC") | |||||
| ,CreditAmount_ASC("`credit_amount` ASC"),CreditAmount_DESC("`credit_amount` DESC") | |||||
| ,CreditNum_ASC("`credit_num` ASC"),CreditNum_DESC("`credit_num` DESC") | |||||
| ,CreditType_ASC("`credit_type` ASC"),CreditType_DESC("`credit_type` DESC") | |||||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||||
| ,ReceiptUrl_ASC("`receipt_url` ASC"),ReceiptUrl_DESC("`receipt_url` DESC") | |||||
| ,OperatorType_ASC("`operator_type` ASC"),OperatorType_DESC("`operator_type` DESC") | |||||
| ,OperatorId_ASC("`operator_id` ASC"),OperatorId_DESC("`operator_id` DESC") | |||||
| ,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC") | |||||
| ,CouponId_ASC("`coupon_id` ASC"),CouponId_DESC("`coupon_id` DESC") | |||||
| ,BusinessId_ASC("`business_id` ASC"),BusinessId_DESC("`business_id` DESC") | |||||
| ,Spend_ASC("`spend` ASC"),Spend_DESC("`spend` DESC") | |||||
| ; | |||||
| private String value; | |||||
| Field(String value){ | |||||
| this.value = value; | |||||
| } | |||||
| public String getValue() { | |||||
| return value; | |||||
| } | |||||
| public void setCol(String value) { | |||||
| this.value = value; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return this.getValue(); | |||||
| } | |||||
| } | |||||
| public void setSortColumns(Field... fields) | |||||
| { | |||||
| if (fields == null || fields.length == 0) { | |||||
| return; | |||||
| } | |||||
| for (int k = 0; k < fields.length; k++) { | |||||
| if (fields[k] == null) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||||
| for (int k = 1; k < fields.length; k++) { | |||||
| sb.append(","); | |||||
| sb.append(fields[k].toString()); | |||||
| } | |||||
| this.sortColumns = sb.toString(); | |||||
| } | |||||
| public void setSortColumns(String sortColumns) | |||||
| { | |||||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||||
| return; | |||||
| } | |||||
| if (sortColumns.contains(",")) { | |||||
| String[] cols = sortColumns.split(","); | |||||
| List<Field> fList = new ArrayList(); | |||||
| for (int k = 0; k < cols.length; k++) { | |||||
| fList.add(Field.valueOf(cols[k])); | |||||
| } | |||||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||||
| } else { | |||||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,55 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @Data | |||||
| public class WxCreditHistoryVo { | |||||
| @io.swagger.annotations.ApiModelProperty(value="手机号",name="phone") | |||||
| private String phone; | |||||
| @io.swagger.annotations.ApiModelProperty(value="姓名",name="name") | |||||
| private String name; | |||||
| @io.swagger.annotations.ApiModelProperty(value="性别",name="sex") | |||||
| private String sex; | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分ID",name="creditId") | |||||
| private String creditId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户ID",name="cUserId") | |||||
| private Long cUserId; | |||||
| /**总积分*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="总积分",name="creditAmount") | |||||
| private Integer creditAmount; | |||||
| /**每笔积分明细*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="每笔积分明细",name="creditNum") | |||||
| private Integer creditNum; | |||||
| /**积分类型*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="积分类型",name="creditType") | |||||
| private Integer creditType; | |||||
| /**创建日期*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建日期",name="createDate") | |||||
| private Date createDate; | |||||
| /**小票URL*/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="小票URL",name="receiptUrl") | |||||
| private String receiptUrl; | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户",name="merchantName") | |||||
| private String merchantName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="操作人类型",name="operator") | |||||
| private String operatorType; | |||||
| @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") | |||||
| private Long operatorId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="操作人",name="operator") | |||||
| private String operator; | |||||
| } | |||||
| @@ -0,0 +1,35 @@ | |||||
| package com.iformall.enums; | |||||
| public enum EnumUserType { | |||||
| CUSER(1, "C端用户"), | |||||
| CUSERBASIC(2, "C端用户(偏向A端)"), | |||||
| BUSER(3, "B端用户"), | |||||
| MALLUSER(4, "A端用户") | |||||
| ; | |||||
| public static EnumUserType getEnum(Integer code) { | |||||
| for (EnumUserType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumUserType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| package com.iformall.mapper; | |||||
| import java.util.*; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||||
| import com.iformall.domain.po.WxCreditHistory; | |||||
| public interface WxCreditHistoryMapper extends CommonMapper<WxCreditHistory, Long> { | |||||
| List<WxCreditHistory> findList(WxCreditHistory wxCreditHistory); | |||||
| List<WxCreditHistoryVo> findListMore(WxCreditHistory wxCreditHistory); | |||||
| } | |||||
| @@ -0,0 +1,60 @@ | |||||
| package com.iformall.service; | |||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.dto.WxCreditHistoryDto; | |||||
| import com.iformall.domain.po.WxCreditHistory; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||||
| public interface WxCreditHistoryService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxCreditHistory> listAsPage(WxCreditHistory record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据实体查询分页列表更多 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxCreditHistoryVo> listAsPageMore(WxCreditHistory record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| WxCreditHistory getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| void saveOrUpdate(WxCreditHistory record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -0,0 +1,139 @@ | |||||
| package com.iformall.service.impl; | |||||
| import java.util.*; | |||||
| import java.util.stream.Collectors; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.google.common.collect.Lists; | |||||
| import com.iformall.domain.dto.WxCreditHistoryDto; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||||
| import com.iformall.enums.EnumUserType; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.WxCreditHistoryService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import com.iformall.common.IdWorker; | |||||
| @Service | |||||
| public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| @Autowired | |||||
| WxCreditHistoryMapper wxCreditHistoryMapper; | |||||
| @Autowired | |||||
| WxCUserMapper wxCUserMapper; | |||||
| @Autowired | |||||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||||
| @Autowired | |||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||||
| @Autowired | |||||
| MallUserInfoMapper mallUserInfoMapper; | |||||
| @Override | |||||
| public PageInfo<WxCreditHistory> listAsPage(WxCreditHistory record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCreditHistoryMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public PageInfo<WxCreditHistoryVo> listAsPageMore(WxCreditHistory record, Integer pageIndex, Integer pageSize) { | |||||
| PageHelper.startPage(pageIndex, pageSize); | |||||
| List<WxCreditHistoryVo> wxCreditHistoryVoList = wxCreditHistoryMapper.findListMore(record); | |||||
| if (wxCreditHistoryVoList == null || wxCreditHistoryVoList.size() == 0) { | |||||
| return new PageInfo<>(wxCreditHistoryVoList); | |||||
| } | |||||
| List<Long> cUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.CUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | |||||
| List<Long> cUserBasicIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.CUSERBASIC.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | |||||
| List<Long> bUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.BUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | |||||
| List<Long> mallUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.MALLUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | |||||
| List<WxCUser> wxCUserList = Lists.newArrayList(); | |||||
| List<WxCUserBasicInfo> wxCUserBasicInfoList = Lists.newArrayList(); | |||||
| List<WxMerchantBUser> wxMerchantBUserList = Lists.newArrayList(); | |||||
| List<MallUserInfo> mallUserInfoList = Lists.newArrayList(); | |||||
| if (cUserIds != null && cUserIds.size() > 0) { | |||||
| WxCUser wxUser = new WxCUser(); | |||||
| wxUser.setIds(cUserIds); | |||||
| wxCUserList = wxCUserMapper.findList(wxUser); | |||||
| } | |||||
| if (cUserBasicIds != null && cUserBasicIds.size() > 0) { | |||||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | |||||
| wxCUserBasicInfo.setIds(cUserBasicIds); | |||||
| wxCUserBasicInfoList = wxCUserBasicInfoMapper.findList(wxCUserBasicInfo); | |||||
| } | |||||
| if (bUserIds != null && bUserIds.size() > 0) { | |||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.setIds(bUserIds); | |||||
| wxMerchantBUserList = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||||
| } | |||||
| if (mallUserIds != null && mallUserIds.size() > 0) { | |||||
| MallUserInfo mallUserInfo = new MallUserInfo(); | |||||
| mallUserInfo.setIds(mallUserIds); | |||||
| mallUserInfoList = mallUserInfoMapper.findList(mallUserInfo); | |||||
| } | |||||
| for (WxCreditHistoryVo credit : wxCreditHistoryVoList) { | |||||
| if (wxCUserList != null && wxCUserList.size() > 0) { | |||||
| wxCUserList.stream().forEach(cUser->{ | |||||
| if (cUser.getId().longValue() == credit.getOperatorId().longValue()) { | |||||
| credit.setOperator(cUser.getNickName()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| if (wxCUserBasicInfoList != null && wxCUserBasicInfoList.size() > 0) { | |||||
| wxCUserBasicInfoList.stream().forEach(cUserBasicInfo->{ | |||||
| if (cUserBasicInfo.getId().longValue() == credit.getOperatorId().longValue()) { | |||||
| credit.setOperator(cUserBasicInfo.getNickName()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| if (wxMerchantBUserList != null && wxMerchantBUserList.size() > 0) { | |||||
| wxMerchantBUserList.stream().forEach(bUser->{ | |||||
| if (bUser.getId().longValue() == credit.getOperatorId().longValue()) { | |||||
| credit.setOperator(bUser.getName()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| if (mallUserInfoList != null && mallUserInfoList.size() > 0) { | |||||
| mallUserInfoList.stream().forEach(mallUser->{ | |||||
| if (mallUser.getId().longValue() == credit.getOperatorId().longValue()) { | |||||
| credit.setOperator(mallUser.getName()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | |||||
| return new PageInfo<>(wxCreditHistoryVoList); | |||||
| } | |||||
| @Override | |||||
| public WxCreditHistory getById(Long id) { | |||||
| return wxCreditHistoryMapper.selectByPrimaryKey(id); | |||||
| } | |||||
| @Override | |||||
| public void saveOrUpdate(WxCreditHistory record) { | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| wxCreditHistoryMapper.insertSelective(record); | |||||
| } else { | |||||
| wxCreditHistoryMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| wxCreditHistoryMapper.deleteByPrimaryKey(id); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,122 @@ | |||||
| <?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.iformall.mapper.WxCreditHistoryMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCreditHistory"> | |||||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||||
| <result column="credit_amount" jdbcType="INTEGER" property="creditAmount" /> | |||||
| <result column="credit_num" jdbcType="INTEGER" property="creditNum" /> | |||||
| <result column="credit_type" jdbcType="INTEGER" property="creditType" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="credateDate" /> | |||||
| <result column="receipt_url" jdbcType="VARCHAR" property="receiptUrl" /> | |||||
| <result column="operator_type" jdbcType="INTEGER" property="operatorType" /> | |||||
| <result column="operator_id" jdbcType="BIGINT" property="operatorId" /> | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||||
| <result column="business_id" jdbcType="BIGINT" property="businessId" /> | |||||
| <result column="spend" jdbcType="INTEGER" property="spend" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`c_user_id`,`credit_amount`,`credit_num`,`credit_type`,`credate_date`,`receipt_url`,`operator_type`,`operator_id`,`merchant_id`,`coupon_id`,`business_id`,`spend` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != cUserId "> | |||||
| and `c_user_id` = #{cUserId} | |||||
| </if> | |||||
| <if test=" null != creditAmount "> | |||||
| and `credit_amount` = #{creditAmount} | |||||
| </if> | |||||
| <if test=" null != creditNum "> | |||||
| and `credit_num` = #{creditNum} | |||||
| </if> | |||||
| <if test=" null != creditType "> | |||||
| and `credit_type` = #{creditType} | |||||
| </if> | |||||
| <if test=" null != receiptUrl "> | |||||
| and `receipt_url` like concat('%', #{receiptUrl},'%') | |||||
| </if> | |||||
| <if test=" null != operatorType "> | |||||
| and `operator_type` = #{operatorType} | |||||
| </if> | |||||
| <if test=" null != operatorId "> | |||||
| and `operator_id` = #{operatorId} | |||||
| </if> | |||||
| <if test=" null != merchantId "> | |||||
| and `merchant_id` = #{merchantId} | |||||
| </if> | |||||
| <if test=" null != couponId "> | |||||
| and `coupon_id` = #{couponId} | |||||
| </if> | |||||
| <if test=" null != businessId "> | |||||
| and `business_id` = #{businessId} | |||||
| </if> | |||||
| <if test=" null != spend "> | |||||
| and `spend` = #{spend} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||||
| </sql> | |||||
| <sql id="customWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != name "> | |||||
| and basic.name like concat('%', #{name},'%') | |||||
| </if> | |||||
| <if test=" null != phone "> | |||||
| and basic.phone like concat('%', #{phone},'%') | |||||
| </if> | |||||
| <if test=" null != startTime "> | |||||
| and credit.create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and credit.create_date < #{endTime} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and credit.tenant_id = #{tenantId} | |||||
| </if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCreditHistory" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_credit_history | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| <select id="findListMore" parameterType="com.iformall.domain.po.WxCreditHistory" resultType="com.iformall.domain.vo.WxCreditHistoryVo"> | |||||
| SELECT | |||||
| credit.id creditId, | |||||
| basic.NAME name, | |||||
| basic.phone phone, | |||||
| basic.sex sex, | |||||
| credit.tenant_id tenantId, | |||||
| credit.c_user_id cUserId, | |||||
| credit.credit_amount creditAmount, | |||||
| credit.credit_num creditNum, | |||||
| credit.create_date createDate, | |||||
| credit.credit_type creditType, | |||||
| credit.receipt_url receiptUrl, | |||||
| credit.operator_type operatorType, | |||||
| credit.operator_id operatorId, | |||||
| merchant.NAME merchantName | |||||
| FROM | |||||
| wx_c_user_basic_info basic | |||||
| INNER JOIN wx_credit_history credit ON basic.id = credit.c_user_id | |||||
| LEFT JOIN wx_merchant merchant ON credit.merchant_id = merchant.id | |||||
| <include refid="customWhereConditions"/> | |||||
| ORDER BY | |||||
| credit.id DESC | |||||
| </select> | |||||
| </mapper> | |||||