添加获取购物车中商品可用优惠券接口

This commit is contained in:
zhh
2018-08-29 17:08:16 +08:00
parent 201b405a08
commit 61a67c9aa9
16 changed files with 604 additions and 79 deletions

View File

@@ -66,4 +66,12 @@ public class SmsCouponController {
List<SmsCoupon> couponList = couponService.list(name,type,pageSize,pageNum);
return new CommonResult().pageSuccess(couponList);
}
@ApiOperation("获取单个优惠券的详细信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id) {
SmsCouponParam couponParam = couponService.getItem(id);
return new CommonResult().success(couponParam);
}
}

View File

@@ -0,0 +1,12 @@
package com.macro.mall.dao;
import com.macro.mall.dto.SmsCouponParam;
import org.apache.ibatis.annotations.Param;
/**
* 优惠券管理自定义查询Dao
* Created by macro on 2018/8/29.
*/
public interface SmsCouponDao {
SmsCouponParam getItem(@Param("id") Long id);
}

View File

@@ -33,4 +33,10 @@ public interface SmsCouponService {
* 分页获取优惠券列表
*/
List<SmsCoupon> list(String name, Integer type, Integer pageSize, Integer pageNum);
/**
* 获取优惠券详情
* @param id 优惠券表id
*/
SmsCouponParam getItem(Long id);
}

View File

@@ -1,6 +1,7 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.SmsCouponDao;
import com.macro.mall.dao.SmsCouponProductCategoryRelationDao;
import com.macro.mall.dao.SmsCouponProductRelationDao;
import com.macro.mall.dto.SmsCouponParam;
@@ -31,6 +32,8 @@ public class SmsCouponServiceImpl implements SmsCouponService {
private SmsCouponProductRelationDao productRelationDao;
@Autowired
private SmsCouponProductCategoryRelationDao productCategoryRelationDao;
@Autowired
private SmsCouponDao couponDao;
@Override
public int add(SmsCouponParam couponParam) {
//插入优惠券表
@@ -112,4 +115,9 @@ public class SmsCouponServiceImpl implements SmsCouponService {
PageHelper.startPage(pageNum,pageSize);
return couponMapper.selectByExample(example);
}
@Override
public SmsCouponParam getItem(Long id) {
return couponDao.getItem(id);
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.macro.mall.dao.SmsCouponDao">
<resultMap id="couponItemParam" type="com.macro.mall.dto.SmsCouponParam" extends="com.macro.mall.mapper.SmsCouponMapper.BaseResultMap">
<collection property="productRelationList" columnPrefix="cpr_" resultMap="com.macro.mall.mapper.SmsCouponProductRelationMapper.BaseResultMap">
</collection>
<collection property="productCategoryRelationList" columnPrefix="cpcr_" resultMap="com.macro.mall.mapper.SmsCouponProductCategoryRelationMapper.BaseResultMap">
</collection>
</resultMap>
<select id="getItem" resultMap="couponItemParam">
SELECT
c.*,
cpr.id cpr_id,
cpr.product_id cpr_product_id,
cpcr.id cpcr_id,
cpcr.product_category_id cpcr_product_category_id
FROM
sms_coupon c
LEFT JOIN sms_coupon_product_relation cpr ON c.id = cpr.coupon_id
LEFT JOIN sms_coupon_product_category_relation cpcr ON c.id = cpcr.coupon_id
WHERE
c.id = #{id}
</select>
</mapper>