领取优惠券操作
This commit is contained in:
parent
f203d7bccc
commit
2cd2ef8c07
|
|
@ -0,0 +1,17 @@
|
|||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts;
|
||||
|
||||
public interface TbSplitAccountsMapper {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(TbSplitAccounts record);
|
||||
|
||||
int insertSelective(TbSplitAccounts record);
|
||||
|
||||
TbSplitAccounts selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(TbSplitAccounts record);
|
||||
|
||||
int updateByPrimaryKey(TbSplitAccounts record);
|
||||
}
|
||||
|
|
@ -96,6 +96,7 @@ public class TbOrderInfo implements Serializable {
|
|||
private String tableName;
|
||||
private String masterId;
|
||||
private String isBuyCoupon;
|
||||
private String isUseCoupon;
|
||||
private Integer totalNumber;
|
||||
private List<TbOrderDetail> detailList;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class TbSplitAccounts implements Serializable {
|
||||
private Integer id;
|
||||
|
||||
private Integer merchantId;
|
||||
|
||||
private Integer shopId;
|
||||
|
||||
private BigDecimal couponsPrice;
|
||||
|
||||
private BigDecimal conponsAmount;
|
||||
private BigDecimal originAmount;
|
||||
|
||||
private String isSplit;
|
||||
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date splitTime;
|
||||
|
||||
private String tradeDay;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ public class CartService {
|
|||
BigDecimal packAMount = BigDecimal.ZERO;
|
||||
BigDecimal originAmount = BigDecimal.ZERO;
|
||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||
String couponId = jsonObject.getString("couponsId");
|
||||
String couponId = "";
|
||||
BigDecimal couponAmount = BigDecimal.ZERO;
|
||||
Map<Integer, TbProductSku> skuMap = new HashMap<>();
|
||||
List<TbOrderDetail> orderDetails = new ArrayList<>();
|
||||
|
|
@ -270,7 +270,9 @@ public class CartService {
|
|||
//生成订单
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
|
||||
String isBuyYhq = "false";
|
||||
String isuseYhq = "false";
|
||||
if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) {
|
||||
couponId =jsonObject.getString("couponsId");
|
||||
//1:购买优惠券,0:自己持有优惠券
|
||||
Integer couponsId = jsonObject.getInteger("couponsId");
|
||||
if (jsonObject.getString("isBuyYhq").equals("1")) {
|
||||
|
|
@ -342,7 +344,7 @@ public class CartService {
|
|||
userCouponsMapper.updateByPrimaryKeySelective(userCoupons);
|
||||
couponAmount = userCoupons.getCouponsAmount();
|
||||
}
|
||||
|
||||
isuseYhq = "true";
|
||||
|
||||
}
|
||||
if (Objects.nonNull(orderInfo)) {
|
||||
|
|
@ -370,6 +372,7 @@ public class CartService {
|
|||
orderInfo.setFreightAmount(BigDecimal.ZERO);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setIsBuyCoupon(isBuyYhq);
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
} else {
|
||||
orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount);
|
||||
|
|
@ -377,6 +380,7 @@ public class CartService {
|
|||
orderInfo.setUserCouponId(couponId);
|
||||
orderInfo.setOriginAmount(originAmount);
|
||||
orderInfo.setIsBuyCoupon(isBuyYhq);
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
orderInfo.setUserCouponAmount(couponAmount);
|
||||
orderInfoMapper.insert(orderInfo);
|
||||
orderId = orderInfo.getId();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
<result column="master_id" jdbcType="VARCHAR" property="masterId"/>
|
||||
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
|
||||
<result column="is_buy_coupon" jdbcType="VARCHAR" property="isBuyCoupon"/>
|
||||
<result column="is_use_coupon" jdbcType="VARCHAR" property="isUseCoupon"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount,
|
||||
|
|
@ -54,7 +55,8 @@
|
|||
discount_amount, table_id, small_change, send_type, order_type, product_type, status,
|
||||
billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score,
|
||||
user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group,
|
||||
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,is_buy_coupon
|
||||
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,
|
||||
remark,master_id,`table_name`,is_buy_coupon,is_use_coupon
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
|
|
@ -81,7 +83,7 @@
|
|||
deduct_score, user_coupon_id, user_coupon_amount,
|
||||
refund_able, paid_time, is_effect,
|
||||
is_group, updated_at, system_time,
|
||||
created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,is_buy_coupon
|
||||
created_at, is_accepted, pay_order_no,trade_day,source,remark,master_id,table_name,is_buy_coupon,is_use_coupon
|
||||
)
|
||||
values (#{id,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
|
||||
#{packFee,jdbcType=DECIMAL}, #{originAmount,jdbcType=DECIMAL}, #{productAmount,jdbcType=DECIMAL},
|
||||
|
|
@ -97,7 +99,7 @@
|
|||
#{isGroup,jdbcType=TINYINT}, #{updatedAt,jdbcType=BIGINT}, #{systemTime,jdbcType=BIGINT},
|
||||
#{createdAt,jdbcType=BIGINT}, #{isAccepted,jdbcType=TINYINT}, #{payOrderNo,jdbcType=VARCHAR},
|
||||
#{tradeDay,jdbcType=VARCHAR}, #{source,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR},
|
||||
#{masterId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{isBuyCoupon,jdbcType=VARCHAR}
|
||||
#{masterId,jdbcType=VARCHAR}, #{tableName,jdbcType=VARCHAR}, #{isBuyCoupon,jdbcType=VARCHAR}, #{isUseCoupon,jdbcType=VARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo"
|
||||
|
|
@ -221,15 +223,15 @@
|
|||
<if test="payOrderNo != null">
|
||||
pay_order_no,
|
||||
</if>
|
||||
<if test="isBuyCoupon != null">
|
||||
is_buy_coupon,
|
||||
<if test="isBuyCoupon != null">
|
||||
is_buy_coupon,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isBuyCoupon != null">
|
||||
<if test="isBuyCoupon != null">
|
||||
#{isBuyCoupon,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="orderNo != null">
|
||||
|
|
@ -471,8 +473,11 @@
|
|||
<if test="tradeDay != null">
|
||||
trade_day = #{tradeDay,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isBuyCoupon != null">
|
||||
is_buy_coupon = #{isBuyCoupon,jdbcType=VARCHAR},
|
||||
<if test="isBuyCoupon != null">
|
||||
is_buy_coupon = #{isBuyCoupon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isUseCoupon != null">
|
||||
is_use_coupon = #{isUseCoupon,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
|
|
@ -529,7 +534,7 @@
|
|||
</select>
|
||||
<select id="selectByUserId" resultType="com.chaozhanggui.system.cashierservice.entity.TbOrderInfo">
|
||||
select
|
||||
*
|
||||
*
|
||||
from tb_order_info a
|
||||
|
||||
where user_id = #{userId}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,154 @@
|
|||
<?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.TbSplitAccountsMapper">
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
|
||||
<result column="shop_id" jdbcType="INTEGER" property="shopId" />
|
||||
<result column="coupons_price" jdbcType="DECIMAL" property="couponsPrice" />
|
||||
<result column="conpons_amount" jdbcType="DECIMAL" property="conponsAmount" />
|
||||
<result column="is_split" jdbcType="VARCHAR" property="isSplit" />
|
||||
<result column="order_amount" jdbcType="DECIMAL" property="orderAmount" />
|
||||
<result column="origin_amount" jdbcType="DECIMAL" property="originAmount" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="split_time" jdbcType="TIMESTAMP" property="splitTime" />
|
||||
<result column="trade_day" jdbcType="VARCHAR" property="tradeDay" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
id, merchant_id, shop_id, coupons_price, conpons_amount, is_split, order_amount,
|
||||
create_time, split_time, trade_day,origin_amount
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_split_accounts
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_split_accounts
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts">
|
||||
insert into tb_split_accounts (id, merchant_id, shop_id,
|
||||
coupons_price, conpons_amount, is_split,
|
||||
order_amount, create_time, split_time,
|
||||
trade_day,origin_amount)
|
||||
values (#{id,jdbcType=INTEGER}, #{merchantId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER},
|
||||
#{couponsPrice,jdbcType=DECIMAL}, #{conponsAmount,jdbcType=DECIMAL}, #{isSplit,jdbcType=VARCHAR},
|
||||
#{orderAmount,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{splitTime,jdbcType=TIMESTAMP},
|
||||
#{tradeDay,jdbcType=VARCHAR},#{originAmount,jdbcType=DECIMAL})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts">
|
||||
insert into tb_split_accounts
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="merchantId != null">
|
||||
merchant_id,
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id,
|
||||
</if>
|
||||
<if test="couponsPrice != null">
|
||||
coupons_price,
|
||||
</if>
|
||||
<if test="conponsAmount != null">
|
||||
conpons_amount,
|
||||
</if>
|
||||
<if test="isSplit != null">
|
||||
is_split,
|
||||
</if>
|
||||
<if test="orderAmount != null">
|
||||
order_amount,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="splitTime != null">
|
||||
split_time,
|
||||
</if>
|
||||
<if test="tradeDay != null">
|
||||
trade_day,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="merchantId != null">
|
||||
#{merchantId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
#{shopId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="couponsPrice != null">
|
||||
#{couponsPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="conponsAmount != null">
|
||||
#{conponsAmount,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="isSplit != null">
|
||||
#{isSplit,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="orderAmount != null">
|
||||
#{orderAmount,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="splitTime != null">
|
||||
#{splitTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="tradeDay != null">
|
||||
#{tradeDay,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts">
|
||||
update tb_split_accounts
|
||||
<set>
|
||||
<if test="merchantId != null">
|
||||
merchant_id = #{merchantId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="couponsPrice != null">
|
||||
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="conponsAmount != null">
|
||||
conpons_amount = #{conponsAmount,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="isSplit != null">
|
||||
is_split = #{isSplit,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="orderAmount != null">
|
||||
order_amount = #{orderAmount,jdbcType=DECIMAL},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="splitTime != null">
|
||||
split_time = #{splitTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
<if test="tradeDay != null">
|
||||
trade_day = #{tradeDay,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts">
|
||||
update tb_split_accounts
|
||||
set merchant_id = #{merchantId,jdbcType=INTEGER},
|
||||
shop_id = #{shopId,jdbcType=INTEGER},
|
||||
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
|
||||
conpons_amount = #{conponsAmount,jdbcType=DECIMAL},
|
||||
is_split = #{isSplit,jdbcType=VARCHAR},
|
||||
order_amount = #{orderAmount,jdbcType=DECIMAL},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
split_time = #{splitTime,jdbcType=TIMESTAMP},
|
||||
trade_day = #{tradeDay,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue