Commit e396b965 by 吕明尚

修改计算订单价格

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