优惠券
This commit is contained in:
@@ -1,14 +1,28 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.starry.admin.common.aspect.CustomUserLogin;
|
||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||
import com.starry.admin.modules.shop.module.entity.PlayCouponDetailsEntity;
|
||||
import com.starry.admin.modules.shop.module.entity.PlayCouponInfoEntity;
|
||||
import com.starry.admin.modules.shop.service.IPlayCouponDetailsService;
|
||||
import com.starry.admin.modules.shop.service.IPlayCouponInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.WxCouponQueryVo;
|
||||
import com.starry.admin.modules.weichat.entity.WxCouponReturnVo;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -23,21 +37,54 @@ public class WxCouponController {
|
||||
@Resource
|
||||
IPlayCouponDetailsService couponDetailsService;
|
||||
|
||||
@Resource
|
||||
IPlayCouponInfoService couponInfoService;
|
||||
|
||||
/**
|
||||
* 顾客查询本人优惠券列表
|
||||
*/
|
||||
@CustomUserLogin
|
||||
@GetMapping("/custom/queryAll")
|
||||
public R queryAll() {
|
||||
// couponDetailsService.selectByPage()
|
||||
// List<PlayCustomLevelInfoEntity> list = levelInfoService.selectAll();
|
||||
// List<PlayCustomLevelInfoReturnVo> result = new ArrayList<>();
|
||||
// for (PlayCustomLevelInfoEntity entity : list) {
|
||||
// PlayCustomLevelInfoReturnVo vo = new PlayCustomLevelInfoReturnVo();
|
||||
// BeanUtils.copyProperties(entity, vo);
|
||||
// result.add(vo);
|
||||
// }
|
||||
return R.ok("");
|
||||
@PostMapping("/custom/queryAll")
|
||||
public R queryAll(@Validated @RequestBody WxCouponQueryVo vo) {
|
||||
List<PlayCouponDetailsEntity> list = couponDetailsService.selectByCustomId(ThreadLocalRequestDetail.getCustomUserInfo().getId());
|
||||
//不可用订单优惠券列表
|
||||
List<WxCouponReturnVo> notAvailable = new ArrayList<>();
|
||||
//可用优惠券列表
|
||||
List<WxCouponReturnVo> available = new ArrayList<>();
|
||||
for (PlayCouponDetailsEntity couponDetails : list) {
|
||||
PlayCouponInfoEntity couponInfo = couponInfoService.selectPlayCouponInfoById(couponDetails.getCouponId());
|
||||
WxCouponReturnVo wxCouponReturnVo = ConvertUtil.entityToVo(couponDetails, WxCouponReturnVo.class);
|
||||
String couponReasonForUnavailableUse = getCouponReasonForUnavailableUse(couponInfo, vo.getPlaceType(), vo.getCommodityId(), vo.getCommodityQuantity());
|
||||
if (StrUtil.isEmpty(couponReasonForUnavailableUse)) {
|
||||
wxCouponReturnVo.setAvailable("1");
|
||||
available.add(wxCouponReturnVo);
|
||||
} else {
|
||||
wxCouponReturnVo.setAvailable("0");
|
||||
wxCouponReturnVo.setReasonForUnavailableUse(couponReasonForUnavailableUse);
|
||||
notAvailable.add(wxCouponReturnVo);
|
||||
}
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("notAvailable", notAvailable);
|
||||
result.put("available", available);
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取优惠券不可用的原因
|
||||
*
|
||||
* @param couponInfo 优惠券信息
|
||||
* @param placeType 下单类型
|
||||
* @param commodityId 商品ID
|
||||
* @param commodityQuantity 商品数量
|
||||
* @return 不可用原因
|
||||
*/
|
||||
public String getCouponReasonForUnavailableUse(PlayCouponInfoEntity couponInfo, String placeType, String commodityId, Integer commodityQuantity) {
|
||||
if (StrUtil.isEmpty(commodityId) || commodityQuantity <= 0) {
|
||||
return "订单满0船票余额时可用";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
import com.starry.admin.common.aspect.ClerkUserLogin;
|
||||
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
|
||||
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayGroupWagesQueryVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayGroupWagesReturnVo;
|
||||
import com.starry.common.result.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信查询组长工资
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/7/6 下午3:46
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/wx/group")
|
||||
public class WxPersonnelGroupInfoController {
|
||||
|
||||
|
||||
@Resource
|
||||
private IPlayPersonnelGroupInfoService playClerkGroupInfoService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询组长公工资
|
||||
*/
|
||||
@ClerkUserLogin
|
||||
@PostMapping("/wages/listAll")
|
||||
public R listGroupWagesAll(@Validated @RequestBody PlayGroupWagesQueryVo vo) {
|
||||
List<PlayPersonnelGroupInfoEntity> list = playClerkGroupInfoService.selectAll();
|
||||
List<PlayGroupWagesReturnVo> data = new ArrayList<>();
|
||||
for (PlayPersonnelGroupInfoEntity entity : list) {
|
||||
PlayGroupWagesReturnVo bean = new PlayGroupWagesReturnVo();
|
||||
bean.setGroupName(entity.getGroupName());
|
||||
data.add(bean);
|
||||
}
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组长工资查询对象
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/7/6 下午3:56
|
||||
**/
|
||||
@Data
|
||||
public class PlayGroupWagesQueryVo {
|
||||
|
||||
/**
|
||||
* 统计时间
|
||||
*/
|
||||
private List<String> statisticalTime;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 组长工资查询对象
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/7/6 下午3:56
|
||||
**/
|
||||
@Data
|
||||
public class PlayGroupWagesReturnVo {
|
||||
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
private BigDecimal orderMoney = BigDecimal.ZERO;
|
||||
|
||||
|
||||
/**
|
||||
* 订单最终金额(支付金额)
|
||||
*/
|
||||
private BigDecimal finalAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 续单比例
|
||||
*/
|
||||
private final double orderContinueProportion = 0.0;
|
||||
/**
|
||||
* 续单金额
|
||||
*/
|
||||
private final BigDecimal orderTotalAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 续费率
|
||||
*/
|
||||
private final BigDecimal orderContinueRechargeProportion = BigDecimal.ZERO;
|
||||
/**
|
||||
* 退单率
|
||||
*/
|
||||
private final BigDecimal orderChargebackProportion = BigDecimal.ZERO;
|
||||
/**
|
||||
* 续客率
|
||||
*/
|
||||
private final BigDecimal continuousCustomProportion = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 订单平均价格
|
||||
*/
|
||||
private final BigDecimal averageUnitPrice = BigDecimal.ZERO;
|
||||
|
||||
|
||||
/**
|
||||
* 组长工资
|
||||
*/
|
||||
private final BigDecimal commission = BigDecimal.ZERO;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* 顾客优惠券查询对象
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/7/6 下午4:16
|
||||
**/
|
||||
@Data
|
||||
public class WxCouponQueryVo {
|
||||
|
||||
|
||||
private String commodityId;
|
||||
|
||||
|
||||
/**
|
||||
* 下单类型(-1:其他类型;0:指定单;1:随机单;2:打赏单)
|
||||
*/
|
||||
@NotNull(message = "下单类型不能为空")
|
||||
@Pattern(regexp = "[0|1]", message = "订单类型必须为0或者1")
|
||||
private String placeType;
|
||||
|
||||
|
||||
private int commodityQuantity;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.starry.admin.modules.weichat.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 顾客优惠券查询对象
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/7/6 下午4:16
|
||||
**/
|
||||
@Data
|
||||
public class WxCouponReturnVo {
|
||||
|
||||
/**
|
||||
* 优惠券ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
|
||||
/**
|
||||
* 优惠券名称
|
||||
**/
|
||||
private String couponName;
|
||||
|
||||
|
||||
/**
|
||||
* 有效期类型(0:永久有效;1:固定时间内有效;2:领取后几天内有效)
|
||||
*/
|
||||
private String validityPeriodType;
|
||||
|
||||
/**
|
||||
* 生效时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime productiveTime;
|
||||
|
||||
/**
|
||||
* 到期时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime expirationTime;
|
||||
|
||||
/**
|
||||
* 生效时长,validityPeriodType=2时有效
|
||||
**/
|
||||
private Integer effectiveDay;
|
||||
|
||||
/**
|
||||
* 使用优惠券最低消费金额
|
||||
**/
|
||||
private BigDecimal useMinAmount;
|
||||
|
||||
/**
|
||||
* 优惠类型(0:满减;1:折扣)
|
||||
*/
|
||||
private String discountType;
|
||||
|
||||
/**
|
||||
* 折扣值
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/**
|
||||
* 优惠是否可使用(0:不可使用,1:可使用)
|
||||
*/
|
||||
private String available;
|
||||
|
||||
/**
|
||||
* 优惠券不可用的原因
|
||||
*/
|
||||
private String reasonForUnavailableUse;
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user