| @@ -355,4 +355,13 @@ public class WxCouponController extends BaseController { | |||
| couponPasswordService.exportData(request, response, wxCouponPassword); | |||
| } | |||
| @ApiOperation("根据id获取富文本接口") | |||
| @GetMapping("/getHtml") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券投放-富文本获取") | |||
| public ResultData getHtml(@RequestParam Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||
| return new ResultData(wxCouponService.getHtmlById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,3 @@ | |||
| ALTER TABLE `wx_coupon` | |||
| ADD COLUMN `content_type` tinyint(1) NULL COMMENT '内容类型(0:小程序页面类型,1:富文本类型)' AFTER `approval_type`, | |||
| ADD COLUMN `html` mediumtext NULL COMMENT '富文本内容' AFTER `content_type`; | |||
| @@ -5,10 +5,7 @@ import com.iformall.annotation.RedisCache; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.EnumCouponValidType; | |||
| @@ -83,8 +80,8 @@ public class WxCouponOrderController extends BaseController { | |||
| @GetMapping("listUnverified") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "date", value = "日期yyyy-MM-dd", dataType = "string", paramType = "query"), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query",required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query",required = true)}) | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listUnverified(String date, Integer pageNum, Integer pageSize) { | |||
| return wxCouponOrderService.listOnDateAsPage(getUser().getId(), date, pageNum, pageSize, false); | |||
| } | |||
| @@ -93,8 +90,8 @@ public class WxCouponOrderController extends BaseController { | |||
| @GetMapping("listVerified") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "date", value = "日期yyyy-MM-dd", dataType = "string", paramType = "query"), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query",required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query",required = true)}) | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listVerified(String date, Integer pageNum, Integer pageSize) { | |||
| return wxCouponOrderService.listOnDateAsPage(getUser().getId(), date, pageNum, pageSize, true); | |||
| } | |||
| @@ -124,8 +121,8 @@ public class WxCouponOrderController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponOrderId", value = "券ID", dataType = "string", paramType = "query", required = true) | |||
| }) | |||
| public ResultData detail(String couponOrderId) { | |||
| if(couponOrderId == null) { | |||
| public ResultData detail(String couponOrderId) { | |||
| if (couponOrderId == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| Long bUserId = getUser().getId(); | |||
| @@ -185,10 +182,53 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(wxCouponOrderCVo); | |||
| } | |||
| @ApiOperation(value = "卡券富文本接口") | |||
| @GetMapping("html") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponOrderId", value = "券ID", dataType = "string", paramType = "query", required = true) | |||
| }) | |||
| public ResultData getHtml(String couponOrderId) { | |||
| if (couponOrderId == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxCouponOrderCVo wxCouponOrderCVo = null; | |||
| try { | |||
| wxCouponOrderCVo = wxCouponOrderService.simpleDetailCUserVo(couponOrderId); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| if (wxCouponOrderCVo == null) { | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| WxCouponCVo wxCouponCVo = null; | |||
| String key = "ch:" + wxCouponOrderCVo.getCouponId(); | |||
| ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); | |||
| // 缓存 | |||
| boolean hasKey = cdRedisTemplate.hasKey(key); | |||
| if (hasKey) { | |||
| // 从缓存获取用户信息 | |||
| wxCouponCVo = operations.get(key); | |||
| if (wxCouponCVo == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| } else { | |||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponOrderCVo.getCouponId()); | |||
| if (wxCoupon == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| wxCouponCVo = new WxCouponCVo(); | |||
| wxCouponCVo.setId(wxCouponOrderCVo.getCouponId()); | |||
| wxCouponCVo.setHtml(wxCoupon.getHtml()); | |||
| // 插入缓存 | |||
| operations.set(key, wxCouponCVo, 3600, TimeUnit.SECONDS); | |||
| } | |||
| return new ResultData(wxCouponOrderCVo); | |||
| } | |||
| @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") | |||
| @PostMapping("verify") | |||
| public ResultData verify(@RequestBody Map<String, String> paramMap) { | |||
| logger.info("couponOrderController.verify:"+paramMap.toString()); | |||
| logger.info("couponOrderController.verify:" + paramMap.toString()); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| logger.error("couponOrderId不能为空: " + paramMap.toString()); | |||
| @@ -253,7 +293,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); | |||
| } | |||
| if(couponOrder != null) { | |||
| if (couponOrder != null) { | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, wxMerchantBUser.getId()); | |||
| } | |||
| @@ -292,6 +332,4 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| } | |||
| @@ -128,6 +128,53 @@ public class WxCouponController extends BaseController { | |||
| return new ResultData(wxCouponCVo); | |||
| } | |||
| @ApiOperation("根据id(couponChannel)查询富文本接口") | |||
| @GetMapping("/html") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query", required = false)}) | |||
| public ResultData getHtml(String couponChannelId, String couponId) { | |||
| if (StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId/couponId为空"); | |||
| } | |||
| Long couponChannelIdL = 0L, couponIdL = 0L; | |||
| try { | |||
| couponChannelIdL = Long.valueOf(couponChannelId); | |||
| if (StringUtils.isNotBlank(couponId) && !couponId.equalsIgnoreCase(Constant.UNDEFINED)) { | |||
| couponIdL = Long.valueOf(couponId); | |||
| } | |||
| } catch (NumberFormatException e) { | |||
| logger.error("id转换失败" + couponChannelId); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); | |||
| } | |||
| String key = "ch:" + couponChannelId; | |||
| ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); | |||
| // 缓存 | |||
| boolean hasKey = cdRedisTemplate.hasKey(key); | |||
| if (hasKey) { | |||
| // 从缓存获取用户信息 | |||
| WxCouponCVo wxCouponCVo = operations.get(key); | |||
| return new ResultData(wxCouponCVo); | |||
| } | |||
| WxCouponCVo wxCouponCVo = null; | |||
| try { | |||
| wxCouponCVo = generateWxCouponCVoForHtml(couponChannelIdL, couponIdL); | |||
| } catch (Exception e) { | |||
| logger.error("coupon html fail: " + couponChannelId,e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "coupon html fail: " + couponChannelId); | |||
| } | |||
| if (wxCouponCVo == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| // 插入缓存 | |||
| operations.set(key, wxCouponCVo, 3600, TimeUnit.SECONDS); | |||
| return new ResultData(wxCouponCVo); | |||
| } | |||
| private WxCouponCVo generateWxCouponCVo(Long couponChannelIdL) { | |||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL); | |||
| @@ -148,6 +195,24 @@ public class WxCouponController extends BaseController { | |||
| return couponCVo; | |||
| } | |||
| private WxCouponCVo generateWxCouponCVoForHtml(Long couponChannelIdL, Long couponIdL) { | |||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL); | |||
| if (cc == null) { | |||
| return null; | |||
| } | |||
| WxCoupon c = couponService.getHtmlById(cc.getCouponId()); | |||
| if (c == null) { | |||
| return null; | |||
| } | |||
| WxCouponCVo couponCVo = new WxCouponCVo(); | |||
| couponCVo.setId(cc.getId()); | |||
| couponCVo.setCouponId(cc.getCouponId()); | |||
| couponCVo.setHtml(c.getHtml()); | |||
| return couponCVo; | |||
| } | |||
| private WxCouponCVo generateWxCouponCVoex(Long couponChannelIdL) throws IllegalAccessException, InvocationTargetException { | |||
| WxCouponChannel cc = wxCouponChannelService.getById(couponChannelIdL); | |||
| @@ -174,6 +174,11 @@ public class WxCoupon extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="作废审批状态",name="cancleApplyStatus") | |||
| private Integer cancleApplyStatus; | |||
| @io.swagger.annotations.ApiModelProperty(value="内容类型(0:小程序页面类型,1:富文本类型)",name="contentType") | |||
| private Integer contentType; | |||
| @io.swagger.annotations.ApiModelProperty(value="富文本内容",name="html") | |||
| private String html; | |||
| @TableField(exist = false) | |||
| @SortColumn(column = "press_count") | |||
| private Integer pressSendCount; | |||
| @@ -69,6 +69,9 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="领取条件",name="condition") | |||
| private String conditions; | |||
| @io.swagger.annotations.ApiModelProperty(value="内容类型(0:小程序页面类型,1:富文本类型)",name="contentType") | |||
| private Integer contentType; | |||
| @TableField(exist = false) | |||
| private String salePriceStr; | |||
| @@ -0,0 +1,37 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumCouponContentType { | |||
| // 0: 小程序页面, 1: 富文本页面 | |||
| NORMAL(0, "小程序页面"), | |||
| HTML(1,"富文本") | |||
| ; | |||
| public static EnumCouponContentType getEnum(Integer code) { | |||
| for (EnumCouponContentType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCouponContentType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -54,6 +54,8 @@ public interface WxCouponService { | |||
| */ | |||
| WxCoupon getById(Long id); | |||
| WxCoupon getHtmlById(Long id); | |||
| WxCouponCVo getVoById(Long id); | |||
| @@ -172,6 +172,12 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| @Override | |||
| public WxCoupon getById(Long id) { | |||
| // TODO 富文本优化 | |||
| return wxCouponMapper.selectById(id); | |||
| } | |||
| @Override | |||
| public WxCoupon getHtmlById(Long id) { | |||
| return wxCouponMapper.selectById(id); | |||
| } | |||
| @@ -267,6 +273,12 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| } | |||
| } | |||
| if (record.getContentType().equals(EnumCouponContentType.HTML.getCode())) { | |||
| if (StringUtils.isEmpty(record.getHtml())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "请填写富文本内容"); | |||
| } | |||
| } | |||
| List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | |||
| //有价券判断商户是否配置了分账账号 | |||
| if (record.getSalePrice() != null && record.getSalePrice() > 0) { | |||
| @@ -138,7 +138,7 @@ | |||
| <include refid="allColumns" />, | |||
| c.remain_inventory,c.inventory,c.cover_img,c.title,c.sub_title,c.sale_price, | |||
| c.use_price,c.price,c.unit,c.use_limit_quantity,c.send_type,c.support_transfer,c.press_limit_num,c.auto_refund,c.conditions, | |||
| c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.credit_price | |||
| c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.credit_price,c.content_type | |||
| </sql> | |||
| <resultMap id="CouponChannelVoMap" type="com.iformall.domain.vo.WxCouponChannelVo"> | |||
| @@ -175,6 +175,7 @@ | |||
| <result column="valid_days" jdbcType="INTEGER" property="validDays"/> | |||
| <result column="qr_code" property="qrCode"/> | |||
| <result column="conditions" jdbcType="VARCHAR" property="conditions" /> | |||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | |||
| <collection column="{productId=coupon_id}" property="merchantVoList" | |||
| @@ -219,7 +220,7 @@ | |||
| c.tenant_id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.sale_price,c.use_price, | |||
| c.use_limit_quantity,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,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions, | |||
| c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions,c.content_type, | |||
| cc.qr_code | |||
| </sql> | |||
| @@ -266,6 +267,7 @@ | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| <result column="qr_code" property="qrCode"/> | |||
| <result column="conditions" jdbcType="VARCHAR" property="conditions" /> | |||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | |||
| <collection column="{productId=coupon_id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| @@ -313,6 +315,7 @@ | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| <result column="qr_code" property="qrCode"/> | |||
| <result column="conditions" jdbcType="VARCHAR" property="conditions" /> | |||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | |||
| </resultMap> | |||
| <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap"> | |||
| @@ -44,6 +44,8 @@ | |||
| <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | |||
| <result column="approval_type" property="approvalType"/> | |||
| <result column="password_support" property="passwordSupport"/> | |||
| <result column="content_type" property="contentType"/> | |||
| <result column="html" property="html"/> | |||
| </resultMap> | |||
| <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| @@ -95,7 +97,8 @@ | |||
| `id`,`tenant_id`,`type`,`cover_img`,`cover_picture`,`detail_picture`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`, | |||
| `valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`, | |||
| `remark`,`status`,`create_date`,`update_date`,`business`,`sub_business`,`support_transfer`,`subsidy_num`,`subsidy_type`, | |||
| `press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund`,`put_apply_status`,`stock_apply_status`,`cancle_apply_status`,`conditions`,approval_type | |||
| `press_limit_num`, `press_limit_hours`, `auto_refund`,`credit_price`,`credit_refund`,`put_apply_status`,`stock_apply_status`,`cancle_apply_status`, | |||
| `conditions`,approval_type,content_type | |||
| </sql> | |||
| <sql id="statusColumns"> | |||
| @@ -241,6 +244,10 @@ | |||
| and `credit_refund` = #{creditRefund} | |||
| </if> | |||
| <if test=" null != contentType "> | |||
| and `content_type` = #{contentType} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -415,6 +422,10 @@ | |||
| and c.`auto_refund` = #{autoRefund} | |||
| </if> | |||
| <if test=" null != contentType "> | |||
| and c.`content_type` = #{contentType} | |||
| </if> | |||
| <!--如果配置了审批模板,需要过滤投放审批状态--> | |||
| <if test="0 != filterCanPut or null ==filterCanPut "> | |||
| <if test=" null != pressModelId and 0l != pressModelId"> | |||
| @@ -466,9 +477,6 @@ | |||
| <include refid="dynamicWhereConditionsForCoupon"/> | |||
| </select> | |||
| <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| @@ -503,6 +511,7 @@ | |||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | |||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | |||
| <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | |||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | |||
| <collection column="{productId=id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| @@ -545,6 +554,7 @@ | |||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | |||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | |||
| <result column="conditions" jdbcType="VARCHAR" property="conditions"/> | |||
| <result column="content_type" jdbcType="INTEGER" property="contentType"/> | |||
| </resultMap> | |||
| <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap"> | |||