提交更新
This commit is contained in:
parent
c8f9a9237c
commit
0ca8a9f9db
|
@ -332,10 +332,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
* 获取下一个周一
|
||||
*/
|
||||
public static LocalDateTime nextMonday(LocalDateTime time) {
|
||||
LocalDateTime result;
|
||||
|
||||
if (time.getDayOfWeek() == DayOfWeek.MONDAY) {
|
||||
return time.plusDays(7);
|
||||
result = time.plusDays(7);
|
||||
} else {
|
||||
return time.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
|
||||
result = time.with(TemporalAdjusters.next(DayOfWeek.MONDAY));
|
||||
}
|
||||
|
||||
return result.withHour(0).withMinute(0).withSecond(0).withNano(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sb.payed_amount,
|
||||
sb.wait_amount,
|
||||
sb.to_balance,
|
||||
sb.by_hand
|
||||
sb.by_hand,
|
||||
sb.bst_type
|
||||
<include refid="searchTables"/>
|
||||
</sql>
|
||||
|
||||
|
@ -53,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.prePayTimeEnd != null "> and sb.pre_pay_time <= #{query.prePayTimeEnd}</if>
|
||||
<if test="query.toBalance != null "> and sb.to_balance = #{query.toBalance}</if>
|
||||
<if test="query.byHand != null "> and sb.by_hand = #{query.byHand}</if>
|
||||
<if test="query.bstType != null "> and sb.bst_type = #{query.bstType}</if>
|
||||
<if test="query.payDate != null "> and date(sb.pay_time) = #{query.payDate}</if>
|
||||
<if test="query.hasRefund != null ">
|
||||
<if test="query.hasRefund">
|
||||
|
@ -261,6 +263,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="waitAmount != null">wait_amount,</if>
|
||||
<if test="toBalance != null">to_balance,</if>
|
||||
<if test="byHand != null">by_hand,</if>
|
||||
<if test="bstType != null and bstType != ''">bst_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="billId != null">#{billId},</if>
|
||||
|
@ -281,6 +284,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="waitAmount != null">#{waitAmount},</if>
|
||||
<if test="toBalance != null">#{toBalance},</if>
|
||||
<if test="byHand != null">#{byHand},</if>
|
||||
<if test="bstType != null and bstType != ''">#{bstType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -302,7 +306,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
pre_pay_time,
|
||||
payed_amount,
|
||||
wait_amount,
|
||||
to_balance
|
||||
to_balance,
|
||||
bst_type
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
|
@ -341,6 +346,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="i.waitAmount == null">default,</if>
|
||||
<if test="i.toBalance != null">#{i.toBalance},</if>
|
||||
<if test="i.toBalance == null">default,</if>
|
||||
<if test="i.bstType != null and i.bstType != ''">#{i.bstType},</if>
|
||||
<if test="i.bstType == null or i.bstType == ''">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -454,6 +461,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.waitAmount != null">wait_amount = #{data.waitAmount},</if>
|
||||
<if test="data.toBalance != null">to_balance = #{data.toBalance},</if>
|
||||
<if test="data.byHand != null">by_hand = #{data.byHand},</if>
|
||||
<if test="data.bstType != null">bst_type = #{data.bstType},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteBonusById" parameterType="Long">
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.ruoyi.ss.bonus.domain.Bonus;
|
|||
import com.ruoyi.ss.bonus.domain.BonusProvideQuery;
|
||||
import com.ruoyi.ss.bonus.domain.BonusQuery;
|
||||
import com.ruoyi.ss.bonus.domain.BonusVO;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusBstType;
|
||||
import com.ruoyi.ss.bonus.domain.vo.BonusDailyAmountVO;
|
||||
import com.ruoyi.ss.bonus.domain.vo.BonusMonthAmountVO;
|
||||
import com.ruoyi.ss.bonus.domain.vo.ProvideBonusVO;
|
||||
|
@ -172,4 +173,9 @@ public interface BonusService
|
|||
* 扣减分成方余额
|
||||
*/
|
||||
int subtractBalance(Long id, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 查询分成明细
|
||||
*/
|
||||
List<BonusVO> selectBonusByBstId(BonusBstType bstType, Long bstId);
|
||||
}
|
||||
|
|
|
@ -250,6 +250,9 @@ public class BonusConverterImpl implements BonusConverter {
|
|||
if (dept == null) {
|
||||
return null;
|
||||
}
|
||||
if (point == null) {
|
||||
point = BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
Bonus po = new Bonus();
|
||||
po.setStatus(BonusStatus.UN_DIVIDEND.getStatus());
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.ruoyi.ss.bonus.domain.BonusProvideQuery;
|
|||
import com.ruoyi.ss.bonus.domain.BonusQuery;
|
||||
import com.ruoyi.ss.bonus.domain.BonusVO;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusBstType;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusStatus;
|
||||
import com.ruoyi.ss.bonus.domain.vo.BonusDailyAmountVO;
|
||||
import com.ruoyi.ss.bonus.domain.vo.BonusMonthAmountVO;
|
||||
|
@ -36,6 +37,7 @@ import java.math.BigDecimal;
|
|||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -166,7 +168,8 @@ public class BonusServiceImpl implements BonusService
|
|||
// 若需要打款到余额,根据类型,添加金额
|
||||
if (bonus.getToBalance() != null && bonus.getToBalance()) {
|
||||
if (BonusArrivalType.userList().contains(bonus.getArrivalType())) {
|
||||
int add = userService.addBalance(bonus.getArrivalId(), bonus.getWaitAmount(), String.format("订单分成:%s", bonus.getBillNo()), RecordBalanceBstType.RECHARGE, bonus.getBillId());
|
||||
String reason = this.getReason(bonus.getBstType(), bonus.getBillNo());
|
||||
int add = userService.addBalance(bonus.getArrivalId(), bonus.getWaitAmount(), reason, RecordBalanceBstType.RECHARGE, bonus.getBillId());
|
||||
ServiceUtil.assertion(add != 1, "增加账户金额失败");
|
||||
} else if (BonusArrivalType.deptList().contains(bonus.getArrivalType())) {
|
||||
// add = deptService.addBalance(bonus.getArrivalId(), bonus.getAmount(), String.format("订单分成:%s", bonus.getBillNo()), RecordBalanceBstType.RECHARGE, bonus.getBillId());
|
||||
|
@ -179,6 +182,16 @@ public class BonusServiceImpl implements BonusService
|
|||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
// 获取打款理由
|
||||
private String getReason(String bstType, String billNo) {
|
||||
if (BonusBstType.RECHARGE.getType().equals(bstType)) {
|
||||
return String.format("充值订单分成:%s", billNo);
|
||||
} else if (BonusBstType.VIP.getType().equals(bstType)) {
|
||||
return String.format("VIP订单分成:%s", billNo);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partBonus(List<Bonus> bonusList, BigDecimal money) {
|
||||
if (CollectionUtils.isEmptyElement(bonusList) || money == null) {
|
||||
|
@ -426,6 +439,17 @@ public class BonusServiceImpl implements BonusService
|
|||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BonusVO> selectBonusByBstId(BonusBstType bstType, Long bstId) {
|
||||
if (bstType == null || bstId == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
BonusQuery query = new BonusQuery();
|
||||
query.setBstType(bstType.getType());
|
||||
query.setBillId(bstId);
|
||||
return this.selectBonusList(query);
|
||||
}
|
||||
|
||||
private int batchUpdateAmount(List<Bonus> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return 0;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.ruoyi.ss.payBill.interfaces.AfterPay;
|
|||
import com.ruoyi.ss.payBill.interfaces.AfterRefund;
|
||||
import com.ruoyi.ss.transactionBill.service.impl.RechargeDepositAfterPay;
|
||||
import com.ruoyi.ss.transactionBill.service.impl.RechargePayHandler;
|
||||
import com.ruoyi.ss.vipOrder.service.impl.VipOrderServiceImpl;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
@ -23,7 +24,7 @@ public enum PayBillBstType {
|
|||
ELECTRICITY_RECHARGE("2", "电量充值订单", null, null),
|
||||
RECHARGE_ORDER("4", "充值订单", RechargePayHandler.class, RechargePayHandler.class),
|
||||
RECHARGE_ORDER_DEPOSIT("5", "充值订单押金", RechargeDepositAfterPay.class, null),
|
||||
VIP_ORDER("6", "VIP订单", null, null);
|
||||
VIP_ORDER("6", "VIP订单", VipOrderServiceImpl.class, VipOrderServiceImpl.class);
|
||||
|
||||
private final String type;
|
||||
private final String msg;
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.ruoyi.ss.payBill.domain.PayBill;
|
|||
import com.ruoyi.ss.payBill.domain.PayBillQuery;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.domain.dto.PayBillRefundDTO;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillBstType;
|
||||
import com.ruoyi.ss.payBill.domain.vo.DoPayVO;
|
||||
import com.ruoyi.ss.payBill.domain.vo.PayResultVO;
|
||||
import com.ruoyi.ss.refund.domain.RefundVO;
|
||||
|
@ -145,4 +146,9 @@ public interface PayBillService
|
|||
* 按日查询支付金额
|
||||
*/
|
||||
List<LocalDateDecimalVO> selectDailyAmount(PayBillQuery query);
|
||||
|
||||
/**
|
||||
* 刷新支付结果
|
||||
*/
|
||||
public int refreshPayResult(PayBillBstType bstType, Long bstId);
|
||||
}
|
||||
|
|
|
@ -394,6 +394,15 @@ public class PayBillServiceImpl implements PayBillService
|
|||
return this.refreshPayResult(Collections.singletonList(payBill));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int refreshPayResult(PayBillBstType bstType, Long bstId) {
|
||||
if (bstType == null || bstId == null) {
|
||||
return 0;
|
||||
}
|
||||
List<PayBillVO> payList = this.selectByBstId(bstId, bstType.getType());
|
||||
return this.refreshPayResult(payList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int refund(PayBillRefundDTO dto) {
|
||||
// 校验订单
|
||||
|
|
|
@ -1654,7 +1654,9 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
|
|||
return 0;
|
||||
}
|
||||
|
||||
// 构建退款列表
|
||||
// FIXME 构建退款列表
|
||||
// FIXME 多次退款有问题,比如商户已经退款0.3元,剩余0.2元,第二次退款的时候,还是给商户分配了0.3元的退款,此时退款会失败。
|
||||
// FIXME 需要重新考虑一下退款金额的分配规则。
|
||||
List<Bonus> refundList = new ArrayList<>(); // 退款的列表
|
||||
BigDecimal dividedAmount = BigDecimal.ZERO; // 已分配金额
|
||||
for (BonusVO bonus : bonusList) {
|
||||
|
|
|
@ -77,4 +77,7 @@ public class Vip extends BaseEntity
|
|||
@ApiModelProperty("限制次数")
|
||||
private Integer limitCount;
|
||||
|
||||
@Excel(name = "总剩余次数")
|
||||
@ApiModelProperty("总剩余次数")
|
||||
private Integer surplusCount;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package com.ruoyi.ss.vip.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.ss.store.domain.StoreVo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -26,6 +22,13 @@ public class VipVO extends Vip{
|
|||
@ApiModelProperty("VIP商户ID")
|
||||
private Long vipMchId;
|
||||
|
||||
@ApiModelProperty("店铺列表")
|
||||
private List<StoreVo> storeList;
|
||||
@ApiModelProperty("店铺名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty("商户名称")
|
||||
private String mchName;
|
||||
|
||||
@ApiModelProperty("是否在有效期内")
|
||||
private Boolean inValid;
|
||||
|
||||
}
|
||||
|
|
|
@ -71,5 +71,10 @@ public interface VipMapper
|
|||
/**
|
||||
* 续费
|
||||
*/
|
||||
int renewal(@Param("id")Long id, @Param("days") Integer days);
|
||||
int renewal(@Param("id")Long id, @Param("days") Integer days, @Param("count") Integer count);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*/
|
||||
int logicDel(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<resultMap type="VipVO" id="VipResult" autoMapping="true"/>
|
||||
|
||||
<!-- 是否在有效期内 -->
|
||||
<sql id="inValid">
|
||||
(sv.start_time <= now() and sv.end_time >= now())
|
||||
</sql>
|
||||
|
||||
<sql id="selectVipVo">
|
||||
select
|
||||
sv.id,
|
||||
|
@ -21,12 +26,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sv.round_count,
|
||||
sv.limit_type,
|
||||
sv.limit_count,
|
||||
sv.surplus_count,
|
||||
sv.deleted,
|
||||
<include refid="inValid"/> as in_valid,
|
||||
if(su.is_real, su.real_name, su.user_name) as user_name,
|
||||
svl.name as vip_level_name,
|
||||
svl.mch_id as vip_mch_id
|
||||
svl.mch_id as vip_mch_id,
|
||||
ss.user_id as store_mch_id,
|
||||
ss.name as store_name,
|
||||
if(mch.is_real, mch.real_name, mch.user_name) as mch_name
|
||||
from ss_vip sv
|
||||
left join sm_user su on su.user_id = sv.user_id
|
||||
left join ss_vip_level svl on svl.id = sv.level_id
|
||||
left join sm_store ss on ss.store_id = svl.store_id
|
||||
left join sm_user mch on mch.user_id = svl.mch_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
|
@ -36,12 +49,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.startTime != null "> and sv.start_time = #{query.startTime}</if>
|
||||
<if test="query.endTime != null "> and sv.end_time = #{query.endTime}</if>
|
||||
<if test="query.discount != null "> and sv.discount = #{query.discount}</if>
|
||||
<if test="query.storeId != null and query.storeId != ''"> and sv.store_id = #{query.storeId}</if>
|
||||
<if test="query.storeId != null"> and sv.store_id = #{query.storeId}</if>
|
||||
<if test="query.storeName != null and query.storeName != ''">and ss.name like concat('%',#{query.storeName},'%')</if>
|
||||
<if test="query.userName != null and query.userName != ''">and if(su.is_real, su.real_name, su.user_name) like concat('%',#{query.userName},'%')</if>
|
||||
<if test="query.mchName != null and query.mchName != ''">and if(mch.is_real, mch.real_name, mch.user_name) like concat('%',#{query.mchName},'%')</if>
|
||||
<if test="query.vipLevelName != null and query.vipLevelName != ''">and svl.name like concat('%',#{query.vipLevelName},'%')</if>
|
||||
<if test="query.limitType != null and query.limitType != ''"> and limit_type = #{query.limitType}</if>
|
||||
<if test="query.limitCount != null "> and limit_count = #{query.limitCount}</if>
|
||||
<if test="query.excludeId != null">and sv.id != #{query.excludeId}</if>
|
||||
<if test="query.deleted != null">and sv.deleted = #{query.deleted}</if>
|
||||
<if test="query.deleted == null">and sv.deleted = false</if>
|
||||
<if test="query.inValid != null">
|
||||
and
|
||||
<if test="!query.inValid">
|
||||
not
|
||||
</if>
|
||||
<include refid="inValid"/>
|
||||
</if>
|
||||
<if test="query.vipLevelIds != null and query.vipLevelIds.size() > 0">
|
||||
and sv.level_id in
|
||||
<foreach collection="query.vipLevelIds" item="item" open="(" close=")" separator=",">
|
||||
|
@ -79,12 +103,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="startTime != null">start_time,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
<if test="discount != null">discount,</if>
|
||||
<if test="storeId != null and storeId.size() > 0">store_id,</if>
|
||||
<if test="storeId != null">store_id,</if>
|
||||
<if test="nextResetTime != null">next_reset_time,</if>
|
||||
<if test="totalCount != null">total_count,</if>
|
||||
<if test="roundCount != null">round_count,</if>
|
||||
<if test="limitType != null and limitType != ''">limit_type,</if>
|
||||
<if test="limitCount != null">limit_count,</if>
|
||||
<if test="surplusCount != null">surplus_count,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
|
@ -93,12 +118,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
<if test="discount != null">#{discount},</if>
|
||||
<if test="storeId != null and storeId.size() > 0">#{storeId},</if>
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
<if test="nextResetTime != null">#{nextResetTime},</if>
|
||||
<if test="totalCount != null">#{totalCount},</if>
|
||||
<if test="roundCount != null">#{roundCount},</if>
|
||||
<if test="limitType != null and limitType != ''">#{limitType},</if>
|
||||
<if test="limitCount != null">#{limitCount},</if>
|
||||
<if test="surplusCount != null">#{surplusCount},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -111,9 +137,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
|
||||
<update id="renewal">
|
||||
update ss_vip
|
||||
set end_time = date_add(if(now() > end_time, now(), end_time), interval #{days} day)
|
||||
where id = #{id}
|
||||
update ss_vip sv
|
||||
set sv.end_time = date_add(if(now() > sv.end_time, now(), sv.end_time), interval #{days} day),
|
||||
sv.surplus_count = if (now() <= sv.end_time, sv.surplus_count + #{count}, #{count})
|
||||
where sv.id = #{id}
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
|
@ -123,12 +150,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.startTime != null">start_time = #{data.startTime},</if>
|
||||
<if test="data.endTime != null">end_time = #{data.endTime},</if>
|
||||
<if test="data.discount != null">discount = #{data.discount},</if>
|
||||
<if test="data.storeId != null and data.storeId.size() > 0">store_id = #{data.storeId},</if>
|
||||
<if test="data.storeId != null">store_id = #{data.storeId},</if>
|
||||
<if test="data.nextResetTime != null">next_reset_time = #{data.nextResetTime},</if>
|
||||
<if test="data.totalCount != null">total_count = #{data.totalCount},</if>
|
||||
<if test="data.roundCount != null">round_count = #{data.roundCount},</if>
|
||||
<if test="data.limitType != null and data.limitType != ''">limit_type = #{data.limitType},</if>
|
||||
<if test="data.limitCount != null">limit_count = #{data.limitCount},</if>
|
||||
<if test="data.surplusCount != null">surplus_count = #{data.surplusCount},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteVipById" parameterType="Long">
|
||||
|
@ -141,4 +169,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- logicDel -->
|
||||
|
||||
<update id="logicDel">
|
||||
update ss_vip
|
||||
set deleted = true
|
||||
where id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and deleted = false
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -12,4 +12,9 @@ public interface VipConverter {
|
|||
* 订单转会员
|
||||
*/
|
||||
Vip toPo(VipOrderVO order);
|
||||
|
||||
/**
|
||||
* 新增会员
|
||||
*/
|
||||
Vip toPoByAdd(Vip data);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,16 @@ public interface VipService
|
|||
|
||||
/**
|
||||
* 续费 VIP
|
||||
* @param id VIP ID
|
||||
* @param days 续费天数
|
||||
* @param count 可用次数(叠加)
|
||||
*/
|
||||
int renewal(Long id, Integer days);
|
||||
int renewal(Long id, Integer days, Integer count);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int logicDel(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@ package com.ruoyi.ss.vip.service.impl;
|
|||
import com.ruoyi.ss.vip.domain.Vip;
|
||||
import com.ruoyi.ss.vip.service.VipConverter;
|
||||
import com.ruoyi.ss.vip.utils.VipUtil;
|
||||
import com.ruoyi.ss.vipLevel.domain.VipLevel;
|
||||
import com.ruoyi.ss.vipLevel.service.VipLevelService;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -14,6 +17,10 @@ import java.time.LocalDateTime;
|
|||
*/
|
||||
@Service
|
||||
public class VipConverterImpl implements VipConverter {
|
||||
|
||||
@Autowired
|
||||
private VipLevelService vipLevelService;
|
||||
|
||||
@Override
|
||||
public Vip toPo(VipOrderVO order) {
|
||||
if (order == null) {
|
||||
|
@ -31,8 +38,40 @@ public class VipConverterImpl implements VipConverter {
|
|||
vip.setRoundCount(0);
|
||||
vip.setLimitType(order.getSkuLimitType());
|
||||
vip.setLimitCount(order.getSkuLimitCount());
|
||||
vip.setSurplusCount(order.getSkuLimitTotal());
|
||||
vip.setNextResetTime(VipUtil.getNextResetTime(LocalDateTime.now(), order.getSkuLimitType()));
|
||||
|
||||
return vip;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vip toPoByAdd(Vip data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
VipLevel level = vipLevelService.selectVipLevelById(data.getLevelId());
|
||||
if(level == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Vip vip = new Vip();
|
||||
// 自定义数据
|
||||
vip.setUserId(data.getUserId());
|
||||
vip.setStartTime(data.getStartTime());
|
||||
vip.setEndTime(data.getEndTime());
|
||||
vip.setLimitType(data.getLimitType());
|
||||
vip.setNextResetTime(VipUtil.getNextResetTime(LocalDateTime.now(), data.getLimitType()));
|
||||
vip.setTotalCount(0);
|
||||
vip.setRoundCount(0);
|
||||
vip.setLimitCount(data.getLimitCount());
|
||||
vip.setSurplusCount(data.getSurplusCount());
|
||||
|
||||
// 等级数据
|
||||
vip.setLevelId(level.getId());
|
||||
vip.setDiscount(level.getDiscount());
|
||||
vip.setStoreId(level.getStoreId());
|
||||
return vip;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,15 +144,16 @@ public class VipServiceImpl implements VipService
|
|||
query.setStoreId(storeId);
|
||||
query.setLimitType(limitType);
|
||||
query.setLimitCount(limitCount);
|
||||
query.setInValid(true);
|
||||
return selectOne(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int renewal(Long id, Integer days) {
|
||||
public int renewal(Long id, Integer days, Integer count) {
|
||||
if (id == null || days == null || days < 0) {
|
||||
return 0;
|
||||
}
|
||||
return vipMapper.renewal(id, days);
|
||||
return vipMapper.renewal(id, days, count);
|
||||
}
|
||||
|
||||
private VipVO selectOne(VipQuery query) {
|
||||
|
@ -160,4 +161,12 @@ public class VipServiceImpl implements VipService
|
|||
List<VipVO> vipList = selectVipList(query);
|
||||
return CollectionUtils.getFirst(vipList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int logicDel(List<Long> ids) {
|
||||
if (CollectionUtils.isEmptyElement(ids)) {
|
||||
return 0;
|
||||
}
|
||||
return vipMapper.logicDel(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package com.ruoyi.ss.vip.service.impl;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.store.service.StoreValidator;
|
||||
import com.ruoyi.ss.user.service.UserValidator;
|
||||
|
@ -13,6 +8,10 @@ import com.ruoyi.ss.vip.domain.VipQuery;
|
|||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import com.ruoyi.ss.vip.service.VipValidator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
|
@ -48,7 +47,7 @@ public class VipValidatorImpl implements VipValidator {
|
|||
return;
|
||||
}
|
||||
|
||||
this.checkMch(vo.getStoreMchId(), vo.getVipMchId());
|
||||
ServiceUtil.assertion(!Objects.equals(vo.getStoreMchId(), vo.getVipMchId()), "当前VIP等级与店铺商户不一致");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,10 +55,6 @@ public class VipValidatorImpl implements VipValidator {
|
|||
return vo != null && userId != null && Objects.equals(vo.getStoreMchId(), userId);
|
||||
}
|
||||
|
||||
private void checkMch(Long storeMchId, Long vipMchId) {
|
||||
ServiceUtil.assertion(!Objects.equals(storeMchId, vipMchId), "当前选择的VIP等级与店铺商户不一致");
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否重复成为店铺会员
|
||||
* @param id 会员ID
|
||||
|
|
|
@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="discount != null">#{discount},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="storeId != null and storeId.size() > 0">#{storeId},</if>
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.discount != null">discount = #{data.discount},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.description != null">`description` = #{data.description},</if>
|
||||
<if test="data.storeId != null and data.storeId.size() > 0">store_id = #{data.storeId},</if>
|
||||
<if test="data.storeId != null">store_id = #{data.storeId},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteVipLevelById" parameterType="Long">
|
||||
|
|
|
@ -8,7 +8,9 @@ import com.ruoyi.system.valid.DictValid;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
@ -65,4 +67,9 @@ public class VipLevelSku extends BaseEntity
|
|||
@ApiModelProperty("原价")
|
||||
private BigDecimal originalPrice;
|
||||
|
||||
@Excel(name = "限制总次数")
|
||||
@ApiModelProperty("限制总次数")
|
||||
@Min(value = 0, message = "限制总次数不允许小于0")
|
||||
@NotNull(message = "限制总次数不允许为空", groups = {ValidGroup.Create.class})
|
||||
private Integer limitTotal;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
svls.limit_count,
|
||||
svls.status,
|
||||
svls.name,
|
||||
svls.original_price
|
||||
svls.original_price,
|
||||
svls.limit_total
|
||||
from ss_vip_level_sku svls
|
||||
</sql>
|
||||
|
||||
|
@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">`status`,</if>
|
||||
<if test="name != null and name != ''">`name`,</if>
|
||||
<if test="originalPrice != null">original_price,</if>
|
||||
<if test="limitTotal != null">limit_total,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
|
@ -81,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="name != null and name != ''">#{name},</if>
|
||||
<if test="originalPrice != null">#{originalPrice},</if>
|
||||
<if test="limitTotal != null">#{limitTotal},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -98,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
`status`,
|
||||
`name`,
|
||||
original_price,
|
||||
limit_total,
|
||||
</trim>
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
|
@ -124,6 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="i.name == null or i.name == ''">default,</if>
|
||||
<if test="i.originalPrice != null ">#{i.originalPrice},</if>
|
||||
<if test="i.originalPrice == null ">default,</if>
|
||||
<if test="i.limitTotal != null ">#{i.limitTotal},</if>
|
||||
<if test="i.limitTotal == null ">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@ -241,6 +247,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="limit_total = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.limitTotal != null ">
|
||||
WHEN #{item.id} THEN #{item.limitTotal}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `limit_total`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
where id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
|
@ -268,6 +284,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
|
||||
<if test="data.name != null and data.name != ''">`name` = #{data.name},</if>
|
||||
<if test="data.originalPrice != null">original_price = #{data.originalPrice},</if>
|
||||
<if test="data.limitTotal != null">limit_total = #{data.limitTotal},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteVipLevelSkuById" parameterType="Long">
|
||||
|
|
|
@ -78,6 +78,10 @@ public class VipOrder extends BaseEntity
|
|||
@ApiModelProperty("sku限制次数")
|
||||
private Integer skuLimitCount;
|
||||
|
||||
@Excel(name = "sku总限制次数")
|
||||
@ApiModelProperty("sku总限制次数")
|
||||
private Integer skuLimitTotal;
|
||||
|
||||
@Excel(name = "实付金额")
|
||||
@ApiModelProperty("实付金额")
|
||||
private BigDecimal amount;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.ss.vipOrder.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
@ -8,4 +9,7 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class VipOrderQuery extends VipOrderVO{
|
||||
|
||||
@ApiModelProperty("精准订单号")
|
||||
private String eqOrderNo;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
@ -37,13 +38,17 @@ public class AddPayVipOrderDTO {
|
|||
private BigDecimal skuPrice;
|
||||
|
||||
@ApiModelProperty("sku限制类型")
|
||||
@NotNull(message = "sku限制类型不能为空")
|
||||
@NotBlank(message = "sku限制类型不能为空")
|
||||
private String skuLimitType;
|
||||
|
||||
@ApiModelProperty("sku限制次数")
|
||||
@NotNull(message = "sku限制次数不能为空")
|
||||
private Integer skuLimitCount;
|
||||
|
||||
@ApiModelProperty("sku总限制次数")
|
||||
@NotNull(message = "sku总限制次数不能为空")
|
||||
private Integer skuLimitTotal;
|
||||
|
||||
@ApiModelProperty("VIP等级折扣")
|
||||
@NotNull(message = "VIP等级折扣不能为空")
|
||||
private BigDecimal levelDiscount;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.ss.vipOrder.domain.vo;
|
||||
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrder;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -11,8 +10,11 @@ import lombok.Data;
|
|||
@Data
|
||||
public class AddAndPayVO {
|
||||
|
||||
@ApiModelProperty("订单数据")
|
||||
private VipOrder order;
|
||||
@ApiModelProperty("订单编号")
|
||||
private String orderNo;
|
||||
|
||||
@ApiModelProperty("支付订单编号")
|
||||
private String payNo;
|
||||
|
||||
@ApiModelProperty("支付参数")
|
||||
private Object payParams;
|
||||
|
|
|
@ -4,9 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.vipOrder.mapper.VipOrderMapper">
|
||||
|
||||
<resultMap type="VipOrderVO" id="VipOrderResult" autoMapping="true">
|
||||
<result property="levelStoreId" column="level_store_id" typeHandler="com.ruoyi.system.mapper.typehandler.LongSplitListTypeHandler"/>
|
||||
</resultMap>
|
||||
<resultMap type="VipOrderVO" id="VipOrderResult" autoMapping="true"/>
|
||||
|
||||
<sql id="selectVipOrderVo">
|
||||
select
|
||||
|
@ -25,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
svo.sku_price,
|
||||
svo.sku_limit_type,
|
||||
svo.sku_limit_count,
|
||||
svo.sku_limit_total,
|
||||
svo.amount,
|
||||
svo.expire_time,
|
||||
svo.pay_id,
|
||||
|
@ -47,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="searchCondition">
|
||||
<if test="query.id != null "> and svo.id = #{query.id}</if>
|
||||
<if test="query.orderNo != null and query.orderNo != ''"> and svo.order_no like concat('%', #{query.orderNo}, '%')</if>
|
||||
<if test="query.eqOrderNo != null and query.eqOrderNo != ''"> and svo.order_no = #{query.eqOrderNo}</if>
|
||||
<if test="query.userId != null "> and svo.user_id = #{query.userId}</if>
|
||||
<if test="query.mchId != null "> and svo.mch_id = #{query.mchId}</if>
|
||||
<if test="query.levelId != null "> and svo.level_id = #{query.levelId}</if>
|
||||
|
@ -87,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="levelId != null">level_id,</if>
|
||||
<if test="levelName != null and levelName != ''">level_name,</if>
|
||||
<if test="levelDiscount != null">level_discount,</if>
|
||||
<if test="levelStoreId != null and levelStoreId != ''">level_store_id,</if>
|
||||
<if test="levelStoreId != null">level_store_id,</if>
|
||||
<if test="levelSolution != null and levelSolution != ''">level_solution,</if>
|
||||
<if test="skuId != null">sku_id,</if>
|
||||
<if test="skuName != null and skuName != ''">sku_name,</if>
|
||||
|
@ -95,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="skuPrice != null">sku_price,</if>
|
||||
<if test="skuLimitType != null and skuLimitType != ''">sku_limit_type,</if>
|
||||
<if test="skuLimitCount != null">sku_limit_count,</if>
|
||||
<if test="skuLimitTotal != null">sku_limit_total,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="expireTime != null">expire_time,</if>
|
||||
<if test="payId != null">pay_id,</if>
|
||||
|
@ -118,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="levelId != null">#{levelId},</if>
|
||||
<if test="levelName != null and levelName != ''">#{levelName},</if>
|
||||
<if test="levelDiscount != null">#{levelDiscount},</if>
|
||||
<if test="levelStoreId != null and levelStoreId != ''">#{levelStoreId},</if>
|
||||
<if test="levelStoreId != null">#{levelStoreId},</if>
|
||||
<if test="levelSolution != null and levelSolution != ''">#{levelSolution},</if>
|
||||
<if test="skuId != null">#{skuId},</if>
|
||||
<if test="skuName != null and skuName != ''">#{skuName},</if>
|
||||
|
@ -126,6 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="skuPrice != null">#{skuPrice},</if>
|
||||
<if test="skuLimitType != null and skuLimitType != ''">#{skuLimitType},</if>
|
||||
<if test="skuLimitCount != null">#{skuLimitCount},</if>
|
||||
<if test="skuLimitTotal != null">#{skuLimitTotal},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="expireTime != null">#{expireTime},</if>
|
||||
<if test="payId != null">#{payId},</if>
|
||||
|
@ -169,7 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.levelId != null">svo.level_id = #{data.levelId},</if>
|
||||
<if test="data.levelName != null and data.levelName != ''">svo.level_name = #{data.levelName},</if>
|
||||
<if test="data.levelDiscount != null">svo.level_discount = #{data.levelDiscount},</if>
|
||||
<if test="data.levelStoreId != null and data.levelStoreId != ''">svo.level_store_id = #{data.levelStoreId},</if>
|
||||
<if test="data.levelStoreId != null">svo.level_store_id = #{data.levelStoreId},</if>
|
||||
<if test="data.levelSolution != null and data.levelSolution != ''">svo.level_solution = #{data.levelSolution},</if>
|
||||
<if test="data.skuId != null">svo.sku_id = #{data.skuId},</if>
|
||||
<if test="data.skuName != null and data.skuName != ''">svo.sku_name = #{data.skuName},</if>
|
||||
|
@ -177,6 +179,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.skuPrice != null">svo.sku_price = #{data.skuPrice},</if>
|
||||
<if test="data.skuLimitType != null and data.skuLimitType != ''">svo.sku_limit_type = #{data.skuLimitType},</if>
|
||||
<if test="data.skuLimitCount != null">svo.sku_limit_count = #{data.skuLimitCount},</if>
|
||||
<if test="data.skuLimitTotal != null">svo.sku_limit_total = #{data.skuLimitTotal},</if>
|
||||
<if test="data.amount != null">svo.amount = #{data.amount},</if>
|
||||
<if test="data.expireTime != null">svo.expire_time = #{data.expireTime},</if>
|
||||
<if test="data.payId != null">svo.pay_id = #{data.payId},</if>
|
||||
|
|
|
@ -68,4 +68,14 @@ public interface VipOrderService
|
|||
* 下单并支付
|
||||
*/
|
||||
AddAndPayVO addAndPay(AddPayVipOrderBO bo);
|
||||
|
||||
/**
|
||||
* 刷新支付结果
|
||||
*/
|
||||
int refreshPayResult(Long id);
|
||||
|
||||
/**
|
||||
* 刷新支付结果
|
||||
*/
|
||||
int refreshPayResult(String orderNo);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.ss.vipOrder.service;
|
||||
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderVO;
|
||||
import com.ruoyi.ss.vipOrder.domain.bo.AddPayVipOrderBO;
|
||||
|
||||
/**
|
||||
|
@ -12,4 +13,9 @@ public interface VipOrderValidator {
|
|||
* 下单并支付校验
|
||||
*/
|
||||
void preAddAndPay(AddPayVipOrderBO bo);
|
||||
|
||||
/**
|
||||
* 判断用户是否可以查看订单
|
||||
*/
|
||||
boolean canView(VipOrderVO order, Long userId);
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ public class VipOrderConverterImpl implements VipOrderConverter {
|
|||
order.setSkuPrice(sku.getPrice());
|
||||
order.setSkuLimitType(sku.getLimitType());
|
||||
order.setSkuLimitCount(sku.getLimitCount());
|
||||
order.setSkuLimitTotal(sku.getLimitTotal());
|
||||
}
|
||||
// 渠道信息
|
||||
ChannelVO channel = bo.getChannel();
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
package com.ruoyi.ss.vipOrder.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.bonus.domain.Bonus;
|
||||
import com.ruoyi.ss.bonus.service.BonusConverter;
|
||||
import com.ruoyi.ss.bonus.service.BonusService;
|
||||
import com.ruoyi.ss.payBill.domain.PayBill;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.domain.bo.RefundSuccessBO;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillBstType;
|
||||
import com.ruoyi.ss.payBill.domain.vo.DoPayVO;
|
||||
import com.ruoyi.ss.payBill.interfaces.AfterPay;
|
||||
import com.ruoyi.ss.payBill.interfaces.AfterRefund;
|
||||
|
@ -165,8 +169,6 @@ public class VipOrderServiceImpl implements VipOrderService, AfterPay, AfterRefu
|
|||
// 转为订单数据
|
||||
VipOrder order = vipOrderConverter.toOrder(bo);
|
||||
ServiceUtil.assertion(order == null, "订单数据为空");
|
||||
// 订单数据加入结果集和上下文
|
||||
result.setOrder(order);
|
||||
bo.setOrder(order);
|
||||
|
||||
// 操作数据库
|
||||
|
@ -180,11 +182,20 @@ public class VipOrderServiceImpl implements VipOrderService, AfterPay, AfterRefu
|
|||
ServiceUtil.assertion(pay == null, "支付单数据为空");
|
||||
DoPayVO payResult = payBillService.createPayBill(pay);
|
||||
ServiceUtil.assertion(payResult == null, "调起支付失败");
|
||||
|
||||
// 构造结果集
|
||||
result.setPayParams(payResult.getPayParams());
|
||||
result.setPayNo(pay.getPayNo());
|
||||
result.setOrderNo(order.getOrderNo());
|
||||
|
||||
return insert;
|
||||
});
|
||||
|
||||
// TODO 模拟支付成功
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
payBillService.handleSuccess(result.getPayNo(), LocalDateTime.now());
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -248,7 +259,7 @@ public class VipOrderServiceImpl implements VipOrderService, AfterPay, AfterRefu
|
|||
);
|
||||
// 可兼容操作
|
||||
if (vip != null ) {
|
||||
int renewal = vipService.renewal(vip.getId(), order.getSkuTime());
|
||||
int renewal = vipService.renewal(vip.getId(), order.getSkuTime(), order.getSkuLimitTotal());
|
||||
ServiceUtil.assertion(renewal != 1, "续费ID为%s的VIP失败", vip.getId());
|
||||
return renewal;
|
||||
}
|
||||
|
@ -274,4 +285,38 @@ public class VipOrderServiceImpl implements VipOrderService, AfterPay, AfterRefu
|
|||
public int onRefundSuccess(RefundSuccessBO bo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int refreshPayResult(Long id) {
|
||||
if (id == null) {
|
||||
return 0;
|
||||
}
|
||||
return payBillService.refreshPayResult(PayBillBstType.VIP_ORDER, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int refreshPayResult(String orderNo) {
|
||||
if (StringUtils.isBlank(orderNo)) {
|
||||
return 0;
|
||||
}
|
||||
VipOrderVO order = selectVipOrderByOrderNo(orderNo);
|
||||
if (order == null || order.getId() == null) {
|
||||
return 0;
|
||||
}
|
||||
return payBillService.refreshPayResult(PayBillBstType.VIP_ORDER, order.getId());
|
||||
}
|
||||
|
||||
// 根据订单号查询订单
|
||||
private VipOrderVO selectVipOrderByOrderNo(String orderNo) {
|
||||
VipOrderQuery query = new VipOrderQuery();
|
||||
query.setEqOrderNo(orderNo);
|
||||
return this.selectOne(query);
|
||||
}
|
||||
|
||||
// 根据查询条件查询一个订单
|
||||
private VipOrderVO selectOne(VipOrderQuery query) {
|
||||
PageHelper.startPage(1, 1);
|
||||
List<VipOrderVO> list = this.selectVipOrderList(query);
|
||||
return CollectionUtils.firstElement(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,10 @@ package com.ruoyi.ss.vipOrder.service.impl;
|
|||
|
||||
import com.ruoyi.common.utils.MathUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.ss.bonus.domain.BonusVO;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusArrivalType;
|
||||
import com.ruoyi.ss.bonus.domain.enums.BonusBstType;
|
||||
import com.ruoyi.ss.bonus.service.BonusService;
|
||||
import com.ruoyi.ss.channel.domain.ChannelVO;
|
||||
import com.ruoyi.ss.user.domain.SmUserVO;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
|
@ -9,6 +13,7 @@ import com.ruoyi.ss.vip.service.VipService;
|
|||
import com.ruoyi.ss.vipLevel.domain.VipLevelVO;
|
||||
import com.ruoyi.ss.vipLevelSku.domain.VipLevelSkuVO;
|
||||
import com.ruoyi.ss.vipLevelSku.domain.enums.VipLevelSkuStatus;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderVO;
|
||||
import com.ruoyi.ss.vipOrder.domain.bo.AddPayVipOrderBO;
|
||||
import com.ruoyi.ss.vipOrder.domain.dto.AddPayVipOrderDTO;
|
||||
import com.ruoyi.ss.vipOrder.service.VipOrderValidator;
|
||||
|
@ -16,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +34,9 @@ public class VipOrderValidatorImpl implements VipOrderValidator {
|
|||
@Autowired
|
||||
private VipService vipService;
|
||||
|
||||
@Autowired
|
||||
private BonusService bonusService;
|
||||
|
||||
@Override
|
||||
public void preAddAndPay(AddPayVipOrderBO bo) {
|
||||
ServiceUtil.assertion(bo == null, "参数错误");
|
||||
|
@ -41,20 +50,21 @@ public class VipOrderValidatorImpl implements VipOrderValidator {
|
|||
|
||||
// 校验用户前端查看到的数据和后台数据是否一致
|
||||
ServiceUtil.assertion(sku == null, "ID为%sVIP等级价格不存在", dto.getSkuId());
|
||||
ServiceUtil.assertion(level == null, "的VIP等级不存在");
|
||||
ServiceUtil.assertion(level == null, "ID为%s的VIP等级不存在", sku.getLevelId());
|
||||
ServiceUtil.assertion(!VipLevelSkuStatus.ON_SALE.getStatus().equals(sku.getStatus()), "ID为%s的SKU目前不可购买", sku.getId());
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuLimitType(), sku.getLimitType()), "当前使用限制已发生变化,请重新下单");
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuLimitCount(), sku.getLimitCount()), "当前限制次数已发生变化,请重新下单");
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuLimitType(), sku.getLimitType()), "当前使用限制已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getSkuLimitType(), sku.getLimitType());
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuLimitCount(), sku.getLimitCount()), "当前限制次数已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getSkuLimitCount(), sku.getLimitCount());
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuLimitTotal(), sku.getLimitTotal()), "当前总限制次数已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getSkuLimitTotal(), sku.getLimitTotal());
|
||||
ServiceUtil.assertion(sku.getPrice() == null, "价格不允许为空,请重新下单");
|
||||
ServiceUtil.assertion(!MathUtils.equals(dto.getSkuPrice(), sku.getPrice()), "当前价格已发生变化,请重新下单");
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuTime(), sku.getTime()), "当前可购买的时长已发生变化,请重新下单");
|
||||
ServiceUtil.assertion(!MathUtils.equals(dto.getLevelDiscount(), level.getDiscount()), "当前折扣已发生变化,请重新下单");
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getLevelStoreId(), level.getStoreId()), "当前可用店铺已发生变化,请重新下单");
|
||||
ServiceUtil.assertion(!MathUtils.equals(dto.getSkuPrice(), sku.getPrice()), "当前价格已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getSkuPrice(), sku.getPrice());
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getSkuTime(), sku.getTime()), "当前可购买的时长已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getSkuTime(), sku.getTime());
|
||||
ServiceUtil.assertion(!MathUtils.equals(dto.getLevelDiscount(), level.getDiscount()), "当前折扣已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getLevelDiscount(), level.getDiscount());
|
||||
ServiceUtil.assertion(!Objects.equals(dto.getLevelStoreId(), level.getStoreId()), "当前可用店铺已发生变化,请重新下单。当前值:%s,最新值:%s", dto.getLevelStoreId(), level.getStoreId());
|
||||
|
||||
// 商户是否存在
|
||||
ServiceUtil.assertion(mch == null, "商户不存在");
|
||||
ServiceUtil.assertion(mch == null, "ID为%s的商户不存在", level.getMchId());
|
||||
// 用户是否存在
|
||||
ServiceUtil.assertion(user == null, "下单用户不存在");
|
||||
ServiceUtil.assertion(user == null, "当前下单用户不存在");
|
||||
|
||||
// 校验渠道是否可用
|
||||
ServiceUtil.assertion(channel == null, "ID为%s的支付渠道不存在", dto.getChannelId());
|
||||
|
@ -89,4 +99,38 @@ public class VipOrderValidatorImpl implements VipOrderValidator {
|
|||
|
||||
return vip != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canView(VipOrderVO order, Long userId) {
|
||||
if (order == null || userId == null) {
|
||||
return false;
|
||||
}
|
||||
return isBonus(order, userId) || isUser(order, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否是订单的分成方
|
||||
*/
|
||||
private boolean isBonus(VipOrderVO order, Long userId) {
|
||||
if (order == null || userId == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询订单的分成方
|
||||
List<BonusVO> bonusList = bonusService.selectBonusByBstId(BonusBstType.VIP, order.getId());
|
||||
|
||||
// 判断用户是否分成方
|
||||
return bonusList.stream()
|
||||
.anyMatch(bonus ->
|
||||
BonusArrivalType.userList().contains(bonus.getArrivalType())
|
||||
&& Objects.equals(bonus.getArrivalId(), userId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否是订单的创建者
|
||||
*/
|
||||
private boolean isUser(VipOrderVO order, Long userId) {
|
||||
return userId != null && order != null && Objects.equals(order.getUserId(), userId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,19 @@ package com.ruoyi.web.controller.app;
|
|||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.ss.vipLevel.domain.enums.VipLevelSolution;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderQuery;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderVO;
|
||||
import com.ruoyi.ss.vipOrder.domain.bo.AddPayVipOrderBO;
|
||||
import com.ruoyi.ss.vipOrder.domain.dto.AddPayVipOrderDTO;
|
||||
import com.ruoyi.ss.vipOrder.service.VipOrderConverter;
|
||||
import com.ruoyi.ss.vipOrder.service.VipOrderService;
|
||||
import com.ruoyi.ss.vipOrder.service.VipOrderValidator;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
|
@ -28,12 +30,39 @@ public class AppVipOrderController extends BaseController {
|
|||
@Autowired
|
||||
private VipOrderConverter vipOrderConverter;
|
||||
|
||||
@Autowired
|
||||
private VipOrderValidator vipOrderValidator;
|
||||
|
||||
@ApiOperation("下单并发起支付")
|
||||
@PostMapping
|
||||
public AjaxResult addAndPay(@RequestBody AddPayVipOrderDTO dto) {
|
||||
public AjaxResult addAndPay(@RequestBody @Validated AddPayVipOrderDTO dto) {
|
||||
dto.setSolution(VipLevelSolution.SAME.getCode());
|
||||
AddPayVipOrderBO bo = vipOrderConverter.toBO(dto);
|
||||
return success(vipOrderService.addAndPay(bo));
|
||||
}
|
||||
|
||||
@ApiOperation("刷新支付结果")
|
||||
@PutMapping("/refreshPayResult")
|
||||
public AjaxResult refreshPayResult(String orderNo) {
|
||||
return toAjax(vipOrderService.refreshPayResult(orderNo));
|
||||
}
|
||||
|
||||
@ApiOperation("查询本人订单列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(VipOrderQuery query) {
|
||||
startPage();
|
||||
query.setUserId(getUserId());
|
||||
return getDataTable(vipOrderService.selectVipOrderList(query));
|
||||
}
|
||||
|
||||
@ApiOperation("通过ID查询订单详情")
|
||||
@GetMapping("/detail/{id}")
|
||||
public AjaxResult detail(@PathVariable Long id) {
|
||||
VipOrderVO order = vipOrderService.selectVipOrderById(id);
|
||||
if (!vipOrderValidator.canView(order, getUserId())) {
|
||||
return error("您没有权限查看该订单");
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.web.controller.ss;
|
|||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.ValidGroup;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
|
@ -10,9 +11,11 @@ import com.ruoyi.ss.vip.domain.Vip;
|
|||
import com.ruoyi.ss.vip.domain.VipQuery;
|
||||
import com.ruoyi.ss.vip.domain.VipVO;
|
||||
import com.ruoyi.ss.vip.service.VipAssembler;
|
||||
import com.ruoyi.ss.vip.service.VipConverter;
|
||||
import com.ruoyi.ss.vip.service.VipService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -32,6 +35,9 @@ public class VipController extends BaseController
|
|||
@Autowired
|
||||
private VipService vipService;
|
||||
|
||||
@Autowired
|
||||
private VipConverter vipConverter;
|
||||
|
||||
@Autowired
|
||||
private VipAssembler vipAssembler;
|
||||
|
||||
|
@ -79,8 +85,9 @@ public class VipController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('ss:vip:add')")
|
||||
@Log(title = "会员", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Vip vip)
|
||||
public AjaxResult add(@RequestBody @Validated(ValidGroup.Create.class) Vip vip)
|
||||
{
|
||||
vip = vipConverter.toPoByAdd(vip);
|
||||
return toAjax(vipService.insertVip(vip));
|
||||
}
|
||||
|
||||
|
@ -91,7 +98,8 @@ public class VipController extends BaseController
|
|||
@Log(title = "会员", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Vip vip) {
|
||||
return toAjax(vipService.updateVip(vip));
|
||||
return error("会员修改功能暂未开放");
|
||||
// return toAjax(vipService.updateVip(vip));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,8 +108,8 @@ public class VipController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('ss:vip:remove')")
|
||||
@Log(title = "会员", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
{
|
||||
return toAjax(vipService.deleteVipByIds(ids));
|
||||
return toAjax(vipService.logicDel(ids));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
|||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrder;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderQuery;
|
||||
import com.ruoyi.ss.vipOrder.domain.VipOrderVO;
|
||||
import com.ruoyi.ss.vipOrder.service.VipOrderAssembler;
|
||||
|
@ -72,35 +71,14 @@ public class VipOrderController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* 新增会员订单
|
||||
* 刷新支付结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipOrder:add')")
|
||||
@Log(title = "会员订单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody VipOrder vipOrder)
|
||||
{
|
||||
return toAjax(vipOrderService.insertVipOrder(vipOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改会员订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipOrder:edit')")
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipOrder:refreshPayResult')")
|
||||
@Log(title = "会员订单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody VipOrder vipOrder)
|
||||
{
|
||||
return toAjax(vipOrderService.updateVipOrder(vipOrder));
|
||||
@PutMapping("/refreshPayResult")
|
||||
public AjaxResult refreshPayResult(Long id) {
|
||||
return toAjax(vipOrderService.refreshPayResult(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除会员订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:vipOrder:remove')")
|
||||
@Log(title = "会员订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(vipOrderService.deleteVipOrderByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user