dcs 2 月之前
父節點
當前提交
b443ce330f

+ 6 - 6
virgo.api/src/main/java/com/bosshand/virgo/api/workark/controller/ProductCouponController.java

@@ -22,15 +22,15 @@ public class ProductCouponController {
     ProductCouponService productCouponService;
 
     @ApiOperation("新用户优惠券")
-    @RequestMapping(value = "/nowReceive/{organizationId}/{userId}", method = RequestMethod.GET)
-    public Response nowReceive(@PathVariable long organizationId, @PathVariable long userId) {
-        return Response.ok(productCouponService.nowReceive(organizationId, userId));
+    @RequestMapping(value = "/nowReceive/{userId}", method = RequestMethod.GET)
+    public Response nowReceive(@PathVariable long userId) {
+        return Response.ok(productCouponService.nowReceive(userId));
     }
 
     @ApiOperation("领取优惠券")
-    @RequestMapping(value = "/receive/{organizationId}/{userId}/{productCouponModelId}", method = RequestMethod.GET)
-    public Response receive(@PathVariable long organizationId, @PathVariable long userId, @PathVariable long productCouponModelId) {
-        productCouponService.receive(organizationId, userId, productCouponModelId);
+    @RequestMapping(value = "/receive/{userId}/{productCouponModelId}", method = RequestMethod.GET)
+    public Response receive(@PathVariable long userId, @PathVariable long productCouponModelId) {
+        productCouponService.receive(userId, productCouponModelId);
         return Response.ok();
     }
 

+ 1 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/workark/dao/ProductCouponDao.java

@@ -23,5 +23,5 @@ public interface ProductCouponDao {
 
     List<ProductCoupon> getLimit(@Param("p") ProductCoupon p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
 
-    List<ProductCoupon> getProductCouponModelId(long organizationId, long userId);
+    List<ProductCoupon> getProductCouponModelId(long userId);
 }

+ 13 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/ProductCouponModel.java

@@ -12,6 +12,11 @@ public class ProductCouponModel {
 
     private Long id;
 
+    /**
+     * 组织id
+     */
+    private long organizationId;
+
     /**
      * 类型(1、打折,2、现金)
      */
@@ -76,6 +81,14 @@ public class ProductCouponModel {
         this.id = id;
     }
 
+    public long getOrganizationId() {
+        return organizationId;
+    }
+
+    public void setOrganizationId(long organizationId) {
+        this.organizationId = organizationId;
+    }
+
     public Integer getType() {
         return type;
     }

+ 3 - 4
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/ProductCouponService.java

@@ -49,8 +49,8 @@ public class ProductCouponService {
         return productCouponDao.get(id);
     }
 
-    public List<ProductCouponModel> nowReceive(long organizationId, long userId) {
-        List<ProductCoupon> list = productCouponDao.getProductCouponModelId(organizationId, userId);
+    public List<ProductCouponModel> nowReceive(long userId) {
+        List<ProductCoupon> list = productCouponDao.getProductCouponModelId(userId);
         if (list.size() == 0) {
             return productCouponModelDao.getAll();
         }
@@ -59,11 +59,10 @@ public class ProductCouponService {
         return productCouponModelDao.nowReceive(ids);
     }
 
-    public void receive(long organizationId, long userId, long productCouponModelId) {
+    public void receive(long userId, long productCouponModelId) {
         ProductCouponModel productCouponModel = productCouponModelDao.get(productCouponModelId);
         ProductCoupon productCoupon = new ProductCoupon();
         BeanUtils.copyProperties(productCouponModel, productCoupon);
-        productCoupon.setOrganizationId(organizationId);
         productCoupon.setUserId(userId);
         productCoupon.setProductCouponModelId(productCouponModel.getId());
         productCouponDao.save(productCoupon);

+ 1 - 1
virgo.api/src/main/resources/mapper/ProductCouponMapper.xml

@@ -31,7 +31,7 @@
     </select>
 
     <select id="getProductCouponModelId" resultMap="result">
-        select id from workark_product_coupon where organizationId = #{organizationId} and userId = #{userId} and productCouponModelId != 0
+        select id from workark_product_coupon where userId = #{userId} and productCouponModelId != 0
     </select>
 
     <select id="getList" resultMap="result">

+ 13 - 2
virgo.api/src/main/resources/mapper/ProductCouponModelMapper.xml

@@ -6,6 +6,7 @@
 
     <resultMap type="com.bosshand.virgo.api.workark.model.ProductCouponModel" id="result">
         <id column="id" property="id"/>
+        <result column="organizationId" property="organizationId"/>
         <result column="type" property="type"/>
         <result column="otherType" property="otherType"/>
         <result column="discount" property="discount"/>
@@ -38,6 +39,9 @@
     <select id="getList" resultMap="result">
         select * from workark_product_coupon_model
         <where>
+            <if test="organizationId != 0">
+                and organizationId = #{organizationId}
+            </if>
             <if test="type != null">
                 and type = #{type}
             </if>
@@ -53,6 +57,9 @@
     <select id="getTotalCount" parameterType="com.bosshand.virgo.api.workark.model.ProductCouponModel" resultType="Integer">
         SELECT count(*) FROM workark_product_coupon_model
         <where>
+            <if test="organizationId != 0">
+                and organizationId = #{organizationId}
+            </if>
             <if test="type != null">
                 and type = #{type}
             </if>
@@ -68,6 +75,9 @@
     <select id="getLimit" resultMap="result">
         select * from workark_product_coupon_model
         <where>
+            <if test="p.organizationId != 0">
+                and organizationId = #{p.organizationId}
+            </if>
             <if test="p.type != null">
                 and type = #{p.type}
             </if>
@@ -82,13 +92,14 @@
     </select>
 
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
-        INSERT INTO workark_product_coupon_model (type, otherType, discount, createTime, lifespan, productLevelId, couponAmount, title, threshold, mostConstraint, description)
-        VALUES (#{type}, #{otherType}, #{discount}, now(), #{lifespan}, #{productLevelId}, #{couponAmount}, #{title}, #{threshold}, #{mostConstraint}, #{description})
+        INSERT INTO workark_product_coupon_model (organizationId, type, otherType, discount, createTime, lifespan, productLevelId, couponAmount, title, threshold, mostConstraint, description)
+        VALUES (#{organizationId}, #{type}, #{otherType}, #{discount}, now(), #{lifespan}, #{productLevelId}, #{couponAmount}, #{title}, #{threshold}, #{mostConstraint}, #{description})
     </insert>
 
     <update id="update" parameterType="com.bosshand.virgo.api.workark.model.ProductCouponModel">
         UPDATE workark_product_coupon_model
         <trim prefix="set" suffixOverrides=",">
+            <if test="organizationId!=0">organizationId=#{organizationId},</if>
             <if test="type!=null">type=#{type},</if>
             <if test="otherType!=null">otherType=#{otherType},</if>
             <if test="discount!=null">discount=#{discount},</if>