| @@ -17,8 +17,10 @@ import com.simple.utils.TJDCarUtil; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import io.swagger.models.auth.In; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.log4j.Logger; | |||
| import org.apache.poi.hmef.attribute.MAPIAttribute; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @@ -258,4 +260,42 @@ public class WxCarController extends BaseController | |||
| return new ResultData(id); | |||
| } | |||
| @ApiOperation("优免券模板已分配总数") | |||
| @GetMapping("/templateAmtCount") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="templateId",value="模板ID",dataType="Long", paramType = "query",required=true)}) | |||
| public ResultData getTemplateAmountSum(Long templateId) { | |||
| Map map = new HashMap(); | |||
| Integer amountCount = 0; | |||
| try { | |||
| amountCount = wxCouponCarService.getAmtCountByTemplateId(templateId); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| map.put("amountCount", amountCount); | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation("停车券detail") | |||
| @GetMapping("/detail") | |||
| public ResultData getCouponCarDetail(@ModelAttribute WxCoupon coupon) { | |||
| MallUserInfo user = getUser(); | |||
| coupon.setTenantId(user.getTenantId()); | |||
| try { | |||
| WxCouponCarVo couponCarVo = wxCouponCarService.getByCoupon(coupon); | |||
| if (couponCarVo != null) { | |||
| return new ResultData(couponCarVo); | |||
| } else { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(), "券不存在"); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -128,6 +128,9 @@ public class WxCouponCarVo implements Serializable { | |||
| /*业态**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="业态",name="business") | |||
| private String business; | |||
| /*车场厂商类型**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="车场厂商类型1:ETCP,2:TJD",name="vendorType") | |||
| private String vendorType; | |||
| /*车场厂商相关信息**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="车场厂商相关信息",name="vendorParams") | |||
| private String vendorParams; | |||
| @@ -282,6 +285,14 @@ public class WxCouponCarVo implements Serializable { | |||
| business = _business; | |||
| } | |||
| public String getVendorType() { | |||
| return vendorType; | |||
| } | |||
| public void setVendorType(String vendorType) { | |||
| this.vendorType = vendorType; | |||
| } | |||
| public String getVendorParams() { | |||
| return vendorParams; | |||
| } | |||
| @@ -2,6 +2,8 @@ package com.simple.mapper; | |||
| import java.util.*; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.vo.WxCouponCarVo; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.simple.domain.po.WxCouponCar; | |||
| @@ -10,8 +12,8 @@ public interface WxCouponCarMapper extends CommonMapper<WxCouponCar, String> { | |||
| List<WxCouponCar> findList(WxCouponCar wxCouponCar); | |||
| Integer findTemplateAmtCount(Long templateId); | |||
| WxCouponCarVo selectCouponCarDetail(WxCoupon coupon); | |||
| } | |||
| @@ -2,7 +2,9 @@ package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.po.WxCouponCar; | |||
| import com.simple.domain.vo.WxCouponCarVo; | |||
| public interface WxCouponCarService { | |||
| @@ -44,11 +46,21 @@ public interface WxCouponCarService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| /** | |||
| * 根据templateId获取分配总数 | |||
| * | |||
| * @param templateId | |||
| */ | |||
| Integer getAmtCountByTemplateId(Long templateId); | |||
| /** | |||
| * 根据coupon获得实体 | |||
| * | |||
| * @param coupon | |||
| * @return | |||
| */ | |||
| WxCouponCarVo getByCoupon(WxCoupon coupon); | |||
| @@ -3,7 +3,9 @@ package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.po.WxCouponCar; | |||
| import com.simple.domain.vo.WxCouponCarVo; | |||
| import com.simple.mapper.WxCouponCarMapper; | |||
| import com.simple.service.WxCouponCarService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -41,10 +43,17 @@ public class WxCouponCarServiceImpl implements WxCouponCarService { | |||
| public void deleteById(Long id) { | |||
| wxCouponCarMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public Integer getAmtCountByTemplateId(Long templateId) { | |||
| return wxCouponCarMapper.findTemplateAmtCount(templateId); | |||
| } | |||
| @Override | |||
| public WxCouponCarVo getByCoupon(WxCoupon coupon) { | |||
| return wxCouponCarMapper.selectCouponCarDetail(coupon); | |||
| } | |||
| @@ -71,9 +71,61 @@ | |||
| select <include refid="allColumns" /> from wx_coupon_car | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| <select id="findTemplateAmtCount" parameterType="Long" resultType="Integer"> | |||
| select sum(c.inventory) as count | |||
| from wx_coupon_car car, wx_coupon c | |||
| where car.id = c.id and json_extract(vendor_params,'$.id') = ${value} | |||
| </select> | |||
| <resultMap id="CouponCarMap" type="com.simple.domain.vo.WxCouponCarVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="type" jdbcType="INTEGER" property="type" /> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg" /> | |||
| <result column="title" jdbcType="VARCHAR" property="title" /> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle" /> | |||
| <result column="sale_price" jdbcType="INTEGER" property="salePrice" /> | |||
| <result column="use_price" jdbcType="INTEGER" property="usePrice" /> | |||
| <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity" /> | |||
| <result column="target_ad" jdbcType="INTEGER" property="targetAd" /> | |||
| <result column="send_type" jdbcType="INTEGER" property="sendType" /> | |||
| <result column="valid_type" jdbcType="INTEGER" property="validType" /> | |||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate" /> | |||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate" /> | |||
| <result column="valid_days" jdbcType="INTEGER" property="validDays" /> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail" /> | |||
| <result column="price" jdbcType="INTEGER" property="price" /> | |||
| <result column="unit" jdbcType="INTEGER" property="unit" /> | |||
| <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory" /> | |||
| <result column="inventory" jdbcType="INTEGER" property="inventory" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="status" jdbcType="INTEGER" property="status" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="business" jdbcType="VARCHAR" property="business" /> | |||
| <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | |||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | |||
| </resultMap> | |||
| <sql id="CouponCarColumns"> | |||
| c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.target_ad,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business, | |||
| car.vendor_type, car.vendor_params | |||
| </sql> | |||
| <select id="selectCouponCarDetail" parameterType="com.simple.domain.vo.WxCouponCarVo" resultMap="CouponCarMap"> | |||
| select <include refid="CouponCarColumns" /> | |||
| from | |||
| wx_coupon c,wx_coupon_car car | |||
| where c.id = car.id | |||
| <if test=" null != id "> | |||
| and c.id = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and c.tenant_id = #{tenantId} | |||
| </if> | |||
| </select> | |||