修改优惠“卷”为优惠“券”,用户信息返回积分总数和可用优惠券数量

This commit is contained in:
谭凯凯
2024-11-13 17:08:49 +08:00
committed by Tankaikai
parent 99e9aae70a
commit 9a7a358f70
23 changed files with 107 additions and 52 deletions

View File

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 团购订单
* 团购订单
*
* @author ww
* @since 2024-04-27 16:15:08
@@ -42,7 +42,7 @@ public class GroupOrderInfoController {
}
/**
* 通过id查询
* 通过id查询
*/
@RequestMapping("getCoupon")
public Result queryCouponById(Integer id) {
@@ -50,7 +50,7 @@ public class GroupOrderInfoController {
}
/**
* 团购 下单
* 团购 下单
* @param token
* @param param
* @return

View File

@@ -131,7 +131,7 @@ public class NotifyController {
@RequestMapping("notifyCallBackGroupYsk")
public String notifyCallBackGroupYsk(HttpServletRequest request) {
Map<String, Object> map = getParameterMap(request);
log.info("团购回调返回信息:{}", JSONUtil.toJsonStr(map));
log.info("团购回调返回信息:{}", JSONUtil.toJsonStr(map));
if (ObjectUtil.isNotEmpty(map) && map.containsKey("code") && "200".equals(map.get("code") + "")) {
JSONObject object = JSONUtil.parseObj(map.get("data"));
if (ObjectUtil.isNotEmpty(object) && object.containsKey("status") && "1".equals(object.getStr("status"))) {
@@ -146,7 +146,7 @@ public class NotifyController {
@RequestMapping("notifyCallBackGroup")
public String notifyCallBackGroup(HttpServletRequest request) {
Map<String, Object> map = getParameterMap(request);
log.info("团购回调返回信息:{}", JSONUtil.toJsonStr(map));
log.info("团购回调返回信息:{}", JSONUtil.toJsonStr(map));
if (ObjectUtil.isNotEmpty(map) && map.containsKey("code") && "000000".equals(map.get("code") + "")) {
JSONObject object = JSONUtil.parseObj(map.get("bizData"));
if (ObjectUtil.isNotEmpty(object) && object.containsKey("state") && "TRADE_SUCCESS".equals(object.getStr("state"))) {

View File

@@ -1,8 +1,10 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
import com.chaozhanggui.system.cashierservice.dao.TbUserInfoMapper;
@@ -36,6 +38,8 @@ public class UserContoller {
private TbShopInfoMapper shopInfoMapper;
@Autowired
private TbUserInfoMapper userInfoMapper;
@Autowired
private TbActivateInRecordMapper activateInRecordMapper;
@PostMapping("/openMember")
public Result openMember(@RequestBody OpenMemberVo memberVo){
@@ -86,6 +90,7 @@ public class UserContoller {
shopUser.setShopId(shopId);
shopUser.setUserId(userId);
shopUser.setMiniOpenId(openId);
shopUser.setAccountPoints(0);
shopUser.setCreatedAt(System.currentTimeMillis());
shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser);
@@ -109,6 +114,8 @@ public class UserContoller {
shopUser.setAddress(tbShopInfo.getAddress());
shopUser.setIsUser(tbShopInfo.getIsCustom());
}
int couponNum = activateInRecordMapper.countCouponNumByShopId(Convert.toInt(shopUser.getUserId()),Convert.toInt(shopUser.getShopId()));
shopUser.setCouponNum(couponNum);
return Result.success(CodeEnum.SUCCESS, shopUser);
}

View File

@@ -37,6 +37,7 @@ public interface TbActivateInRecordMapper {
int countCouponNum(@Param("userId") Integer userId);
int countCouponNumByShopId(@Param("userId") Integer userId, @Param("shopId") Integer shopId);
/**
* 新增数据

View File

@@ -2,7 +2,7 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbCouponCategory;
/**
* 团购分类(TbCouponCategory)表数据库访问层
* 团购分类(TbCouponCategory)表数据库访问层
*
* @author ww
* @since 2024-04-24 14:09:16

View File

@@ -7,7 +7,7 @@ import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* 团购卷 卷码表(TbGroupOrderCoupon)表数据库访问层
* 团购券 券码表(TbGroupOrderCoupon)表数据库访问层
*
* @author ww
* @since 2024-05-06 14:39:59

View File

@@ -3,13 +3,12 @@ package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbGroupOrderInfo;
import com.chaozhanggui.system.cashierservice.entity.dto.GroupOrderDto;
import com.chaozhanggui.system.cashierservice.entity.vo.GroupOrderListVo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 团购订单(TbGroupOrderInfo)表数据库访问层
* 团购订单(TbGroupOrderInfo)表数据库访问层
*
* @author ww
* @since 2024-04-27 16:15:08

View File

@@ -29,15 +29,15 @@ public class TbActivate implements Serializable {
*/
private Integer giftPoints;
/**
* 是否使用优惠 0否 1是
* 是否使用优惠 0否 1是
*/
private Integer isUseCoupon;
/**
* 优惠id
* 优惠id
*/
private Integer couponId;
/**
* 优惠数量
* 优惠数量
*/
private Integer num;

View File

@@ -1,8 +1,8 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.io.Serializable;
/**
* 活动商品赠送记录表(TbActivateInRecord)实体类
@@ -19,11 +19,11 @@ public class TbActivateInRecord implements Serializable {
*/
private Integer vipUserId;
/**
* Id (校验是否可用)
* Id (校验是否可用)
*/
private Integer couponId;
/**
* 描述 满10减2/商品
* 描述 满10减2/商品
*/
private String name;
/**

View File

@@ -1,10 +1,10 @@
package com.chaozhanggui.system.cashierservice.entity;
import java.util.Date;
import java.io.Serializable;
import java.util.Date;
/**
* 团购分类(TbCouponCategory)实体类
* 团购分类(TbCouponCategory)实体类
*
* @author ww
* @since 2024-04-24 14:09:16

View File

@@ -4,7 +4,7 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
* 团购卷 卷码表(TbGroupOrderCoupon)实体类
* 团购券 券码表(TbGroupOrderCoupon)实体类
*
* @author ww
* @since 2024-05-06 14:39:59
@@ -18,7 +18,7 @@ public class TbGroupOrderCoupon implements Serializable {
*/
private Integer orderId;
/**
* 团购
* 团购
*/
private String couponNo;
/**

View File

@@ -2,9 +2,9 @@ package com.chaozhanggui.system.cashierservice.entity;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.io.Serializable;
@Data
public class TbGroupOrderInfo implements Serializable {
@@ -39,7 +39,7 @@ public class TbGroupOrderInfo implements Serializable {
*/
private String proName;
/**
* 团购到期日期
* 团购到期日期
*/
private Date expDate;
/**
@@ -98,7 +98,7 @@ public class TbGroupOrderInfo implements Serializable {
*/
private Date createTime;
/**
* 码核销员
* 码核销员
*/
private String verifier;
/**

View File

@@ -15,7 +15,7 @@ public class TbPurchaseNotice implements Serializable {
*/
private Integer id;
/**
* 商户Id
* 商户Id
*/
private Integer couponId;
/**

View File

@@ -7,6 +7,7 @@ import org.springframework.data.annotation.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class TbShopUser implements Serializable {
@@ -83,6 +84,13 @@ public class TbShopUser implements Serializable {
private String isUser;
private Timestamp joinTime;
private Integer accountPoints;
private Date lastPointsChangeTime;
private Integer lastFloatPoints;
@Transient
@TableField(exist = false)
private Integer couponNum;
private static final long serialVersionUID = 1L;

View File

@@ -102,7 +102,7 @@ public class TbUserInfo implements Serializable {
private String pwd;
private String custPhone = "400-6666-389";
//优惠数量
//优惠数量
private Integer couponAll = 0;
//储值数量
private BigDecimal balanceAll = BigDecimal.ZERO;

View File

@@ -19,7 +19,7 @@ public class GroupOrderDetailsVo {
*/
private String proName;
/**
* 商品图片
* 商品图片
*/
private String proImg;
/**

View File

@@ -4,7 +4,7 @@ import lombok.Data;
/**
* @author ww
* 店铺团购vo
* 店铺团购vo
*/
@Data
public class ShopGroupInfoVo {

View File

@@ -1,14 +1,14 @@
package com.chaozhanggui.system.cashierservice.service;
import com.chaozhanggui.system.cashierservice.entity.TbGroupOrderCoupon;
import com.chaozhanggui.system.cashierservice.dao.TbGroupOrderCouponMapper;
import com.chaozhanggui.system.cashierservice.entity.TbGroupOrderCoupon;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 团购卷 卷码表(TbGroupOrderCoupon)表服务实现类
* 团购券 券码表(TbGroupOrderCoupon)表服务实现类
*
* @author ww
* @since 2024-05-06 14:39:59

View File

@@ -731,7 +731,7 @@ public class PayService {
flow.setShopUserId(Integer.valueOf(user.getId()));
flow.setBizCode("accountGroupPay");
flow.setType("-");
flow.setBizName("会员储值卡支付团购");
flow.setBizName("会员储值卡支付团购");
flow.setAmount(orderInfo.getOrderAmount());
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
@@ -827,14 +827,14 @@ public class PayService {
} else if (payType.equals("aliPay")) {
req.setPayWay("ZFBZF");
}
req.setSubject("零点八零:团购");
req.setSubject("零点八零:团购");
req.setUserId(userId);
Map<String, Object> map = BeanUtil.transBeanMap(req);
req.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
ResponseEntity<String> response = restTemplate.postForEntity(url.concat("trans/pay"), req, String.class);
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
JSONObject object = JSONObject.parseObject(response.getBody());
log.info("团购支付响应:{}", object);
log.info("团购支付响应:{}", object);
if (object.get("code").equals("0")) {
payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
payment.setUpdatedAt(System.currentTimeMillis());
@@ -1548,13 +1548,13 @@ public class PayService {
record.setCouponJson(activateInRecordService.getCouponJson(activate, tbShopCoupon, null));
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.setName("商品");
record.setType(2);
record.setProId(actPro.getProductId());
record.setNum(actPro.getNum() * tbShopCoupon.getNumber());

View File

@@ -12,10 +12,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoEatModelEnum;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.dto.*;
import com.chaozhanggui.system.cashierservice.entity.vo.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
@@ -31,7 +30,6 @@ import com.chaozhanggui.system.cashierservice.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.util.concurrent.AtomicDouble;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -720,9 +718,9 @@ public class ProductService {
/**
* 团购详情
* 团购详情
*
* @param productId 团购Id
* @param productId 团购Id
* @return
* @throws Exception
*/

View File

@@ -2,12 +2,10 @@ 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.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -15,11 +13,7 @@ import org.apache.commons.lang3.StringUtils;
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.time.format.DateTimeFormatter;
import java.util.*;
@@ -268,13 +262,13 @@ public class TbShopShareRecordServiceImpl implements TbShopShareRecordService {
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.setName("商品");
record.setType(2);
record.setProId(actPro.getProductId());
record.setNum(actPro.getNum() * tbShopCoupon.getNumber());

View File

@@ -101,7 +101,7 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
order by inRecord.use_end_time asc
</select>
<!--查询剩余商品优惠数量-->
<!--查询剩余商品优惠数量-->
<select id="countCouponNum" resultType="INTEGER">
SELECT
ifnull(sum(over_num), 0)
@@ -110,6 +110,15 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu
INNER JOIN tb_shop_user vip ON record.vip_user_id = vip.id AND vip.user_id = #{userId}
</select>
<!--查询剩余商品优惠券数量-->
<select id="countCouponNumByShopId" resultType="INTEGER">
SELECT
ifnull(sum(over_num), 0)
FROM
tb_activate_in_record record
INNER JOIN tb_shop_user vip ON record.vip_user_id = vip.id AND vip.user_id = #{userId} AND vip.shop_id = #{shopId}
</select>
<!--查询指定行数据-->
<select id="queryAll" resultMap="TbActivateInRecordMap">
select

View File

@@ -32,12 +32,15 @@
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="mini_open_id" jdbcType="VARCHAR" property="miniOpenId" />
<result column="join_time" jdbcType="VARCHAR" property="joinTime" />
<result column="account_points" jdbcType="INTEGER" property="accountPoints" />
<result column="last_points_change_time" jdbcType="DATE" property="lastPointsChangeTime" />
<result column="last_float_points" jdbcType="INTEGER" property="lastFloatPoints" />
</resultMap>
<sql id="Base_Column_List">
id, amount, credit_amount, consume_amount, consume_number, level_consume, status,
merchant_id, shop_id, user_id, parent_id, parent_level, name, head_img, sex, birth_day,
telephone, is_vip, code, is_attention, attention_at, is_shareholder, level, distribute_type,
sort, created_at, updated_at, mini_open_id,dynamic_code,join_time
sort, created_at, updated_at, mini_open_id,dynamic_code,join_time,account_points,last_points_change_time,last_float_points
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
@@ -75,7 +78,9 @@
code, is_attention, attention_at,
is_shareholder, level, distribute_type,
sort, created_at, updated_at,
mini_open_id,join_time)
mini_open_id,join_time,
account_points,last_points_change_time,last_float_points
)
values (#{id,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{creditAmount,jdbcType=DECIMAL},
#{consumeAmount,jdbcType=DECIMAL}, #{consumeNumber,jdbcType=INTEGER}, #{levelConsume,jdbcType=DECIMAL},
#{status,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR},
@@ -85,7 +90,11 @@
#{code,jdbcType=VARCHAR}, #{isAttention,jdbcType=TINYINT}, #{attentionAt,jdbcType=INTEGER},
#{isShareholder,jdbcType=TINYINT}, #{level,jdbcType=TINYINT}, #{distributeType,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
#{miniOpenId,jdbcType=VARCHAR},#{joinTime,jdbcType=TIMESTAMP})
#{miniOpenId,jdbcType=VARCHAR},#{joinTime,jdbcType=TIMESTAMP},
#{accountPoints,jdbcType=INTEGER},
#{lastPointsChangeTime,jdbcType=TIMESTAMP},
#{lastFloatPoints,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
insert into tb_shop_user
@@ -177,6 +186,15 @@
<if test="joinTime != null">
join_time,
</if>
<if test="accountPoints != null">
account_points,
</if>
<if test="lastPointsChangeTime != null">
last_points_change_time,
</if>
<if test="lastFloatPoints != null">
last_float_points,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -266,6 +284,15 @@
<if test="joinTime != null">
#{joinTime,jdbcType=TIMESTAMP},
</if>
<if test="accountPoints != null">
#{accountPoints,jdbcType=INTEGER},
</if>
<if test="lastPointsChangeTime != null">
#{lastPointsChangeTime,jdbcType=TIMESTAMP},
</if>
<if test="lastFloatPoints != null">
#{lastFloatPoints,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
@@ -364,6 +391,15 @@
<if test="joinTime != null">
join_time = #{joinTime,jdbcType=TIMESTAMP},
</if>
<if test="accountPoints != null">
account_points = #{accountPoints,jdbcType=INTEGER},
</if>
<if test="lastPointsChangeTime != null">
last_points_change_time = #{lastPointsChangeTime,jdbcType=TIMESTAMP},
</if>
<if test="lastFloatPoints != null">
last_float_points = #{lastFloatPoints,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@@ -395,8 +431,11 @@
sort = #{sort,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
join_time = #{joinTime,jdbcType=TIMESTAMP},
mini_open_id = #{miniOpenId,jdbcType=VARCHAR}
join_time = #{joinTime,jdbcType=TIMESTAMP},
mini_open_id = #{miniOpenId,jdbcType=VARCHAR},
account_points = #{accountPoints,jdbcType=INTEGER},
last_points_change_time = #{lastPointsChangeTime,jdbcType=TIMESTAMP},
last_float_points = #{lastFloatPoints,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>