Commit f3b16631 by 吕明尚

优惠卷增加优惠卷售卖金额

parent 0f30bc29
......@@ -6,33 +6,29 @@ import java.math.BigDecimal;
public class TableDataInfoVo extends TableDataInfo {
/**
* 总金额
* 订单总金额
*/
private BigDecimal totalAmount;
/**
* 实付金额
* 实付金额
*/
private BigDecimal amount;
/**
* 已使用总金额
* 优惠卷售卖总金额
*/
private BigDecimal usedAmount;
private BigDecimal couponAmount;
/**
* 已使用实付金额
*/
private BigDecimal usedPayAmount;
/**
* 以退款总金额
* 申请退款总金额
*/
private BigDecimal refundAmount;
/**
* 以退款实付金额
* 实际退款总金额
*/
private BigDecimal refundPayAmount;
private BigDecimal realRefundAmount;
public BigDecimal getTotalAmount() {
return totalAmount;
......@@ -50,20 +46,12 @@ public class TableDataInfoVo extends TableDataInfo {
this.amount = amount;
}
public BigDecimal getUsedAmount() {
return usedAmount;
public BigDecimal getCouponAmount() {
return couponAmount;
}
public void setUsedAmount(BigDecimal usedAmount) {
this.usedAmount = usedAmount;
}
public BigDecimal getUsedPayAmount() {
return usedPayAmount;
}
public void setUsedPayAmount(BigDecimal usedPayAmount) {
this.usedPayAmount = usedPayAmount;
public void setCouponAmount(BigDecimal couponAmount) {
this.couponAmount = couponAmount;
}
public BigDecimal getRefundAmount() {
......@@ -74,12 +62,11 @@ public class TableDataInfoVo extends TableDataInfo {
this.refundAmount = refundAmount;
}
public BigDecimal getRefundPayAmount() {
return refundPayAmount;
public BigDecimal getRealRefundAmount() {
return realRefundAmount;
}
public void setRefundPayAmount(BigDecimal refundPayAmount) {
this.refundPayAmount = refundPayAmount;
public void setRealRefundAmount(BigDecimal realRefundAmount) {
this.realRefundAmount = realRefundAmount;
}
}
package share.quartz.task;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dianping.openapi.sdk.api.tuangou.entity.TuangouReceiptGetConsumedReponseEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import share.common.enums.CouponTypeEnum;
import share.common.enums.PlatformTypeEnum;
import share.common.enums.UserStatusEnum;
import share.common.enums.YesNoEnum;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SOrder;
import share.system.domain.SStore;
import share.system.service.ISConsumerCouponService;
import share.system.service.ISOrderService;
import share.system.service.ISStoreService;
import share.system.service.QPService;
import share.system.service.TiktokService;
import share.system.service.impl.QPServiceImpl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -30,7 +38,7 @@ public class CouponRetryTask {
@Autowired
private QPService qpService;
@Autowired
private ISOrderService orderService;
private TiktokService tiktokService;
private static final Logger logger = LoggerFactory.getLogger(QPServiceImpl.class);
public void AuToRetryCoupon() {
......@@ -50,36 +58,55 @@ public class CouponRetryTask {
}
}
// //自动生成优惠卷购买金额
// public void AutoGenerateCoupon() {
// LambdaQueryWrapper<SConsumerCoupon> consumerCouponWrapper = new LambdaQueryWrapper<>();
// List<SStore> list = storeService.list();
// //去除没open_shop_uuid的store
// list = list.stream().filter(item -> item.getOpenShopUuid() != null).collect(Collectors.toList());
// LambdaQueryWrapper<SOrder> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
// //优惠卷id不等于空
// orderLambdaQueryWrapper.isNotNull(SOrder::getCouponId);
// List<SOrder> orderList = orderService.list(orderLambdaQueryWrapper);
// //查询团购劵,未删除的优惠卷
// consumerCouponWrapper.eq(SConsumerCoupon::getIsDelete, YesNoEnum.no.getIndex());
// consumerCouponWrapper.eq(SConsumerCoupon::getCouponType, CouponTypeEnum.CASH.getCode());
// List<SConsumerCoupon> sConsumerCoupons = sConsumerCouponService.list(consumerCouponWrapper);
// if (!CollectionUtils.isEmpty(sConsumerCoupons)) {
// List<SStore> finalList = list;
// sConsumerCoupons.stream().forEach(item -> {
// TuangouReceiptGetConsumedReponseEntity getconsumed = qpService.getconsumed(item.getCouponCode(),
// finalList.stream().filter(store -> store.getId().equals(item.getStoreId())).findFirst().get().getOpenShopUuid());
// item.setCouponPayPrice(BigDecimal.valueOf(getconsumed.getDeal_price()));
// });
// orderList.stream().forEach(item -> {
// sConsumerCoupons.stream().forEach(coupon -> {
// if (item.getCouponId().equals(coupon.getId())) {
// coupon.setCouponPayPrice(item.getPayPrice());
// }
// });
// });
// orderService.updateBatchById(orderList);
// sConsumerCouponService.updateBatchById(sConsumerCoupons);
// }
// }
//自动生成优惠卷购买金额
public void AutoGenerateCoupon() {
LambdaQueryWrapper<SConsumerCoupon> consumerCouponWrapper = new LambdaQueryWrapper<>();
List<SStore> list = storeService.list();
//去除没open_shop_uuid的store
list = list.stream().filter(item -> item.getOpenShopUuid() != null).collect(Collectors.toList());
LambdaQueryWrapper<SOrder> orderLambdaQueryWrapper = new LambdaQueryWrapper<>();
//优惠卷id不等于空
orderLambdaQueryWrapper.isNotNull(SOrder::getCouponId);
//查询团购劵,未删除的优惠卷
consumerCouponWrapper.eq(SConsumerCoupon::getIsDelete, YesNoEnum.no.getIndex());
consumerCouponWrapper.eq(SConsumerCoupon::getCouponType, CouponTypeEnum.CASH.getCode());
consumerCouponWrapper.ne(SConsumerCoupon::getUseStatus, UserStatusEnum.EXPIRED.getCode());
//门店id不等于空
consumerCouponWrapper.isNotNull(SConsumerCoupon::getStoreId);
consumerCouponWrapper.isNull(SConsumerCoupon::getCouponPayPrice);
List<SConsumerCoupon> sConsumerCoupons = sConsumerCouponService.list(consumerCouponWrapper);
List<SConsumerCoupon> sConsumerCouponList = new ArrayList<>();
//大于100条取100条数据
if (sConsumerCoupons.size() > 100) {
sConsumerCoupons = sConsumerCoupons.subList(0, 100);
}
if (!CollectionUtils.isEmpty(sConsumerCoupons)) {
List<SStore> finalList = list;
sConsumerCoupons.stream().forEach(item -> {
if (item.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
String openShopUuid = finalList.stream().filter(store -> store.getId().equals(item.getStoreId())).findFirst().get().getOpenShopUuid();
TuangouReceiptGetConsumedReponseEntity getconsumed = qpService.getconsumed(item.getCouponCode(), openShopUuid);
System.out.println(getconsumed);
if (!ObjectUtils.isEmpty(getconsumed)) {
item.setCouponPayPrice(BigDecimal.valueOf(getconsumed.getDeal_price()));
sConsumerCouponList.add(item);
logger.info("美团优惠卷购买金额为:" + item.getCouponPayPrice());
} else {
item.setUseStatus(UserStatusEnum.EXPIRED.getCode());
}
}
if (item.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
JSONObject data = tiktokService.certificateGet(item.getEncryptedCode());
JSONObject certificate = data.getJSONObject("certificate");
JSONObject amount = certificate.getJSONObject("amount");
sConsumerCouponList.add(item);
item.setCouponPayPrice(BigDecimal.valueOf(amount.getDouble("pay_amount") / 100));
logger.info("抖音优惠卷购买金额为:" + item.getCouponPayPrice());
}
});
if (!CollectionUtils.isEmpty(sConsumerCouponList))
sConsumerCouponService.updateBatchById(sConsumerCouponList);
}
}
}
......@@ -129,8 +129,7 @@ public class RedisTask {
}
}
}
//逻辑删除所有异常优惠券
isConsumerCouponService.removeByIdList(expiredCoupons);
if (!CollectionUtils.isEmpty(expiredCoupons)) isConsumerCouponService.removeByIdList(expiredCoupons);
}
}
......
......@@ -116,6 +116,12 @@ public class SConsumerCoupon extends BaseEntity
@Excel(name = "减去金额(满减券单位:元,折扣为系数)")
private BigDecimal subPrice;
/**
* 优惠卷购买金额
*/
@Excel(name = "优惠卷购买金额(单位:元)")
private BigDecimal couponPayPrice;
/** 优惠券来源(1:领取,2:赠送,3:验券) */
@Excel(name = "优惠券来源(1:领取,2:赠送,3:验券)")
private String sourceType;
......
......@@ -82,6 +82,12 @@ public class SCoupon extends BaseEntity
private BigDecimal subPrice;
/**
* 优惠卷购买金额
*/
@Excel(name = "优惠卷购买金额(单位:元)")
private BigDecimal couponPayPrice;
/**
* 订单类型(0:订房订单,1:续房订单,2:充值订单)
*/
@Excel(name = "订单类型(1:订房订单,2:续房订单,3:充值订单)")
......
......@@ -129,6 +129,7 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
sConsumerCoupon.setCreateTime(new Date());
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(prepare.getDeal_marketprice()));
sConsumerCoupon.setCouponPayPrice(BigDecimal.valueOf(prepare.getDeal_price()));
//查询美团团购信息
List<TuangouDealQueryShopDealResponseEntity> groupActivities = queryshopdeal(sStore.getOpenShopUuid());
groupActivities.forEach(o -> {
......
......@@ -210,6 +210,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon.setName(item.getTitle());
//套餐原价
sCoupon.setSubPrice(BigDecimal.valueOf(item.getMarketprice()));
sCoupon.setCouponPayPrice(BigDecimal.valueOf(item.getPrice()));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date receiptEndDate = sdf.parse(item.getReceipt_end_date());
......@@ -323,6 +324,7 @@ public class SCouponServiceImpl extends ServiceImpl<SCouponMapper, SCoupon> impl
sCoupon.setMinDuration(DEFAULT_DURATION);
sCoupon.setMaxDuration(DEFAULT_MAX_DURATION);
sCoupon.setMinPrice(new BigDecimal("0.00"));
sCoupon.setCouponPayPrice(sku.getBigDecimal("actual_amount").divide(new BigDecimal("100")));
sCoupon.setCouponType(CouponTypeEnum.CASH.getCode());
if (finalSStores.size() == 0) {
sCouponList.add(sCoupon);
......
......@@ -313,27 +313,25 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<SOrderVo> sOrderVos = convertDosToVos(sOrders);
BigDecimal totalAmount = new BigDecimal("0.00");
BigDecimal amount = new BigDecimal("0.00");
//已使用总金额
BigDecimal usedAmount = new BigDecimal("0.00");
//已使用实付金额
BigDecimal usedPayAmount = new BigDecimal("0.00");
//以退款总金额
//优惠卷售卖总金额
BigDecimal couponAmount = new BigDecimal("0.00");
//申请退款总金额
BigDecimal refundAmount = new BigDecimal("0.00");
//以退款实付金额
BigDecimal refundPayAmount = new BigDecimal("0.00");
//实际退款总金额
BigDecimal realRefundAmount = new BigDecimal("0.00");
List<SConsumerCoupon> sConsumerCoupons = consumerCouponService.queryList();
if (CollectionUtils.isNotEmpty(sOrderVos)) {
for (SOrderVo item : sOrderVos) {
totalAmount = totalAmount.add(item.getTotalPrice());
amount = amount.add(item.getPayPrice());
if (item.getPayStatus().equals(YesNoEnum.yes.getIndex()) && item.getStatus().equals(OrderStatusEnum.USED.getCode())) {
usedAmount = usedAmount.add(item.getTotalPrice());
usedPayAmount = usedPayAmount.add(item.getPayPrice());
}
if (item.getRefundStatus().equals(RefundStatusEnum.REFUNDED.getCode())) {
refundAmount = refundAmount.add(item.getTotalPrice());
refundPayAmount = refundPayAmount.add(item.getPayPrice());
sConsumerCoupons.stream().filter(sConsumerCoupon -> sConsumerCoupon.getId().equals(item.getCouponId())).findFirst().ifPresent(sConsumerCoupon -> {
couponAmount.add(ObjectUtil.isEmpty(sConsumerCoupon.getCouponPayPrice()) ? new BigDecimal("0.00") : sConsumerCoupon.getCouponPayPrice());
});
if (item.getPayStatus().equals(YesNoEnum.yes.getIndex()) && item.getRefundStatus().equals(RefundStatusEnum.REFUNDED.getCode())) {
refundAmount.add(ObjectUtil.isEmpty(item.getPayPrice()) ? new BigDecimal("0.00") : item.getPayPrice());
realRefundAmount.add(ObjectUtil.isEmpty(item.getRefundPrice()) ? new BigDecimal("0.00") : item.getRefundPrice());
}
}
}
sOrderVos.sort(Comparator.comparing(SOrderVo::getCreateTime).reversed());
......@@ -350,10 +348,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
tableDataInfo.setMsg("查询成功");
tableDataInfo.setTotalAmount(totalAmount);
tableDataInfo.setAmount(amount);
tableDataInfo.setUsedAmount(usedAmount);
tableDataInfo.setUsedPayAmount(usedPayAmount);
tableDataInfo.setCouponAmount(couponAmount);
tableDataInfo.setRefundAmount(refundAmount);
tableDataInfo.setRefundPayAmount(refundPayAmount);
tableDataInfo.setRealRefundAmount(realRefundAmount);
return tableDataInfo;
}
......
......@@ -394,6 +394,7 @@ public class TiktokServiceImpl implements TiktokService {
sConsumerCoupon.setCreateTime(new Date());
Integer originalAmount = amount.getInt("list_market_amount");
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(originalAmount / 100));
sConsumerCoupon.setCouponPayPrice(BigDecimal.valueOf(amount.getInt("coupon_pay_amount") / 100));
//时间戳转年月日时分秒
sConsumerCoupon.setEndDate(new Date(entries.getInt("expire_time") * 1000L));
//获取本日的00:00:00
......
......@@ -24,6 +24,7 @@
<result property="duration" column="duration" />
<result property="minPrice" column="min_price" />
<result property="subPrice" column="sub_price" />
<result property="couponPayPrice" column="coupon_pay_price"/>
<result property="sourceType" column="source_type" />
<result property="roomType" column="room_type" />
<result property="storeType" column="store_type" />
......@@ -65,6 +66,7 @@
duration,
min_price,
sub_price,
coupon_pay_price,
source_type,
platform_type,
start_date,
......@@ -119,6 +121,7 @@
<if test="deleteBy != null and deleteBy != ''"> and delete_by = #{deleteBy}</if>
<if test="deleteTime != null "> and delete_time = #{deleteTime}</if>
<if test="tiktokSkuId != null ">and tiktok_sku_id = #{tiktokSkuId}</if>
<if test="couponPayPrice != null ">and coupon_pay_price = #{couponPayPrice}</if>
ORDER BY create_time DESC
</select>
......@@ -198,6 +201,7 @@
<if test="dealgroupId != null">dealgroup_id,</if>
<if test="tiktokSkuId != null">tiktok_sku_id,</if>
<if test="storeIds != null">store_ids,</if>
<if test="couponPayPrice != null">coupon_pay_price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="consumerId != null">#{consumerId},</if>
......@@ -237,6 +241,7 @@
<if test="dealgroupId != null">#{dealgroupId},</if>
<if test="tiktokSkuId != null">#{tiktokSkuId},</if>
<if test="storeIds != null">#{storeIds},</if>
<if test="couponPayPrice != null">#{couponPayPrice},</if>
</trim>
</insert>
......@@ -280,6 +285,7 @@
<if test="dealgroupId != null">dealgroup_id = #{dealgroupId},</if>
<if test="tiktokSkuId != null">tiktok_sku_id = #{tiktokSkuId},</if>
<if test="storeIds != null">store_ids = #{storeIds},</if>
<if test="couponPayPrice != null">coupon_pay_price = #{couponPayPrice},</if>
</trim>
where id = #{id}
</update>
......
......@@ -24,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="maxDuration" column="max_duration" />
<result property="minPrice" column="min_price" />
<result property="subPrice" column="sub_price" />
<result property="couponPayPrice" column="coupon_pay_price"/>
<result property="isOverlay" column="is_overlay" />
<result property="weeks" column="weeks"/>
<result property="platformType" column="platform_type" />
......@@ -47,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
tiktok_sku_id,
weeks,
store_ids,
coupon_pay_price,
duration,min_duration,max_duration,
min_price,sub_price,is_overlay,
platform_type,number,create_by,
......@@ -75,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="maxDuration != null and maxDuration != ''"> and max_duration = #{maxDuration}</if>
<if test="minPrice != null and minPrice != ''"> and min_price = #{minPrice}</if>
<if test="subPrice != null and subPrice != ''"> and sub_price = #{subPrice}</if>
<if test="couponPayPrice != null and couponPayPrice != ''">and coupon_pay_price = #{couponPayPrice}</if>
<if test="isOverlay != null"> and is_overlay = #{isOverlay}</if>
<if test="platformType != null"> and platform_type = #{platformType}</if>
<if test="weeks != null">and weeks = #{weeks}</if>
......@@ -148,6 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dealgroupId != null">dealgroup_id,</if>
<if test="tiktokSkuId != null">tiktok_sku_id,</if>
<if test="storeIds != null">store_ids,</if>
<if test="couponPayPrice != null">coupon_pay_price,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
......@@ -175,6 +179,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dealgroupId != null">#{dealgroupId},</if>
<if test="tiktokSkuId != null">#{tiktokSkuId},</if>
<if test="storeIds != null">#{storeIds},</if>
<if test="couponPayPrice != null">#{couponPayPrice},</if>
</trim>
</insert>
......@@ -208,6 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="couponPayPrice != null">coupon_pay_price = #{couponPayPrice},</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