Commit b0e41575 authored by mengbali153's avatar mengbali153

优惠券分类查询

parent e5c2843d
......@@ -22,15 +22,24 @@ public class BaiyingApi {
//开发环境配置
private static String openid = "19198e6d7feedda5";;
private static String cipher = "6276bcfcbd71966e";;
// private static String openid = "19198e6d7feedda5";
// private static String cipher = "6276bcfcbd71966e";
//服务器地址
private static String url = "http://116.62.180.218:8082";
// private static String url = "http://116.62.180.218:8082";
//生产环境配置
private static String openid = "c395729b9fa99789";
private static String cipher = "437a09f790230c43";
//服务器地址
private static String url = "https://openapi.baiying365.com";
public static void main(String[] args) {
// getAccessToken_2_0();
// synRedeemCodeState();
synRedeemCodeState();
// getRedeemCodeUseState();
}
......
......@@ -107,12 +107,19 @@ public class CMBOneNetController {
return CMBOneNetPayService.getUserInfo(coridc);
}
@ApiOperation(value = "申请发券")
@PostMapping("/applyEnterprise")
public BaseResponse applyEnterprise(@RequestBody SysEnterpriseDto enterpriseDto) {
return CMBOneNetPayService.applyEnterprise(enterpriseDto);
}
@ApiOperation(value = "查询申请发券企业信息")
@GetMapping("/getIssEnterprise")
public BaseResponse getIssEnterprise(String coridc) {
return CMBOneNetPayService.getIssEnterprise(coridc);
}
@ApiOperation(value = "票券列表(企业列表)")
@GetMapping("/getEnterpriseList")
public BaseResponse getEnterpriseList(String usridc) {
......@@ -143,24 +150,39 @@ public class CMBOneNetController {
@ApiOperation(value = "已领取优惠券列表")
@GetMapping("/getReceivedList")
public BaseResponse getReceivedList(String coridc, String usridc) {
public BaseResponse getReceivedList(String coridc,String usridc) {
return CMBOneNetPayService.getReceivedList(coridc, usridc);
}
@ApiOperation(value = "使用优惠券")
@GetMapping("/useCoupon")
public BaseResponse useCoupon(Long couponDetailId) {
return CMBOneNetPayService.useCoupon(couponDetailId);
@ApiOperation(value = "个人券夹")
@GetMapping("/getAllReceivedList")
public BaseResponse getAllReceivedList(String usridc) {
return CMBOneNetPayService.getAllReceivedList(usridc);
}
@ApiOperation(value = "个人券夹(企业)")
@GetMapping("/getAllReceivedListSE")
public BaseResponse getAllReceivedListSE(String coridc,String usridc) {
return CMBOneNetPayService.getAllReceivedListSE(coridc, usridc);
}
@ApiOperation(value = "失效优惠券列表")
@GetMapping("/getOverdueList")
public BaseResponse getOverdueList(String usridc) {
return CMBOneNetPayService.getOverdueList(usridc);
}
@ApiOperation(value = "失效优惠券列表(企业)")
@GetMapping("/getOverdueListSE")
public BaseResponse getOverdueListSE(String coridc,String usridc) {
return CMBOneNetPayService.getOverdueListSE(coridc, usridc);
}
@ApiOperation(value = "使用优惠券")
@GetMapping("/useCoupon")
public BaseResponse useCoupon(Long couponDetailId) {
return CMBOneNetPayService.useCoupon(couponDetailId);
}
}
......@@ -21,7 +21,15 @@ public interface SysCouponDetailMapper extends BaseMapper<SysCouponDetail> {
@Select("select count(*) from sys_coupon_detail where to_days(create_time) = to_days(now())")
int createNo();
List<ReceivedAppListVO> getReceivedList(@Param("coridc") String coridc, @Param("usridc") String usridc );
List<ReceivedAppListVO> getReceivedList(@Param("coridc") String coridc,@Param("usridc") String usridc);
List<ReceivedAppListVO> getAllReceivedList(@Param("usridc") String usridc);
List<ReceivedAppListVO> getAllReceivedListSE(@Param("coridc") String coridc,@Param("usridc") String usridc);
List<ReceivedAppListVO> getOverdueList(@Param("usridc") String usridc);
List<ReceivedAppListVO> getOverdueListSE(@Param("coridc") String coridc,@Param("usridc") String usridc);
@Select("select * from sys_coupon_detail scd where scd.is_receive=0 and to_days(now()) - to_days(scd.end_date) >0")
List<SysCouponDetail> getVerdueList();
......
......@@ -2,6 +2,7 @@ package cn.wise.sc.consume.business.mapper;
import cn.wise.sc.consume.business.entity.SysEnterprise;
import cn.wise.sc.consume.business.model.EnterpriseAppListVO;
import cn.wise.sc.consume.business.model.SysEnterpriseDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
......@@ -21,6 +22,7 @@ public interface SysEnterpriseMapper extends BaseMapper<SysEnterprise> {
List<SysEnterprise> getPage(@Param("map") Map<String,Object> map);
SysEnterprise getByCoridc(String coridc);
List<EnterpriseAppListVO> getEnterpriseList(String usridc);
......
......@@ -7,18 +7,77 @@
<!-- </update>-->
<select id="getReceivedList" resultType="cn.wise.sc.consume.business.model.ReceivedAppListVO">
select
scd.id as id, scd.coupon_code as couponCode,
sc.coupon_logo as couponLogo
from sys_coupon_detail scd
left join sys_user_coupon suc on suc.coupon_detail_id = scd.id
left join sys_coupon sc on sc.id = scd.coupon_id
left join sys_enterprise se on se.id = sc.enterprise_id
SELECT
scd.id AS id,sc.coupon_name AS couponName ,scd.coupon_code AS couponCode,
sc.coupon_logo AS couponLogo,scd.end_date AS endDate,scd.remark AS remark,
se.coridc as coridc,se.enterprise_name as coridcName,se.coupon_link as couponLink
FROM sys_coupon_detail scd
LEFT JOIN sys_user_coupon suc ON suc.coupon_detail_id = scd.id
LEFT JOIN sys_coupon sc ON sc.id = scd.coupon_id
LEFT JOIN sys_enterprise se ON se.id = sc.enterprise_id
where se.coridc = #{coridc} and sc.is_delete=1 and sc.status=1
and scd.is_delete=1 and scd.is_receive=1
and suc.user_id=#{usridc} and suc.is_use=0
</select>
<select id="getAllReceivedList" resultType="cn.wise.sc.consume.business.model.ReceivedAppListVO">
SELECT
scd.id AS id,sc.coupon_name AS couponName ,scd.coupon_code AS couponCode,
sc.coupon_logo AS couponLogo,scd.end_date AS endDate,scd.remark AS remark,
se.coridc as coridc,se.enterprise_name as coridcName,se.coupon_link as couponLink
FROM sys_coupon_detail scd
LEFT JOIN sys_user_coupon suc ON suc.coupon_detail_id = scd.id
LEFT JOIN sys_coupon sc ON sc.id = scd.coupon_id
LEFT JOIN sys_enterprise se ON se.id = sc.enterprise_id
where sc.is_delete=1 and sc.status=1
and scd.is_delete=1 and scd.is_receive=1
and suc.user_id=#{usridc} and suc.is_use=0
</select>
<select id="getAllReceivedListSE" resultType="cn.wise.sc.consume.business.model.ReceivedAppListVO">
SELECT
scd.id AS id,sc.coupon_name AS couponName ,scd.coupon_code AS couponCode,
sc.coupon_logo AS couponLogo,scd.end_date AS endDate,scd.remark AS remark,
se.coridc as coridc,se.enterprise_name as coridcName,se.coupon_link as couponLink
FROM sys_coupon_detail scd
LEFT JOIN sys_user_coupon suc ON suc.coupon_detail_id = scd.id
LEFT JOIN sys_coupon sc ON sc.id = scd.coupon_id
LEFT JOIN sys_enterprise se ON se.id = sc.enterprise_id
where se.coridc = #{coridc} and sc.is_delete=1 and sc.status=1
and scd.is_delete=1 and scd.is_receive=1
and suc.user_id=#{usridc} and suc.is_use=0
</select>
<select id="getOverdueList" resultType="cn.wise.sc.consume.business.model.ReceivedAppListVO">
SELECT
scd.id AS id,sc.coupon_name AS couponName ,scd.coupon_code AS couponCode,
sc.coupon_logo AS couponLogo,scd.end_date AS endDate,scd.remark AS remark,
se.coridc as coridc,se.enterprise_name as coridcName
FROM sys_coupon_detail scd
LEFT JOIN sys_user_coupon suc ON suc.coupon_detail_id = scd.id
LEFT JOIN sys_coupon sc ON sc.id = scd.coupon_id
LEFT JOIN sys_enterprise se ON se.id = sc.enterprise_id
where sc.is_delete=1 and sc.status=1
and scd.is_delete=1
and (scd.is_receive>1 OR suc.is_use>1)
and suc.user_id=#{usridc}
</select>
<select id="getOverdueListSE" resultType="cn.wise.sc.consume.business.model.ReceivedAppListVO">
SELECT
scd.id AS id,sc.coupon_name AS couponName ,scd.coupon_code AS couponCode,
sc.coupon_logo AS couponLogo,scd.end_date AS endDate,scd.remark AS remark,
se.coridc as coridc,se.enterprise_name as coridcName
FROM sys_coupon_detail scd
LEFT JOIN sys_user_coupon suc ON suc.coupon_detail_id = scd.id
LEFT JOIN sys_coupon sc ON sc.id = scd.coupon_id
LEFT JOIN sys_enterprise se ON se.id = sc.enterprise_id
where se.coridc = #{coridc} and sc.is_delete=1 and sc.status=1
and scd.is_delete=1
and (scd.is_receive>1 OR suc.is_use>1)
and suc.user_id=#{usridc}
</select>
<select id="getByCouponId" resultType="cn.wise.sc.consume.business.entity.SysCouponDetail">
select scd.*
......
......@@ -19,6 +19,11 @@
order by t.create_time desc
</select>
<select id="getByCoridc" resultType="cn.wise.sc.consume.business.entity.SysEnterprise">
select t.* from sys_enterprise t
where t.coridc = #{coridc}
</select>
<select id="getEnterpriseList" resultType="cn.wise.sc.consume.business.model.EnterpriseAppListVO">
......
......@@ -3,6 +3,7 @@ package cn.wise.sc.consume.business.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
......@@ -18,11 +19,27 @@ public class ReceivedAppListVO {
private Long id;
@ApiModelProperty("优惠券名称")
private String couponName;
@ApiModelProperty("优惠券码")
private String couponCode;
@ApiModelProperty("优惠券logo")
private String couponLogo;
@ApiModelProperty("截止日期")
private LocalDate endDate;
@ApiModelProperty("描述")
private String remark;
@ApiModelProperty("企业id")
private String coridc;
@ApiModelProperty("企业名称")
private String coridcName;
@ApiModelProperty("优惠券链接")
private String couponLink;
}
......@@ -17,7 +17,13 @@ import java.util.List;
public interface ISysCouponDetailService extends IService<SysCouponDetail> {
List<ReceivedAppListVO> getReceivedList(String coridc, String usridc );
List<ReceivedAppListVO> getReceivedList(String coridc,String usridc);
List<ReceivedAppListVO> getAllReceivedList(String usridc);
List<ReceivedAppListVO> getAllReceivedListSE(String coridc,String usridc);
List<ReceivedAppListVO> getOverdueList(String usridc);
List<ReceivedAppListVO> getOverdueListSE(String coridc,String usridc);
void beVerdue();
}
......@@ -64,6 +64,8 @@ public class CMBOneNetPayService {
private ISysCouponDetailService couponDetailService;
@Autowired
private ISysUserCouponService userCouponService;
@Resource
private SysEnterpriseMapper sysEnterpriseMapper;
/**
* 解析app端授权信息
......@@ -152,6 +154,28 @@ public class CMBOneNetPayService {
}
}
/**
* 查询发券企业信息
*
* @param coridc 企业ID
* @return
*/
public BaseResponse getIssEnterprise(String coridc) {
try {
if (!StringUtils.isNotBlank(coridc)) {
return BaseResponse.error("企业信息错误", this.getClass().getName());
}
SysEnterprise byCoridc = sysEnterpriseMapper.getByCoridc(coridc);
if (byCoridc == null){
return BaseResponse.ok();
}
return BaseResponse.ok("成功",byCoridc);
} catch (Exception e) {
log.error("企业信息异常! 参数:{}");
return BaseResponse.error(e.getMessage(), this.getClass().getName());
}
}
/**
* 企业列表 (展示审批通过的企业信息,和当前app的用户id是否已经绑定会员信息)
......@@ -247,19 +271,82 @@ ISysUserCouponService iSysUserCouponService;
}
}
/**已领取优惠券列表
*
* @param coridc 企业编号
* @param usridc 企业用户id
* @return
*/
public BaseResponse getReceivedList(String coridc, String usridc) {
public BaseResponse getReceivedList(String coridc,String usridc) {
try {
List<ReceivedAppListVO> list = couponDetailService.getReceivedList(coridc, usridc);
return BaseResponse.ok(list);
} catch (Exception e) {
log.error("领取优惠券异常异常! 参数:{}", coridc+","+usridc);
log.error("领取优惠券异常异常! 参数:{}",usridc);
return BaseResponse.error(e.getMessage(), this.getClass().getName());
}
}
/**已领取优惠券列表
*
* @param usridc 企业用户id
* @return
*/
public BaseResponse getAllReceivedList(String usridc) {
try {
List<ReceivedAppListVO> list = couponDetailService.getAllReceivedList(usridc);
Map<String, List<ReceivedAppListVO>> collect = list.stream().collect(Collectors.groupingBy(arg -> arg.getCoridc()));
return BaseResponse.ok(collect);
} catch (Exception e) {
log.error("领取优惠券异常异常! 参数:{}",usridc);
return BaseResponse.error(e.getMessage(), this.getClass().getName());
}
}
/**个人券夹(企业)
*
* @param usridc 企业用户id
* @return
*/
public BaseResponse getAllReceivedListSE(String coridc,String usridc) {
try {
List<ReceivedAppListVO> list = couponDetailService.getAllReceivedListSE(coridc, usridc);
// Map<String, List<ReceivedAppListVO>> collect = list.stream().collect(Collectors.groupingBy(arg -> arg.getCoridc()));
return BaseResponse.ok(list);
} catch (Exception e) {
log.error("领取优惠券异常异常! 参数:{}",usridc);
return BaseResponse.error(e.getMessage(), this.getClass().getName());
}
}
/**失效优惠券列表
*
* @param usridc 企业用户id
* @return
*/
public BaseResponse getOverdueList(String usridc) {
try {
List<ReceivedAppListVO> list = couponDetailService.getOverdueList(usridc);
return BaseResponse.ok(list);
} catch (Exception e) {
log.error("失效优惠券列表异常! 参数:{}",usridc);
return BaseResponse.error(e.getMessage(), this.getClass().getName());
}
}
/**失效优惠券列表(企业)
*
* @param usridc 企业用户id
* @return
*/
public BaseResponse getOverdueListSE(String coridc,String usridc) {
try {
List<ReceivedAppListVO> list = couponDetailService.getOverdueListSE(coridc, usridc);
return BaseResponse.ok(list);
} catch (Exception e) {
log.error("失效优惠券列表异常! 参数:{}",usridc);
return BaseResponse.error(e.getMessage(), this.getClass().getName());
}
}
......
......@@ -30,13 +30,38 @@ public class SysCouponDetailServiceImpl extends ServiceImpl<SysCouponDetailMappe
private SysUserCouponMapper userCouponMapper;
@Override
public List<ReceivedAppListVO> getReceivedList(String coridc, String usridc) {
public List<ReceivedAppListVO> getReceivedList(String coridc,String usridc) {
List<ReceivedAppListVO> list = couponDetailMapper.getReceivedList(coridc, usridc);
return list;
}
@Override
public List<ReceivedAppListVO> getAllReceivedList(String usridc) {
List<ReceivedAppListVO> list = couponDetailMapper.getAllReceivedList(usridc);
return list;
}
@Override
public List<ReceivedAppListVO> getAllReceivedListSE(String coridc,String usridc) {
List<ReceivedAppListVO> list = couponDetailMapper.getAllReceivedListSE(coridc, usridc);
return list;
}
@Override
public List<ReceivedAppListVO> getOverdueList(String usridc) {
List<ReceivedAppListVO> list = couponDetailMapper.getOverdueList(usridc);
return list;
}
@Override
public List<ReceivedAppListVO> getOverdueListSE(String coridc,String usridc) {
List<ReceivedAppListVO> list = couponDetailMapper.getOverdueListSE(coridc, usridc);
return list;
}
/**
* 筛选过期优惠券,将优惠券详情表:未领取的状态改成已过期。
* 优惠券领取表-未使用的状态改为已过期
......
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