添加会员充值奖励

This commit is contained in:
韩鹏辉 2024-05-29 10:38:36 +08:00
parent 640036afc5
commit 664e57e145
9 changed files with 758 additions and 329 deletions

View File

@ -0,0 +1,27 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbActivate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
@Mapper
public interface TbActivateMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbActivate record);
int insertSelective(TbActivate record);
TbActivate selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbActivate record);
int updateByPrimaryKey(TbActivate record);
TbActivate selectByAmount(@Param("shopId") String shopId, @Param("amount") BigDecimal amount);
}

View File

@ -0,0 +1,78 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
public class TbActivate implements Serializable {
private Integer id;
private Integer shopId;
private Integer minNum;
private Integer maxNum;
private BigDecimal handselNum;
private String handselType;
private String isDel;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public Integer getMinNum() {
return minNum;
}
public void setMinNum(Integer minNum) {
this.minNum = minNum;
}
public Integer getMaxNum() {
return maxNum;
}
public void setMaxNum(Integer maxNum) {
this.maxNum = maxNum;
}
public BigDecimal getHandselNum() {
return handselNum;
}
public void setHandselNum(BigDecimal handselNum) {
this.handselNum = handselNum;
}
public String getHandselType() {
return handselType;
}
public void setHandselType(String handselType) {
this.handselType = handselType == null ? null : handselType.trim();
}
public String getIsDel() {
return isDel;
}
public void setIsDel(String isDel) {
this.isDel = isDel == null ? null : isDel.trim();
}
}

View File

@ -56,8 +56,35 @@ public class DutyService {
JSONObject jsonObject = JSON.parseObject(message);
String token = jsonObject.getString("token");
String type = jsonObject.getString("type");
boolean quick = jsonObject.containsKey("quick");
TbToken tbToken = tbTokenMapper.selectByToken(token);
String day = DateUtils.getDay();
if (quick) {
Integer tokenId = tbToken.getId();
String orderNo = jsonObject.getString("orderNo");
BigDecimal amount = new BigDecimal(jsonObject.getString("amount"));
JSONObject tokenJson = TokenUtil.parseParamFromToken(tbToken.getToken());
Integer shopId = tokenJson.getInteger("shopId");
Integer userId = tokenJson.getInteger("staffId");
String loginName = tokenJson.getString("loginName");
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(shopId);
ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0");
if (Objects.isNull(shopUserDuty)) {
shopUserDuty = new ShopUserDuty(userId, tbToken.getCreateTime(), 1, amount, shopInfo.getShopName(), "0",
amount, shopId, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, "");
shopUserDuty.setTokenId(tokenId);
shopUserDuty.setReturnAmount(BigDecimal.ZERO);
shopUserDuty.setTradeDay(DateUtils.getDay());
shopUserDutyMapper.insert(shopUserDuty);
}
} else {
if (type.equals("return") || type.equals("create")) {
if (Objects.isNull(tbToken)) {
throw new MsgException("当前用户不存在");
@ -284,6 +311,7 @@ public class DutyService {
shopUserDutyMapper.updateStatusById(shopUserDuty.getId(), staffId);
}
}
}
}catch (Exception e) {
e.getMessage();
}

View File

@ -9,12 +9,17 @@ import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
import com.chaozhanggui.system.cashierservice.util.BeanUtil;
import com.chaozhanggui.system.cashierservice.util.DateUtils;
import com.chaozhanggui.system.cashierservice.util.MD5Util;
import com.chaozhanggui.system.cashierservice.util.SnowFlakeUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
@ -23,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -50,20 +56,20 @@ public class MemberService {
@Autowired
TbShopPayTypeMapper tbShopPayTypeMapper;
@Value("${gateway.url}")
private String gateWayUrl;
@Autowired
ThirdPayService thirdPayService;
@Autowired
RestTemplate restTemplate;
@Autowired
TbActivateMapper tbActivateMapper;
@Value("${gateway.url}")
private String gateWayUrl;
@Value("${thirdPay.payType}")
private String thirdPayType;
@Value("${thirdPay.url}")
private String url;
@Value("${thirdPay.callBack}")
private String callBack;
public Result queryMember(String shopId, String phone, int page, int pageSize) {
@ -85,9 +91,9 @@ public class MemberService {
return Result.fail(CodeEnum.PARAM);
}
String phone=map.get("phone")+"";
String phone = String.valueOf(map.get("phone"));
String shopId=map.get("shopId")+"";
String shopId = String.valueOf(map.get("shopId"));
List<TbShopUser> tbShopUsers = tbShopUserMapper.selectByShopId(shopId, phone);
@ -97,13 +103,13 @@ public class MemberService {
if (ObjectUtil.isNotNull(tbShopUsers) && ObjectUtil.isNotEmpty(tbShopUsers)) {
TbShopUser tbShopUser = tbShopUsers.get(0);
String code= RandomUtil.randomNumbers(6);
String code = DateUtils.getSsdfTimes();
tbShopUser.setCode(code);
tbShopUser.setTelephone(phone);
tbShopUser.setBirthDay(map.get("birthDay")+"");
tbShopUser.setName(map.get("nickName")+"");
tbShopUser.setSex(Byte.parseByte(map.get("sex")+""));
tbShopUser.setLevel(Byte.parseByte(map.get("level")+""));
tbShopUser.setBirthDay(String.valueOf(map.get("birthDay")));
tbShopUser.setName(String.valueOf(map.get("nickName")));
tbShopUser.setSex(Byte.parseByte(String.valueOf(map.get("sex"))));
tbShopUser.setLevel(Byte.parseByte(String.valueOf(map.get("level"))));
tbShopUser.setIsVip(Byte.parseByte("1"));
tbShopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser);
@ -119,10 +125,10 @@ public class MemberService {
tbShopUser.setStatus(Byte.parseByte("1"));
tbShopUser.setShopId(shopId);
tbShopUser.setTelephone(phone);
tbShopUser.setBirthDay(map.get("birthDay")+"");
tbShopUser.setName(map.get("nickName")+"");
tbShopUser.setSex(Byte.parseByte(map.get("sex")+""));
tbShopUser.setLevel(Byte.parseByte(map.get("level")+""));
tbShopUser.setBirthDay(String.valueOf(map.get("birthDay")));
tbShopUser.setName(String.valueOf(map.get("nickName")));
tbShopUser.setSex(Byte.parseByte(String.valueOf(map.get("sex"))));
tbShopUser.setLevel(Byte.parseByte(String.valueOf(map.get("level"))));
String code = RandomUtil.randomNumbers(6);
tbShopUser.setCode(code);
tbShopUser.setIsVip(Byte.parseByte("1"));
@ -132,7 +138,6 @@ public class MemberService {
}
@Transactional(rollbackFor = Exception.class)
public Result memberScanPay(Map<String, Object> map) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
@ -144,9 +149,9 @@ public class MemberService {
return Result.fail(CodeEnum.PARAM);
}
String memberId=map.get("memberId")+"";
String memberId = String.valueOf(map.get("memberId"));
String shopId=map.get("shopId")+"";
String shopId = String.valueOf(map.get("shopId"));
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
@ -176,7 +181,7 @@ public class MemberService {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
}
BigDecimal amount= new BigDecimal(map.get("amount")+"").setScale(2,BigDecimal.ROUND_DOWN);
BigDecimal amount = new BigDecimal(String.valueOf(map.get("amount"))).setScale(2, RoundingMode.DOWN);
TbMemberIn memberIn = new TbMemberIn();
memberIn.setAmount(amount);
@ -187,7 +192,6 @@ public class MemberService {
memberIn.setCreateTime(new Date());
tbMemberInMapper.insert(memberIn);
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
@ -195,6 +199,7 @@ public class MemberService {
}
if ("ysk".equals(thirdPayType)) {
ScanPayReq scanPayReq = new ScanPayReq();
scanPayReq.setAppId(thirdApply.getAppId());
scanPayReq.setTimestamp(System.currentTimeMillis());
@ -243,6 +248,85 @@ public class MemberService {
return Result.fail(object.getString("msg"));
}
}
} else {
String orderNo = DateUtils.getSsdfTimes();
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payTypeCode.equals("1") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData();
if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
memberIn.setOrderNo(orderNo);
memberIn.setTradeNo(mainScanResp.getPayOrderId());
memberIn.setStatus("0");
memberIn.setUpdateTime(new Date());
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
//修改客户资金
shopUser.setAmount(shopUser.getAmount().add(amount));
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(shopUser);
TbShopUserFlow flow = new TbShopUserFlow();
flow.setShopUserId(shopUser.getId());
flow.setBizCode("scanMemberIn");
flow.setBizName("会员扫码充值");
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = BigDecimal.ZERO;
switch (activate.getHandselType()) {
case "GD":
awardAmount = activate.getHandselNum();
break;
case "RATIO":
awardAmount = memberIn.getAmount().multiply(activate.getHandselNum());
break;
}
shopUser.setAmount(shopUser.getAmount().add(awardAmount));
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(shopUser);
flow = new TbShopUserFlow();
flow.setShopUserId(shopUser.getId());
flow.setBizCode("scanMemberAwardIn");
flow.setBizName("会员充值奖励");
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
}
return Result.success(CodeEnum.SUCCESS, memberIn);
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
memberIn.setOrderNo(orderNo);
memberIn.setTradeNo(mainScanResp.getPayOrderId());
memberIn.setUpdateTime(new Date());
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
return Result.success(CodeEnum.PAYING, memberIn);
} else {
return Result.fail(publicResp.getMsg());
}
}
}
}
return Result.fail("失败");
@ -257,7 +341,6 @@ public class MemberService {
TbMemberIn memberIn = tbMemberInMapper.selectByPrimaryKey(Integer.valueOf(flowId));
TbShopUser shopUser = tbShopUserMapper.selectByPrimaryKey(memberIn.getUserId());
if (ObjectUtil.isEmpty(shopUser) || !"1".equals(shopUser.getIsVip().toString())) {
return Result.fail(CodeEnum.MEMBERNOEXIST);
@ -265,10 +348,13 @@ public class MemberService {
if (memberIn.getStatus().equals("7")) {
TbMerchantThirdApply thirdApply= tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(memberIn.getMerchantId()));
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(memberIn.getMerchantId());
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail(CodeEnum.NOCUSTOMER);
}
if ("ysk".equals(thirdPayType)) {
TradeQueryReq tradeQueryReq = new TradeQueryReq();
tradeQueryReq.setAppId(thirdApply.getAppId());
tradeQueryReq.setTimestamp(System.currentTimeMillis());
@ -306,14 +392,69 @@ public class MemberService {
}
}
}
} else {
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(), memberIn.getTradeNo(), null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
if ("000000".equals(orderstatus.getCode())) {
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
memberIn.setStatus("0");
memberIn.setUpdateTime(new Date());
tbMemberInMapper.updateByPrimaryKeySelective(memberIn);
//修改客户资金
shopUser.setAmount(shopUser.getAmount().add(memberIn.getAmount()));
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(shopUser);
TbShopUserFlow flow = new TbShopUserFlow();
flow.setShopUserId(shopUser.getId());
flow.setBizCode("scanMemberIn");
flow.setBizName("会员扫码充值");
flow.setAmount(memberIn.getAmount());
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
TbActivate activate = tbActivateMapper.selectByAmount(shopUser.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = BigDecimal.ZERO;
switch (activate.getHandselType()) {
case "GD":
awardAmount = activate.getHandselNum();
break;
case "RATIO":
awardAmount = memberIn.getAmount().multiply(activate.getHandselNum());
break;
}
shopUser.setAmount(shopUser.getAmount().add(awardAmount));
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(shopUser);
flow = new TbShopUserFlow();
flow.setShopUserId(shopUser.getId());
flow.setBizCode("scanMemberAwardIn");
flow.setBizName("会员充值奖励");
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
}
return Result.success(CodeEnum.SUCCESS, memberIn);
}
}
}
}
}
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@Transactional(rollbackFor = Exception.class)
public Result memberAccountPay(Map<String, Object> map) {
if (ObjectUtil.isEmpty(map) || map.size() <= 0
@ -324,9 +465,9 @@ public class MemberService {
return Result.fail(CodeEnum.PARAM);
}
String memberId=map.get("memberId")+"";
String memberId = String.valueOf(map.get("memberId"));
String shopId=map.get("shopId")+"";
String shopId = String.valueOf(map.get("shopId"));
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
@ -343,7 +484,7 @@ public class MemberService {
return Result.fail(CodeEnum.PAYTYPENOEXIST);
}
BigDecimal amount= new BigDecimal(map.get("amount")+"").setScale(2,BigDecimal.ROUND_DOWN);
BigDecimal amount = new BigDecimal(String.valueOf(map.get("amount"))).setScale(2, RoundingMode.DOWN);
TbMemberIn memberIn = new TbMemberIn();
memberIn.setAmount(amount);
@ -367,8 +508,34 @@ public class MemberService {
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
return Result.success(CodeEnum.SUCCESS);
TbActivate activate = tbActivateMapper.selectByAmount(shopInfo.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = BigDecimal.ZERO;
switch (activate.getHandselType()) {
case "GD":
awardAmount = activate.getHandselNum();
break;
case "RATIO":
awardAmount = memberIn.getAmount().multiply(activate.getHandselNum());
break;
}
shopUser.setAmount(shopUser.getAmount().add(awardAmount));
shopUser.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(shopUser);
flow = new TbShopUserFlow();
flow.setShopUserId(shopUser.getId());
flow.setBizCode("scanMemberAwardIn");
flow.setBizName("会员充值奖励");
flow.setAmount(awardAmount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
}
return Result.success(CodeEnum.SUCCESS);
}
@ -384,5 +551,4 @@ public class MemberService {
}
}

View File

@ -436,12 +436,12 @@ public class PayService {
return Result.fail(CodeEnum.MEMBERNOEXIST);
}
if (N.gt(orderInfo.getPayAmount(), user.getAmount())) {
if (N.gt(orderInfo.getOrderAmount(), user.getAmount())) {
return Result.fail(CodeEnum.MEMBERINSUFFICIENTFUNDS);
}
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount()));
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getOrderAmount()));
user.setConsumeNumber(user.getConsumeNumber() + 1);
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(user);
@ -934,6 +934,19 @@ public class PayService {
if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
tbQuickPay.setTradeNo(mainScanResp.getPayOrderId());
tbQuickPayMapper.insert(tbQuickPay);
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", token);
jsonObject.put("quick", "quick");
jsonObject.put("orderNo",tbQuickPay.getOrderNo());
jsonObject.put("amount",tbQuickPay.getAmount());
producer.putOrderCollect(jsonObject.toJSONString());
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
}

View File

@ -19,7 +19,7 @@ public class DateUtils {
private final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss");
private final static SimpleDateFormat sdfTimesSs = new SimpleDateFormat("yyyyMMddHHmmss");
private final static SimpleDateFormat sdfTimesSs = new SimpleDateFormat("yyyyMMddHHmmssSSS");

View File

@ -6,7 +6,7 @@
<generatorConfiguration>
<!-- 需要指明数据库连接器的绝对路径 -->
<!-- <classPathEntry location="C:\Users\admin\.m1\repository\mysql\mysql-connector-java\8.0.20\mysql-connector-java-8.0.20.jar" />-->
<classPathEntry location="E:\app\maven\repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
<classPathEntry location="D:\.m2\repository\mysql\mysql-connector-java\8.0.17\mysql-connector-java-8.0.17.jar"/>
<context id="msqlTables" targetRuntime="MyBatis3">
<!-- 生成的pojo将implements Serializable-->
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
@ -19,8 +19,8 @@
<!-- 数据库链接URL、用户名、密码 -->
<jdbcConnection connectionURL="jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;serverTimezone=GMT%2B8"
driverClass="com.mysql.cj.jdbc.Driver" password="mysqlroot@123" userId="root" >
<jdbcConnection connectionURL="jdbc:mysql://101.37.12.135:3306/fycashier?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;serverTimezone=GMT%2B8"
driverClass="com.mysql.cj.jdbc.Driver" password="Twc6MrzzjBiWSsjh" userId="fycashier" >
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
@ -52,13 +52,9 @@
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
<table tableName="tb_shop_user_duty_pay" domainObjectName="ShopUserDutyPay"
<table tableName="tb_activate" domainObjectName="TbActivate"
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
enableSelectByExample="false" selectByExampleQueryId="false" >
</table>
</context>
</generatorConfiguration>

View File

@ -0,0 +1,121 @@
<?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.TbActivateMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbActivate">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
<result column="min_num" jdbcType="INTEGER" property="minNum" />
<result column="max_num" jdbcType="INTEGER" property="maxNum" />
<result column="handsel_num" jdbcType="DECIMAL" property="handselNum" />
<result column="handsel_type" jdbcType="VARCHAR" property="handselType" />
<result column="is_del" jdbcType="VARCHAR" property="isDel" />
</resultMap>
<sql id="Base_Column_List">
id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_activate
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tb_activate
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
insert into tb_activate (id, shop_id, min_num,
max_num, handsel_num, handsel_type,
is_del)
values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{minNum,jdbcType=INTEGER},
#{maxNum,jdbcType=INTEGER}, #{handselNum,jdbcType=DECIMAL}, #{handselType,jdbcType=VARCHAR},
#{isDel,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
insert into tb_activate
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="minNum != null">
min_num,
</if>
<if test="maxNum != null">
max_num,
</if>
<if test="handselNum != null">
handsel_num,
</if>
<if test="handselType != null">
handsel_type,
</if>
<if test="isDel != null">
is_del,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="shopId != null">
#{shopId,jdbcType=INTEGER},
</if>
<if test="minNum != null">
#{minNum,jdbcType=INTEGER},
</if>
<if test="maxNum != null">
#{maxNum,jdbcType=INTEGER},
</if>
<if test="handselNum != null">
#{handselNum,jdbcType=DECIMAL},
</if>
<if test="handselType != null">
#{handselType,jdbcType=VARCHAR},
</if>
<if test="isDel != null">
#{isDel,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
update tb_activate
<set>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="minNum != null">
min_num = #{minNum,jdbcType=INTEGER},
</if>
<if test="maxNum != null">
max_num = #{maxNum,jdbcType=INTEGER},
</if>
<if test="handselNum != null">
handsel_num = #{handselNum,jdbcType=DECIMAL},
</if>
<if test="handselType != null">
handsel_type = #{handselType,jdbcType=VARCHAR},
</if>
<if test="isDel != null">
is_del = #{isDel,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbActivate">
update tb_activate
set shop_id = #{shopId,jdbcType=INTEGER},
min_num = #{minNum,jdbcType=INTEGER},
max_num = #{maxNum,jdbcType=INTEGER},
handsel_num = #{handselNum,jdbcType=DECIMAL},
handsel_type = #{handselType,jdbcType=VARCHAR},
is_del = #{isDel,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByAmount" resultMap="BaseResultMap">
select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num &lt;= #{amount} and max_num &gt;= #{amount}
</select>
</mapper>

View File

@ -27,7 +27,7 @@
delete from tb_member_in
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbMemberIn">
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbMemberIn" keyProperty="id" useGeneratedKeys="true">
insert into tb_member_in (id, user_id, merchant_id,
code, amount, status,
order_no, trade_no, create_time,