浏览代码

add:平台优惠券商家端预计收入展示问题
bugfix:优惠券请求失败问题

lyx 2 月之前
父节点
当前提交
d045687ee6

+ 4 - 1
alien-entity/src/main/java/shop/alien/mapper/LifeUserOrderMapper.java

@@ -52,7 +52,8 @@ public interface LifeUserOrderMapper extends BaseMapper<LifeUserOrder> {
             "CASE\n" +
             "        WHEN si.delete_flag = 1 OR si.logout_flag = 1 THEN 1\n" +
             "        ELSE 0\n" +
-            "    END AS abnormalStateFlag\n" +
+            "    END AS abnormalStateFlag,\n" +
+            "ldc.nominal_value,ldc.type\n" +
             "from life_user_order luo\n" +
             "left join store_info si on si.id = luo.store_id  -- 查询店铺相关 \n" +
             "left join life_user lu on lu.id = luo.user_id and lu.delete_flag = 0 -- 查询用户相关 \n" +
@@ -60,6 +61,8 @@ public interface LifeUserOrderMapper extends BaseMapper<LifeUserOrder> {
             "inner join total_coupon tc on tc.coupon_id = ocm.coupon_id and tc.coupon_type = luo.coupon_type\n" +
             "left join  store_img simg on simg.id = tc.image_id and simg.delete_flag = 0 \n" +
             "left join  store_comment sc on sc.business_id = luo.id and sc.delete_flag = 0 and sc.business_type = 5\n" +
+            "left join life_discount_coupon_user ldcu on ldcu .id = luo.quan_id \n" +
+            "left join life_discount_coupon ldc on ldc.id = ldcu.coupon_id \n" +
             "${ew.customSqlSegment}")
     IPage<LifeUserOrderVo> queryUserOrderList(IPage<LifeUserOrderVo> brandedPage,@Param(Constants.WRAPPER) QueryWrapper<LifeUserOrderVo> lifeUserOrderQueryWrapper);
 

+ 9 - 0
alien-store/src/main/java/shop/alien/store/service/LifeUserOrderService.java

@@ -915,6 +915,15 @@ public class LifeUserOrderService extends ServiceImpl<LifeUserOrderMapper, LifeU
         for (LifeUserOrderVo record : lifeUserOrderVoIPage.getRecords()) {
             record.setOrderCouponMiddleList(orderCouponMiddleMapper.selectList(new QueryWrapper<OrderCouponMiddle>().eq("order_id",record.getId())));
             calcExpectIncome(record);
+            // 如果代金券为平台优惠券并且是商户查询,则需要计算代金券金额
+            if("3".equals(record.getType()) && org.apache.commons.lang3.StringUtils.isNotBlank(record.getStoreId())){
+                // 如果付款为0,商家收入为套餐原价
+                if(record.getFinalPrice().equals("0")){
+                    record.setFinalPrice(record.getPrice());
+                }else {
+                    record.setFinalPrice(record.getNominalValue().add(new BigDecimal(record.getFinalPrice())).toString());
+                }
+            }
         }
         return lifeUserOrderVoIPage;
     }

+ 6 - 5
alien-store/src/main/java/shop/alien/store/service/impl/LifeDiscountCouponServiceImpl.java

@@ -1,3 +1,4 @@
+
 package shop.alien.store.service.impl;
 
 import com.alibaba.nacos.common.utils.CollectionUtils;
@@ -8,7 +9,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
-import org.apache.poi.util.StringUtil;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.stereotype.Service;
@@ -346,6 +346,7 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
     public List<LifeDiscountCouponVo> getStoreUserCouponList(String storeId, UserLoginInfo userLoginInfo) {
         List<LifeDiscountCouponVo> lifeDiscountCouponVos = new ArrayList<>();
         LocalDate now = LocalDate.now();
+        LocalDateTime now1 = now.atStartOfDay();
         //根据店铺id查询该店铺的优惠券,状态是开启领取的券
         List<LifeDiscountCoupon> lifeDiscountCoupons = lifeDiscountCouponMapper.selectList(new LambdaQueryWrapper<LifeDiscountCoupon>().eq(LifeDiscountCoupon::getStoreId, storeId).eq(LifeDiscountCoupon::getGetStatus, "1").gt(LifeDiscountCoupon::getSingleQty, 0) //还有库存
                 .ge(LifeDiscountCoupon::getEndGetDate, now).orderByDesc(LifeDiscountCoupon::getCreatedTime));
@@ -392,13 +393,13 @@ public class LifeDiscountCouponServiceImpl extends ServiceImpl<LifeDiscountCoupo
                     String unavailableRuleValue = lifeDiscountCouponUnavailableRules.getUnavailableRuleValue();
                     long confineTo = 0L;
                     if (DiscountCouponEnum.DAY.getValue().equals(unavailableRuleValue)) {//如果规则限制一天一张
-                        confineTo = ChronoUnit.DAYS.between(localDateTime, now);
+                        confineTo = ChronoUnit.DAYS.between(localDateTime, now1);
                     } else if (DiscountCouponEnum.WEEK.getValue().equals(unavailableRuleValue)) {//如果规则限制一周一张
-                        confineTo = ChronoUnit.WEEKS.between(localDateTime, now);
+                        confineTo = ChronoUnit.WEEKS.between(localDateTime, now1);
                     } else if (DiscountCouponEnum.MONTH.getValue().equals(unavailableRuleValue)) {//如果规则限制一月一张
-                        confineTo = ChronoUnit.MONTHS.between(localDateTime, now);
+                        confineTo = ChronoUnit.MONTHS.between(localDateTime, now1);
                     } else if (DiscountCouponEnum.YEAR.getValue().equals(unavailableRuleValue)) {//如果规则限制一年一张
-                        confineTo = ChronoUnit.YEARS.between(localDateTime, now);
+                        confineTo = ChronoUnit.YEARS.between(localDateTime, now1);
                     }
                     //如果在规则范围内,则不允许领取,范围外,则可以领取
                     lifeDiscountCouponVo.setCanReceived(confineTo >= 1);