Merge branch 'ww-分享好友' into test

This commit is contained in:
2024-11-07 18:28:55 +08:00
13 changed files with 800 additions and 12 deletions

View File

@@ -45,6 +45,7 @@ public class LoginFilter implements Filter {
"cashierService/home",//首页
"cashierService/order/testMessage",//首页
"cashierService/common/**",//通用接口
"cashierService/tbShopShare/**",//通用接口
"cashierService/distirict/**",//首页其它接口
// "cashierService/login/**",//登录部分接口不校验

View File

@@ -1,12 +1,11 @@
package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.service.TbShopShareService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -19,12 +18,12 @@ import javax.annotation.Resource;
@RestController
@RequestMapping("tbShopShare")
public class TbShopShareController {
/**
* 服务对象
*/
@Autowired
private TbShopShareService tbShopShareService;
@Autowired
private TbShopShareRecordService tbShopShareRecordService;
/**
* 通过主键查询单条数据
@@ -37,5 +36,40 @@ public class TbShopShareController {
return Result.successWithData(tbShopShareService.queryByShopId(shopId));
}
/**
* 查询
*
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
@GetMapping("record")
public Result queryByPage(TbShopShareRecord tbShopShareRecord) {
return Result.successWithData(tbShopShareRecordService.query(tbShopShareRecord));
}
/**
* 进入页面
*
* @param tbShopShareRecord 实体
* @return 新增结果
*/
@PostMapping("open")
public Result open(@RequestBody TbShopShareRecord tbShopShareRecord) {
return tbShopShareRecordService.insert(tbShopShareRecord);
}
/**
* 领取优惠券
*
* @param tbShopShareRecord 实体
* @return 新增结果
*/
@PostMapping("receive")
public Result receive(@RequestBody TbShopShareRecord tbShopShareRecord) {
return tbShopShareRecordService.receive(tbShopShareRecord);
}
}

View File

@@ -0,0 +1,75 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* (TbShopShareRecord)表数据库访问层
*
* @author ww
* @since 2024-11-07 15:50:03
*/
public interface TbShopShareRecordMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TbShopShareRecord queryById(Integer id);
TbShopShareRecord queryByData(
@Param("shareId") Integer shareId, @Param("shopId") Integer shopId,
@Param("invitedId") Integer invitedId, @Param("beInvitedId") Integer beInvitedId);
TbShopShareRecord queryByDataByBeInvited(
@Param("shareId") Integer shareId, @Param("shopId") Integer shopId,
@Param("beInvitedId") Integer beInvitedId);
/**
* 查询数据
*
* @param tbShopShareRecord 查询条件
* @return 对象列表
*/
List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord);
/**
* 新增数据
*
* @param tbShopShareRecord 实例对象
* @return 影响行数
*/
int insert(TbShopShareRecord tbShopShareRecord);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<TbShopShareRecord> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<TbShopShareRecord> entities);
/**
* 修改数据
*
* @param tbShopShareRecord 实例对象
* @return 影响行数
*/
int update(TbShopShareRecord tbShopShareRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
}

View File

@@ -17,6 +17,8 @@ public interface TbUserInfoMapper {
TbUserInfo selectByPrimaryKey(Integer id);
String selectNameByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbUserInfo record);
int updateByPrimaryKey(TbUserInfo record);

View File

@@ -73,6 +73,7 @@ public class TbActivateInRecord implements Serializable {
private Date updateTime;
private String couponJson;
private String source;
public Integer getId() {
@@ -219,5 +220,13 @@ public class TbActivateInRecord implements Serializable {
this.couponJson = couponJson;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
}

View File

@@ -0,0 +1,156 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import java.io.Serializable;
/**
* (TbShopShareRecord)实体类
*
* @author ww
* @since 2024-11-07 15:50:04
*/
public class TbShopShareRecord implements Serializable {
private static final long serialVersionUID = -41620929736900271L;
private Integer id;
/**
* tb_shop_share 主键Id
*/
private Integer shareId;
/**
* 店铺Id
*/
private Integer shopId;
/**
* 邀请人id
*/
private Integer invitedId;
/**
* 邀请人名称
*/
private String invitedName;
/**
* 被邀请人Id
*/
private Integer beInvitedId;
/**
* 被邀请人名称
*/
private String beInvitedName;
/**
* 奖励券获得方式 get/use 领取获得/使用获得
*/
private String method;
/**
* 1 未领取 2 已领取 3 已使用
*/
private Integer status;
/**
* 生效时间/获得奖励的时间
*/
private Date rewardTime;
private Date createTime;
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShareId() {
return shareId;
}
public void setShareId(Integer shareId) {
this.shareId = shareId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getInvitedId() {
return invitedId;
}
public void setInvitedId(Integer invitedId) {
this.invitedId = invitedId;
}
public String getInvitedName() {
return invitedName;
}
public void setInvitedName(String invitedName) {
this.invitedName = invitedName;
}
public Integer getBeInvitedId() {
return beInvitedId;
}
public void setBeInvitedId(Integer beInvitedId) {
this.beInvitedId = beInvitedId;
}
public String getBeInvitedName() {
return beInvitedName;
}
public void setBeInvitedName(String beInvitedName) {
this.beInvitedName = beInvitedName;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getRewardTime() {
return rewardTime;
}
public void setRewardTime(Date rewardTime) {
this.rewardTime = rewardTime;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@@ -0,0 +1,62 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import java.util.List;
/**
* (TbShopShareRecord)表服务接口
*
* @author ww
* @since 2024-11-07 15:50:04
*/
public interface TbShopShareRecordService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
TbShopShareRecord queryById(Integer id);
/**
* 分页查询
*
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord);
Result receive(TbShopShareRecord tbShopShareRecord);
/**
* 新增数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
Result insert(TbShopShareRecord tbShopShareRecord);
/**
* 修改数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
TbShopShareRecord update(TbShopShareRecord tbShopShareRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Integer id);
void give(TbShopShareRecord shareRecord, Integer userId);
}

View File

@@ -7,10 +7,12 @@ import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.CouponDto;
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
import com.chaozhanggui.system.cashierservice.service.TbShopCouponService;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@@ -43,6 +45,12 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
@Resource
private TbActivateOutRecordMapper outRecordMapper;
@Autowired
private TbShopShareRecordMapper shareRecordMapper;
@Autowired
private TbShopShareRecordService shareRecordService;
@Override
public List<TbUserCouponVo> getActivateCouponByAmount(Integer shopId, String userId, BigDecimal amount) {
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, String.valueOf(shopId));
@@ -174,6 +182,14 @@ public class TbShopCouponServiceImpl implements TbShopCouponService {
public boolean use(Integer shopId, Integer orderId, Integer vipUserId, List<TbActivateOutRecord> param) {
for (TbActivateOutRecord outRecord : param) {
TbActivateInRecord inRecord = inRecordMapper.queryById(outRecord.getGiveId());
if (inRecord.getSource().equals("invited")) {
TbShopShareRecord shareRecord = shareRecordMapper.queryById(inRecord.getSourceActId());
if (shareRecord.getMethod().equals("use")) {
shareRecord.setStatus(3);
shareRecordService.give(shareRecord,shareRecord.getInvitedId());
shareRecordMapper.update(shareRecord);
}
}
inRecord.setOverNum(inRecord.getOverNum() - outRecord.getUseNum());
inRecordMapper.updateOverNum(inRecord.getId(), inRecord.getOverNum());

View File

@@ -0,0 +1,262 @@
package com.chaozhanggui.system.cashierservice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.service.TbShopShareRecordService;
import com.chaozhanggui.system.cashierservice.sign.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* (TbShopShareRecord)表服务实现类
*
* @author ww
* @since 2024-11-07 15:50:04
*/
@Primary
@Service
public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
@Autowired
private TbShopShareMapper tbShopShareMapper;
@Autowired
private TbShopShareRecordMapper tbShopShareRecordMapper;
@Autowired
private TbShopUserMapper shopUserMapper;
@Autowired
private TbCouponProductMapper couProductMapper;
@Autowired
private TbShopCouponMapper couponMapper;
@Autowired
private TbActivateInRecordMapper activateInRecordMapper;
@Autowired
private TbUserInfoMapper userInfoMapper;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public TbShopShareRecord queryById(Integer id) {
return this.tbShopShareRecordMapper.queryById(id);
}
/**
* 分页查询
*
* @param tbShopShareRecord 筛选条件
* @return 查询结果
*/
@Override
public List<TbShopShareRecord> query(TbShopShareRecord tbShopShareRecord) {
List<TbShopShareRecord> records = tbShopShareRecordMapper.query(tbShopShareRecord);
for (TbShopShareRecord shareRecord : records) {
shareRecord.setBeInvitedName(userInfoMapper.selectNameByPrimaryKey(shareRecord.getBeInvitedId()));
}
return records;
}
@Override
public Result receive(TbShopShareRecord tbShopShareRecord) {
// TbShopShareRecord query = tbShopShareRecordMapper.queryByDataByBeInvited(
// tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(), tbShopShareRecord.getBeInvitedId());
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
if (query.getStatus() == 1) {
give(query, query.getBeInvitedId());
if (query.getMethod().equals("get")) {
give(query, query.getInvitedId());
}
query.setRewardTime(new Date());
query.setStatus(2);
query.setUpdateTime(new Date());
tbShopShareRecordMapper.update(query);
return Result.successWithData("领取成功。");
} else {
return Result.fail("不可重复领取。");
}
}
/**
* 新增数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
@Override
public Result insert(TbShopShareRecord tbShopShareRecord) {
TbShopUser shopUserInfo = getShopUserInfo(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
TbShopShareRecord query = tbShopShareRecordMapper.queryByData(
tbShopShareRecord.getShareId(), tbShopShareRecord.getShopId(),
tbShopShareRecord.getInvitedId(), tbShopShareRecord.getBeInvitedId());
if (query == null) {
TbShopShare tbShopShare = tbShopShareMapper.queryById(tbShopShareRecord.getShareId());
tbShopShareRecord.setMethod(tbShopShare.getGetMethod());
tbShopShareRecord.setShopId(tbShopShareRecord.getShopId());
tbShopShareRecord.setCreateTime(new Date());
tbShopShareRecord.setUpdateTime(new Date());
}else {
query.setUpdateTime(new Date());
}
if (shopUserInfo == null) {
if (query != null) {
query.setStatus(1);
tbShopShareRecordMapper.update(query);
} else {
tbShopShareRecord.setStatus(1);
tbShopShareRecordMapper.insert(tbShopShareRecord);
}
saveShopUser(tbShopShareRecord.getBeInvitedId(), tbShopShareRecord.getShopId());
} else {
if (query != null) {
query.setStatus(0);
tbShopShareRecordMapper.update(query);
} else {
tbShopShareRecord.setStatus(0);
tbShopShareRecordMapper.insert(tbShopShareRecord);
}
}
if (query == null) {
query = tbShopShareRecord;
}
return Result.successWithData(query);
}
/**
* 修改数据
*
* @param tbShopShareRecord 实例对象
* @return 实例对象
*/
@Override
public TbShopShareRecord update(TbShopShareRecord tbShopShareRecord) {
this.tbShopShareRecordMapper.update(tbShopShareRecord);
return this.queryById(tbShopShareRecord.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Integer id) {
return this.tbShopShareRecordMapper.deleteById(id) > 0;
}
public TbShopUser getShopUserInfo(Integer userId, Integer shopId) {
return shopUserMapper.selectByUserIdAndShopId(userId.toString(), shopId.toString());
}
public void saveShopUser(Integer userId, Integer shopId) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(userId);
TbShopUser shopUser = new TbShopUser();
shopUser.setName(tbUserInfo.getNickName());
shopUser.setSex(tbUserInfo.getSex());
shopUser.setBirthDay(tbUserInfo.getBirthDay());
shopUser.setLevel(Byte.parseByte("1"));
String dynamicCode = RandomUtil.randomNumbers(8);
shopUser.setCode(dynamicCode);
shopUser.setTelephone(tbUserInfo.getTelephone());
shopUser.setAmount(BigDecimal.ZERO);
shopUser.setIsVip(Byte.parseByte("0"));
shopUser.setCreditAmount(BigDecimal.ZERO);
shopUser.setConsumeAmount(BigDecimal.ZERO);
shopUser.setConsumeNumber(0);
shopUser.setLevelConsume(BigDecimal.ZERO);
shopUser.setStatus(Byte.parseByte("1"));
shopUser.setShopId(shopId.toString());
shopUser.setUserId(userId.toString());
shopUser.setMiniOpenId(tbUserInfo.getMiniAppOpenId());
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
}
@Override
public void give(TbShopShareRecord shareRecord, Integer userId) {
TbShopShare shopShare = tbShopShareMapper.queryById(shareRecord.getShareId());
TbShopUser tbShopUser = getShopUserInfo(userId, shareRecord.getShopId());
if (userId.equals(shareRecord.getInvitedId())) {
giveCoupon(shopShare, tbShopUser, shopShare.getRewardCoupons());
} else if (userId.equals(shareRecord.getBeInvitedId())) {
giveCoupon(shopShare, tbShopUser, shopShare.getNewCoupons());
}
}
public void giveCoupon(TbShopShare shopShare, TbShopUser tbShopUser, List<TbShopShare.ShareCoupons> coupons) {
for (TbShopShare.ShareCoupons newCoupon : coupons) {
TbShopCoupon tbShopCoupon = couponMapper.queryById(newCoupon.getCouponId());
Date start = new Date();
Date end = new Date();
if ("fixed".equals(tbShopCoupon.getValidityType())) {
//固定时间
end = DateUtil.offsetDay(new Date(), tbShopCoupon.getValidDays());
} else if ("custom".equals(tbShopCoupon.getValidityType())) {
//自定义时间
start = tbShopCoupon.getValidStartTime();
end = tbShopCoupon.getValidEndTime();
}
if (tbShopCoupon != null) {
List<TbActivateInRecord> actGiveRecords = new ArrayList<>();
if (tbShopCoupon.getType() == 1) {
//满减
TbActivateInRecord record = new TbActivateInRecord();
record.setVipUserId(Integer.valueOf(tbShopUser.getId()));
record.setCouponId(tbShopCoupon.getId());
record.setName("" + tbShopCoupon.getFullAmount() + "" + tbShopCoupon.getDiscountAmount());
record.setFullAmount(tbShopCoupon.getFullAmount());
record.setDiscountAmount(tbShopCoupon.getDiscountAmount());
record.setType(1);
record.setNum(newCoupon.getCouponNum());
record.setOverNum(newCoupon.getCouponNum());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setSourceActId(shopShare.getId());
record.setUseStartTime(start);
record.setUseEndTime(end);
record.setSource("invited");
actGiveRecords.add(record);
} else if (tbShopCoupon.getType() == 2) {
//商品卷
List<TbCouponProduct> tbCouponProducts = couProductMapper.queryAllByCouponId(tbShopCoupon.getId());
for (TbCouponProduct actPro : tbCouponProducts) {
TbActivateInRecord record = new TbActivateInRecord();
record.setVipUserId(Integer.valueOf(tbShopUser.getId()));
record.setCouponId(tbShopCoupon.getId());
record.setName("商品卷");
record.setType(2);
record.setProId(actPro.getProductId());
record.setNum(actPro.getNum() * tbShopCoupon.getNumber());
record.setOverNum(actPro.getNum() * tbShopCoupon.getNumber());
record.setShopId(Integer.valueOf(tbShopUser.getShopId()));
record.setSourceActId(shopShare.getId());
record.setUseStartTime(start);
record.setUseEndTime(end);
record.setSource("invited");
actGiveRecords.add(record);
}
}
activateInRecordMapper.insertBatch(actGiveRecords);
}
}
}
}

View File

@@ -21,10 +21,11 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="couponJson" column="coupon_json" jdbcType="VARCHAR"/>
<result property="source" column="source" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json </sql>
id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json,source </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbActivateInRecordMap">
@@ -173,15 +174,15 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json)
values (#{vipUserId}, #{couponId}, #{name}, #{type}, #{proId}, #{fullAmount}, #{discountAmount}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{useStartTime}, #{useEndTime}, #{createTime}, #{updateTime}, #{couponJson})
insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json,source)
values (#{vipUserId}, #{couponId}, #{name}, #{type}, #{proId}, #{fullAmount}, #{discountAmount}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{useStartTime}, #{useEndTime}, #{createTime}, #{updateTime}, #{couponJson} , #{source})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json)
insert into tb_activate_in_record(vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, num, over_num, shop_id, source_act_id, source_flow_id, use_start_time, use_end_time, create_time, update_time, coupon_json, source)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.vipUserId}, #{entity.couponId}, #{entity.name}, #{entity.type}, #{entity.proId}, #{entity.fullAmount}, #{entity.discountAmount}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.useStartTime}, #{entity.useEndTime}, #{entity.createTime}, #{entity.updateTime}, #{entity.couponJson})
(#{entity.vipUserId}, #{entity.couponId}, #{entity.name}, #{entity.type}, #{entity.proId}, #{entity.fullAmount}, #{entity.discountAmount}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.useStartTime}, #{entity.useEndTime}, #{entity.createTime}, #{entity.updateTime}, #{entity.couponJson}, #{entity.source})
</foreach>
</insert>

View File

@@ -38,6 +38,8 @@
from tb_shop_share
where shop_id = #{shopId}
and status = 1
AND now() &gt; start_time
AND now() &lt; end_time
</select>
<!--查询指定行数据-->

View File

@@ -0,0 +1,160 @@
<?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.chaozhanggui.system.cashierservice.dao.TbShopShareRecordMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbShopShareRecord" id="TbShopShareRecordMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="shareId" column="share_id" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="invitedId" column="invited_id" jdbcType="INTEGER"/>
<result property="invitedName" column="invited_name" jdbcType="VARCHAR"/>
<result property="beInvitedId" column="be_invited_id" jdbcType="INTEGER"/>
<result property="method" column="method" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="rewardTime" column="reward_time" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
, share_id, shop_id, invited_id, invited_name, be_invited_id, method, status, reward_time, create_time, update_time </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where id = #{id}
</select>
<select id="queryByData" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where share_id = #{shareId}
and shop_id = #{shopId}
and invited_id = #{invitedId}
and be_invited_id = #{beInvitedId}
</select>
<select id="queryByDataByBeInvited" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
where share_id = #{shareId}
and shop_id = #{shopId}
and be_invited_id = #{beInvitedId}
</select>
<select id="query" resultMap="TbShopShareRecordMap">
select
<include refid="Base_Column_List"/>
from tb_shop_share_record
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="shareId != null">
and share_id = #{shareId}
</if>
<if test="shopId != null">
and shop_id = #{shopId}
</if>
<if test="invitedId != null">
and invited_id = #{invitedId}
</if>
<if test="invitedName != null and invitedName != ''">
and invited_name = #{invitedName}
</if>
<if test="beInvitedId != null">
and be_invited_id = #{beInvitedId}
</if>
<if test="method != null and method != ''">
and method = #{method}
</if>
<if test="status != null">
and status = #{status}
</if>
<if test="rewardTime != null">
and reward_time = #{rewardTime}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_shop_share_record(share_id, shop_id, invited_id, invited_name, be_invited_id, method, status,
reward_time, create_time, update_time)
values (#{shareId}, #{shopId}, #{invitedId}, #{invitedName}, #{beInvitedId}, #{method}, #{status},
#{rewardTime}, #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_shop_share_record(share_id, shop_id, invited_id, invited_name, be_invited_id, method, status,
reward_time, create_time, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.shareId}, #{entity.shopId}, #{entity.invitedId}, #{entity.invitedName}, #{entity.beInvitedId},
#{entity.method}, #{entity.status}, #{entity.rewardTime}, #{entity.createTime}, #{entity.updateTime})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_shop_share_record
<set>
<if test="shareId != null">
share_id = #{shareId},
</if>
<if test="shopId != null">
shop_id = #{shopId},
</if>
<if test="invitedId != null">
invited_id = #{invitedId},
</if>
<if test="invitedName != null and invitedName != ''">
invited_name = #{invitedName},
</if>
<if test="beInvitedId != null">
be_invited_id = #{beInvitedId},
</if>
<if test="method != null and method != ''">
method = #{method},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="rewardTime != null">
reward_time = #{rewardTime},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tb_shop_share_record
where id = #{id}
</delete>
</mapper>

View File

@@ -67,6 +67,14 @@
from tb_user_info
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectNameByPrimaryKey" parameterType="java.lang.Integer" resultType="string">
select
nick_name
from tb_user_info
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_user_info
where id = #{id,jdbcType=INTEGER}