Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松
2024-11-12 18:18:06 +08:00
8 changed files with 127 additions and 25 deletions

View File

@@ -6,6 +6,7 @@ import org.springframework.data.domain.Pageable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* (TbActivate)表数据库访问层
@@ -66,5 +67,11 @@ public interface TbActivateMapper {
int deleteById(Integer id);
TbActivate selectByAmount(@Param("shopId") String shopId, @Param("amount") BigDecimal amount);
TbActivate selectByAmountScope(@Param("shopId") String shopId,@Param("amount") BigDecimal amount);
int updateMemberPoints(@Param("memberId") Long memberId,@Param("points") Integer points);
int insertMemberPointsLog(Map<String,Object> params);
}

View File

@@ -1,7 +1,7 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import java.io.Serializable;
import java.util.Date;
/**
* (TbActivate)实体类
@@ -23,6 +23,10 @@ public class TbActivate implements Serializable {
* 赠送金额
*/
private Integer giftAmount;
/**
* 赠送积分
*/
private Integer giftPoints;
/**
* 是否使用优惠卷 0否 1是
*/
@@ -113,5 +117,12 @@ public class TbActivate implements Serializable {
this.updateTime = updateTime;
}
public Integer getGiftPoints() {
return giftPoints;
}
public void setGiftPoints(Integer giftPoints) {
this.giftPoints = giftPoints;
}
}

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.math.BigDecimal;
import java.util.Date;
import java.io.Serializable;
@@ -36,11 +37,11 @@ public class TbActivateInRecord implements Serializable {
/**
* 满多少金额
*/
private Integer fullAmount;
private BigDecimal fullAmount;
/**
* 减多少金额
*/
private Integer discountAmount;
private BigDecimal discountAmount;
/**
* 赠送数量
*/
@@ -123,19 +124,19 @@ public class TbActivateInRecord implements Serializable {
this.proId = proId;
}
public Integer getFullAmount() {
public BigDecimal getFullAmount() {
return fullAmount;
}
public void setFullAmount(Integer fullAmount) {
public void setFullAmount(BigDecimal fullAmount) {
this.fullAmount = fullAmount;
}
public Integer getDiscountAmount() {
public BigDecimal getDiscountAmount() {
return discountAmount;
}
public void setDiscountAmount(Integer discountAmount) {
public void setDiscountAmount(BigDecimal discountAmount) {
this.discountAmount = discountAmount;
}

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.math.BigDecimal;
import java.time.LocalTime;
import java.util.Date;
import java.io.Serializable;
@@ -29,11 +30,11 @@ public class TbShopCoupon implements Serializable {
/**
* 满多少金额
*/
private Integer fullAmount;
private BigDecimal fullAmount;
/**
* 减多少金额
*/
private Integer discountAmount;
private BigDecimal discountAmount;
/**
* 描述
*/
@@ -132,19 +133,19 @@ public class TbShopCoupon implements Serializable {
this.type = type;
}
public Integer getFullAmount() {
public BigDecimal getFullAmount() {
return fullAmount;
}
public void setFullAmount(Integer fullAmount) {
public void setFullAmount(BigDecimal fullAmount) {
this.fullAmount = fullAmount;
}
public Integer getDiscountAmount() {
public BigDecimal getDiscountAmount() {
return discountAmount;
}
public void setDiscountAmount(Integer discountAmount) {
public void setDiscountAmount(BigDecimal discountAmount) {
this.discountAmount = discountAmount;
}

View File

@@ -1,8 +1,10 @@
package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
@@ -377,6 +379,23 @@ public class MemberService {
flow.setIsReturn("0");
tbShopUserFlowMapper.insert(flow);
//充值送积分
TbActivate activate = tbActivateMapper.selectByAmountScope(shopUser.getShopId(), memberIn.getAmount());
if (ObjectUtil.isNotNull(activate)) {
tbActivateMapper.updateMemberPoints(Convert.toLong(shopUser.getId()),activate.getGiftAmount());
Map<String, Object> params = new HashMap<>();
params.put("shopId", shopInfo.getId());
params.put("memberId", shopUser.getId());
params.put("memberName", shopUser.getName());
params.put("avatarUrl", shopUser.getHeadImg());
params.put("mobile", shopUser.getTelephone());
params.put("content", StrUtil.format("充值¥{}送{}积分", amount, activate.getGiftPoints()));
params.put("orderNo", memberIn.getOrderNo());
params.put("floatType", "add");
params.put("floatPoints", activate.getGiftPoints());
tbActivateMapper.insertMemberPointsLog(params);
}
BigDecimal fl = giveActivate(shopUser, amount, flow.getId());
JSONObject jsonObject = new JSONObject();
@@ -587,9 +606,9 @@ public class MemberService {
flow.setBalance(shopUser.getAmount());
flow.setIsReturn("0");
flow.setCreateTime(new Date());
flow.setRemark(memberIn.getOrderNo());
tbShopUserFlowMapper.insert(flow);
TbActivate activate = tbActivateMapper.selectByAmount(shopUser.getId().toString(), memberIn.getAmount());
if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) {
BigDecimal awardAmount = activate.getGiftAmount() == null ? BigDecimal.ZERO : new BigDecimal(activate.getGiftAmount());
@@ -626,6 +645,23 @@ public class MemberService {
baObj.put("time", flow.getCreateTime());
producer.balance(baObj.toString());
}
//充值送积分
activate = tbActivateMapper.selectByAmountScope(shopUser.getShopId(), memberIn.getAmount());
if (ObjectUtil.isNotNull(activate)) {
tbActivateMapper.updateMemberPoints(Convert.toLong(shopUser.getId()),activate.getGiftAmount());
Map<String, Object> params = new HashMap<>();
params.put("shopId", shopUser.getShopId());
params.put("memberId", shopUser.getId());
params.put("memberName", shopUser.getName());
params.put("avatarUrl", shopUser.getHeadImg());
params.put("mobile", shopUser.getTelephone());
params.put("content", StrUtil.format("充值¥{}送{}积分", memberIn.getAmount(), activate.getGiftPoints()));
params.put("orderNo", memberIn.getOrderNo());
params.put("floatType", "add");
params.put("floatPoints", activate.getGiftPoints());
tbActivateMapper.insertMemberPointsLog(params);
}
return Result.success(CodeEnum.SUCCESS, memberIn);
}
@@ -728,6 +764,23 @@ public class MemberService {
flow.get().setIsReturn("0");
tbShopUserFlowMapper.insert(flow.get());
fl.set(giveActivate(shopUser, amount, flow.get().getId()));
//充值送积分
TbActivate activate = tbActivateMapper.selectByAmountScope(shopUser.getShopId(), memberIn.getAmount());
if (ObjectUtil.isNotNull(activate)) {
tbActivateMapper.updateMemberPoints(Convert.toLong(shopUser.getId()),activate.getGiftAmount());
Map<String, Object> params = new HashMap<>();
params.put("shopId", shopInfo.getId());
params.put("memberId", shopUser.getId());
params.put("memberName", shopUser.getName());
params.put("avatarUrl", shopUser.getHeadImg());
params.put("mobile", shopUser.getTelephone());
params.put("content", StrUtil.format("充值¥{}送{}积分", amount, activate.getGiftPoints()));
params.put("orderNo", memberIn.getOrderNo());
params.put("floatType", "add");
params.put("floatPoints", activate.getGiftPoints());
tbActivateMapper.insertMemberPointsLog(params);
}
return null;
});

View File

@@ -9,8 +9,8 @@
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="proId" column="pro_id" jdbcType="INTEGER"/>
<result property="fullAmount" column="full_amount" jdbcType="INTEGER"/>
<result property="discountAmount" column="discount_amount" jdbcType="INTEGER"/>
<result property="fullAmount" column="full_amount" jdbcType="DECIMAL"/>
<result property="discountAmount" column="discount_amount" jdbcType="DECIMAL"/>
<result property="num" column="num" jdbcType="INTEGER"/>
<result property="overNum" column="over_num" jdbcType="INTEGER"/>
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>

View File

@@ -7,6 +7,7 @@
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
<result property="amount" column="amount" jdbcType="INTEGER"/>
<result property="giftAmount" column="gift_amount" jdbcType="INTEGER"/>
<result property="giftPoints" column="gift_points" jdbcType="INTEGER"/>
<result property="isUseCoupon" column="is_use_coupon" jdbcType="INTEGER"/>
<result property="couponId" column="coupon_id" jdbcType="INTEGER"/>
<result property="num" column="num" jdbcType="INTEGER"/>
@@ -16,18 +17,40 @@
<sql id="Base_Column_List">
id
, shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time </sql>
, shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time </sql>
<select id="selectByAmount" resultMap="TbActivateMap">
select *
from tb_activate
where shop_id = #{shopId}
and amount = #{amount}
ORDER BY amount desc
and amount &lt;= #{amount}
order by amount desc
limit 1
</select>
<select id="selectByAmountScope" resultMap="TbActivateMap">
select
<include refid="Base_Column_List"/>
from tb_activate
where shop_id = #{shopId}
<![CDATA[
and amount > 0
and amount <= #{amount}
]]>
order by amount desc,gift_points desc,id desc
limit 1
</select>
<select id="updateMemberPoints" resultType="int">
update tb_shop_user set last_points_change_time = now(),last_float_points = #{points},account_points = account_points + ${points} where id = #{memberId}
</select>
<insert id="insertMemberPointsLog" keyProperty="id" useGeneratedKeys="true">
insert into tb_member_points_log(shop_id, member_id, member_name, avatar_url, content, order_no, mobile, float_type, float_points, create_time)
values (#{shopId}, #{memberId}, #{memberName}, #{avatarUrl}, #{content}, #{orderNo}, #{mobile}, #{floatType}, #{floatPoints}, now())
</insert>
<!--查询单个-->
<select id="queryById" resultMap="TbActivateMap">
select
@@ -56,6 +79,9 @@
<if test="giftAmount != null">
and gift_amount = #{giftAmount}
</if>
<if test="giftPoints != null">
and gift_points = #{giftPoints}
</if>
<if test="isUseCoupon != null">
and is_use_coupon = #{isUseCoupon}
</if>
@@ -77,15 +103,15 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate(shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time)
values (#{shopId}, #{amount}, #{giftAmount}, #{isUseCoupon}, #{couponId}, #{num}, #{createTime}, #{updateTime})
insert into tb_activate(shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time)
values (#{shopId}, #{amount}, #{giftAmount}, #{giftPoints}, #{isUseCoupon}, #{couponId}, #{num}, #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate(shop_id, amount, gift_amount, is_use_coupon, coupon_id, num, create_time, update_time)
insert into tb_activate(shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.shopId}, #{entity.amount}, #{entity.giftAmount}, #{entity.isUseCoupon}, #{entity.couponId},
(#{entity.shopId}, #{entity.amount}, #{entity.giftAmount}, #{entity.giftPoints}, #{entity.isUseCoupon}, #{entity.couponId},
#{entity.num}, #{entity.createTime}, #{entity.updateTime})
</foreach>
</insert>
@@ -103,6 +129,9 @@
<if test="giftAmount != null">
gift_amount = #{giftAmount},
</if>
<if test="giftPoints != null">
gift_points = #{giftPoints},
</if>
<if test="isUseCoupon != null">
is_use_coupon = #{isUseCoupon},
</if>

View File

@@ -7,8 +7,8 @@
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="fullAmount" column="full_amount" jdbcType="INTEGER"/>
<result property="discountAmount" column="discount_amount" jdbcType="INTEGER"/>
<result property="fullAmount" column="full_amount" jdbcType="DECIMAL"/>
<result property="discountAmount" column="discount_amount" jdbcType="DECIMAL"/>
<result property="description" column="description" jdbcType="VARCHAR"/>
<result property="number" column="number" jdbcType="INTEGER"/>
<result property="leftNumber" column="left_number" jdbcType="INTEGER"/>