调整了打票机 订单商品间距
This commit is contained in:
parent
621f557e34
commit
a7f2a7ac14
@ -3983,43 +3983,68 @@ public class ShopStoreActivityBaseServiceImpl extends BaseServiceImpl<ShopStoreA
|
||||
return item_row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算砍价活动中每次砍价的价格
|
||||
*
|
||||
* @param activity_row 活动基础信息
|
||||
* @param ac_row 砍价活动记录
|
||||
* @return 砍价金额
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal getCutDownPrice(ShopStoreActivityBase activity_row, ShopActivityCutprice ac_row) {
|
||||
// 1. 参数校验
|
||||
if (activity_row == null || ac_row == null) {
|
||||
throw new ApiException(I18nUtil._("活动不存在!"));
|
||||
}
|
||||
|
||||
// 2. 活动类型校验
|
||||
Integer activity_type_id = activity_row.getActivity_type_id();
|
||||
if (ObjectUtil.notEqual(StateCode.ACTIVITY_TYPE_CUTPRICE, activity_type_id)) {
|
||||
throw new ApiException(I18nUtil._("活动不存在!"));
|
||||
}
|
||||
|
||||
BigDecimal price = BigDecimal.ZERO;
|
||||
BigDecimal price;
|
||||
|
||||
// 3. 解析活动规则
|
||||
String str_activity_rule = activity_row.getActivity_rule();
|
||||
JSONObject activity_rule = JSONObject.parseObject(str_activity_rule);
|
||||
Integer cut_down_type = activity_rule.getObject("cut_down_type", Integer.class);
|
||||
BigDecimal ac_sale_price = ac_row.getAc_sale_price();
|
||||
BigDecimal ac_mix_limit_price = ac_row.getAc_mix_limit_price();
|
||||
|
||||
// 4. 根据砍价类型计算砍价金额
|
||||
switch (cut_down_type) {
|
||||
case 1:
|
||||
// 固定金额砍价
|
||||
price = activity_rule.getObject("cut_down_fixed_price", BigDecimal.class);
|
||||
break;
|
||||
case 2:
|
||||
// 随机金额砍价
|
||||
BigDecimal cut_down_min_limit_price = activity_rule.getObject("cut_down_min_limit_price", BigDecimal.class);
|
||||
Integer cut_down_user_num = activity_rule.getObject("cut_down_user_num", Integer.class);
|
||||
Integer ac_num = ac_row.getAc_num();
|
||||
List<Integer> arr = randMoney(NumberUtil.sub(ac_sale_price, cut_down_min_limit_price), cut_down_user_num - ac_num);
|
||||
|
||||
Integer randPrice = arr.size() == 1 ? arr.get(0) : arr.get(RandomUtil.randomInt(0, arr.size() - 1));
|
||||
// 计算剩余可砍价金额和剩余次数
|
||||
List<Integer> arr = randMoney(
|
||||
NumberUtil.sub(ac_sale_price, cut_down_min_limit_price),
|
||||
cut_down_user_num - ac_num
|
||||
);
|
||||
|
||||
// 随机选择一个砍价金额
|
||||
Integer randPrice = arr.size() == 1 ? arr.get(0) : arr.get(RandomUtil.randomInt(0, arr.size()));
|
||||
price = NumberUtil.div(BigDecimal.valueOf(randPrice), 100, 2);
|
||||
break;
|
||||
default:
|
||||
// 未知砍价类型,返回0
|
||||
price = BigDecimal.ZERO;
|
||||
break;
|
||||
}
|
||||
|
||||
// 5. 返回砍价金额,不超过可砍价的上限
|
||||
return NumberUtil.min(NumberUtil.sub(ac_sale_price, ac_mix_limit_price), price);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ShopStoreActivityBase> getCouponsList(Integer activity_type_id) {
|
||||
QueryWrapper<ShopStoreActivityBase> wrapper = new QueryWrapper<>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user