Commit e396b965 by 吕明尚

修改计算订单价格

parent 487fde0a
......@@ -93,6 +93,9 @@ public class SOrder extends BaseEntity
@Excel(name = "订单时长(H)")
private String timeLong;
@Excel(name = "优惠比例")
private BigDecimal discountRatio;
/** 预约开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
@Excel(name = "预约开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm")
......
......@@ -169,6 +169,11 @@ public class SOrderVo
@ApiModelProperty(value = "支付类型(1:微信,2:支付宝)")
private Integer payType;
/**
* 优惠比例
*/
private BigDecimal discountRatio;
@ApiModelProperty(value = "支付状态(0:未支付,1:已支付)")
private Integer payStatus;
......
......@@ -78,5 +78,7 @@ public class CreateOrderRequest {
@ApiModelProperty(value = "标签id")
private Long roomLabelId;
@ApiModelProperty(value = "优惠比例")
private BigDecimal discountRatio;
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.DateUtils;
import share.common.utils.StringUtils;
import share.system.domain.Activity;
import share.system.domain.SStore;
import share.system.mapper.ActivityMapper;
......@@ -57,7 +58,9 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i
@Override
public int insertActivity(Activity activity) {
activity.setCreateTime(DateUtils.getNowDate());
if (StringUtils.isEmpty(activity.getStoreIds())) {
activity.setStoreIds(storeService.list().stream().map(SStore::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.joining(",")));
}
return activityMapper.insertActivity(activity);
}
......
......@@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.DateUtils;
import share.common.utils.StringUtils;
import share.system.domain.RechargeConf;
import share.system.domain.SStore;
import share.system.mapper.RechargeConfMapper;
import share.system.service.ISStoreService;
import share.system.service.RechargeConfService;
import java.util.List;
import java.util.stream.Collectors;
/**
* 充值配置Service业务层处理
......@@ -20,6 +24,8 @@ import java.util.List;
public class RechargeConfServiceImpl extends ServiceImpl<RechargeConfMapper, RechargeConf> implements RechargeConfService {
@Autowired
private RechargeConfMapper rechargeConfMapper;
@Autowired
private ISStoreService storeService;
/**
* 查询充值配置
......@@ -52,6 +58,9 @@ public class RechargeConfServiceImpl extends ServiceImpl<RechargeConfMapper, Rec
@Override
public int insertRechargeConf(RechargeConf rechargeConf) {
rechargeConf.setCreateTime(DateUtils.getNowDate());
if (StringUtils.isEmpty(rechargeConf.getStoreIds())) {
rechargeConf.setStoreIds(storeService.list().stream().map(SStore::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.joining(",")));
}
return rechargeConfMapper.insertRechargeConf(rechargeConf);
}
......
......@@ -1869,9 +1869,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
BigDecimal totalFee = new BigDecimal(0);
if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
payPrice = totalPrice;
request.setBuyType(BuyTypeEnum.TIME.getCode());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
if (ObjectUtil.isNotEmpty(consumerMember)) {
queryWrapper.eq(Activity::getLabelId, roomLabel.getLabelId());
activity = activityService.getOne(queryWrapper);
......@@ -1907,11 +1907,19 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
priceResponse.setTotalFee(payPrice);
if (totalFee.compareTo(new BigDecimal(0)) == 0) {
priceResponse.setPayFee(payPrice);
} else {
priceResponse.setPayFee(totalFee);
}
// 计算优惠券金额
if (ObjectUtil.isNull(request.getCouponId()) || request.getCouponId() <= 0) {
priceResponse.setCouponFee(BigDecimal.ZERO);
if (totalFee.compareTo(new BigDecimal(0)) == 0) {
priceResponse.setPayFee(payPrice);
} else {
priceResponse.setPayFee(totalFee);
}
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee()).multiply(new BigDecimal(100)));
if (ObjectUtil.isNotEmpty(consumerMember)) {
......
......@@ -57,7 +57,7 @@
m.update_by,
m.update_time,
m.remark
from s_consumer_member m join s_consumer c on m.consumer_id = c.id
from s_consumer_member m join s_consumer c on m.consumer_id = c.id and m.is_delete = 0
<where>
<if test="nickName != null and nickName != ''">and c.nick_name like concat('%', #{nickName},'%')
</if>
......@@ -69,7 +69,6 @@
<if test="memberConfigId != null ">and m.member_config_id = #{memberConfigId}</if>
<if test="expirationDate != null ">and m.expiration_date = #{expirationDate}</if>
<if test="membershipProgress != null ">and m.membership_progress = #{membershipProgress}</if>
<if test="isDelete != null ">and m.is_delete = #{isDelete}</if>
</where>
</select>
......
......@@ -22,6 +22,7 @@
<result property="couponId" column="coupon_id"/>
<result property="couponPrice" column="coupon_price"/>
<result property="totalPrice" column="total_price"/>
<result property="discountRatio" column="discount_ratio"/>
<result property="payPrice" column="pay_price"/>
<result property="payTime" column="pay_time"/>
<result property="timeLong" column="time_long"/>
......@@ -62,6 +63,7 @@
coupon_price,
total_price,
pay_price,
discount_ratio,
pay_time,
time_long,
pre_start_date,
......@@ -106,6 +108,7 @@
<if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if>
<if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if>
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="discountRatio != null and discountRatio != ''">and discount_ratio = #{discountRatio}</if>
<if test="startPayTime != null">
and DATE_FORMAT(pay_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startPayTime}, '%Y-%m-%d')
</if>
......@@ -181,6 +184,7 @@
s.coupon_price,
s.total_price,
s.pay_price,
s.discount_ratio,
s.pay_time,
s.time_long,
s.pre_start_date,
......@@ -225,6 +229,7 @@
s.coupon_price,
s.total_price,
s.pay_price,
s.discount_ratio,
s.pay_time,
s.time_long,
s.pre_start_date,
......@@ -286,6 +291,7 @@
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="createTime != null and createTime != ''">create_time,</if>
<if test="arrivalTime != null and arrivalTime != ''">arrival_time,</if>
<if test="discountRatio != null and discountRatio != ''">discount_ratio,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null">#{orderNo},</if>
......@@ -320,6 +326,7 @@
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="arrivalTime != null">#{arrivalTime},</if>
<if test="discountRatio != null">#{discountRatio},</if>"
</trim>
</insert>
......@@ -359,6 +366,7 @@
<if test="updateTime != null">update_time = NOW(),</if>
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="discountRatio != null">discount_ratio = #{discountRatio},</if>
</trim>
where id = #{id}
</update>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment