| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.vo.WxCardCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.EnumCouponOrderStatus; | |||
| import com.iformall.service.WxCouponOrderService; | |||
| @@ -52,7 +53,7 @@ public class WxCouponOrderController extends BaseController { | |||
| return wxCouponOrderService.listCUserVoAsPage(wxCouponOrder, pageNum, pageSize); | |||
| } | |||
| @ApiOperation(value = "卡券详情接口") | |||
| @ApiOperation(value = "券详情接口") | |||
| @GetMapping("detail") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponOrderId", value = "券ID", dataType = "string", paramType = "query", required = true) | |||
| @@ -91,19 +92,33 @@ public class WxCouponOrderController extends BaseController { | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| public ResultData cardList(@ModelAttribute WxCouponOrder wxCouponOrder, Integer pageNum, Integer pageSize) { | |||
| public ResultData cardList(@ModelAttribute WxCardCVo cardCVo, Integer pageNum, Integer pageSize) { | |||
| if (pageNum == null || pageSize == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderCVo(); | |||
| wxCouponOrder.setCUserId(getUser().getId()); | |||
| if (wxCouponOrder.getCouponOrderStatus() == null) | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| else if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()) | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| if (cardCVo == null) cardCVo = new WxCardCVo(); | |||
| cardCVo.setOwnerId(getUserId()); | |||
| if (cardCVo.getCouponOrderStatus() == null) | |||
| cardCVo.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| else if (cardCVo.getCouponOrderStatus() == EnumCouponOrderStatus.CARD_USING.getCode()) | |||
| cardCVo.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | |||
| else | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); | |||
| return wxCouponOrderService.listCUserVoAsPage(wxCouponOrder, pageNum, pageSize); | |||
| cardCVo.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); | |||
| return wxCouponOrderService.listCardVoAsPage(cardCVo, pageNum, pageSize); | |||
| } | |||
| @ApiOperation(value = "卡券详情接口") | |||
| @GetMapping("cardDetail") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "couponOrderId", value = "券ID", dataType = "string", paramType = "query", required = true) | |||
| }) | |||
| public ResultData cardDetail(String couponOrderId) { | |||
| if (couponOrderId == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return wxCouponOrderService.cardDetailCUserVo(getUserId(), couponOrderId); | |||
| } | |||
| } | |||
| @@ -41,11 +41,11 @@ public class WxCouponOrder implements Serializable { | |||
| } | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "tenantId") | |||
| /**租户ID*/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||
| private String tenantId; | |||
| /*单张券ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "单张券ID", name = "couponId") | |||
| /**卡券ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "卡券ID", name = "couponId") | |||
| private Long couponId; | |||
| /**券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,7.类储值卡) */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,7.类储值卡)", name = "couponType") | |||
| @@ -56,25 +56,25 @@ public class WxCouponOrder implements Serializable { | |||
| /**持有者ID*/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "持有者ID", name = "ownerId") | |||
| private Long ownerId; | |||
| /*操作券B端小程序用户ID**/ | |||
| /**操作券B端小程序用户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "操作券B端小程序用户ID", name = "bUserId") | |||
| private Long bUserId; | |||
| /*用户订单ID**/ | |||
| /**用户订单ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "用户订单ID", name = "orderId") | |||
| private Long orderId; | |||
| /*该订单对应券的实际过期时间**/ | |||
| /**该订单对应券的实际过期时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "该订单对应券的实际过期时间 ", name = "expiredTime") | |||
| private Date expiredTime; | |||
| /*状态:0,待使用 1,已核销 2,已过期 3,已作废 **/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "状态:0,待使用 1,已核销 2,已过期 3,已作废 ", name = "couponOrderStatus") | |||
| /**状态:0-待使用 1-已核销 2-已过期 3-已作废 4-卡使用中 5-卡已过期 6-卡已用完 7-卡已线下退款**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "状态:0-待使用 1-已核销 2-已过期 3-已作废 4-卡使用中 5-卡已过期 6-卡已用完 7-卡已线下退款", name = "couponOrderStatus") | |||
| private Integer couponOrderStatus; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "createDate") | |||
| /**创建时间*/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||
| private Date createDate; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "updateDate") | |||
| /**更新时间*/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate") | |||
| private Date updateDate; | |||
| /*单券实际购买价格**/ | |||
| /**单券实际购买价格**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "单券实际购买价格", name = "couponPrice") | |||
| private Integer couponPrice; | |||
| @@ -0,0 +1,176 @@ | |||
| package com.iformall.domain.vo; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import com.iformall.domain.po.WxCardSpend; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Transient; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @JsonIgnoreProperties(value = {"handler"}) | |||
| public class WxCardCVo extends WxCouponOrder { | |||
| /** | |||
| * | |||
| */ | |||
| private static final long serialVersionUID = 6687954932922444531L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| } | |||
| public void setId(Long id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<Long> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<Long> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /* 券类型信息 */ | |||
| /**封面图**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg") | |||
| private String coverImg; | |||
| /**券名称**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") | |||
| private String title; | |||
| /**副标题**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle") | |||
| private String subTitle; | |||
| /**单位**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="单位0:钱分,1:小时",name="unit") | |||
| private Integer unit; | |||
| /**须知**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="须知",name="detail") | |||
| private String detail; | |||
| /**购买须知**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | |||
| private String remark; | |||
| /*发券商户信息*/ | |||
| /**商户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户id",name="merchantId") | |||
| private Long merchantId; | |||
| /**使用商户名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户名",name="name") | |||
| private String merchantName; | |||
| /**发券商户信息*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList") | |||
| private List<WxMerchantVo> merchantVoList; | |||
| /**卡信息*/ | |||
| /**卡面额总金额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "卡面额总金额", name = "amount") | |||
| private Integer amount; | |||
| /**卡面额余额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "卡面额余额", name = "remainingAmount") | |||
| private Integer remainingAmount; | |||
| /**卡消费信息*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="卡消费列表",name="cardSpendList") | |||
| private List<WxCardSpend> cardSpendList; | |||
| public List<WxMerchantVo> getMerchantVoList() { | |||
| return merchantVoList; | |||
| } | |||
| public void setMerchantVoList(List<WxMerchantVo> merchantVoList) { | |||
| this.merchantVoList = merchantVoList; | |||
| } | |||
| public Long getMerchantId() { | |||
| return merchantId; | |||
| } | |||
| public void setMerchantId(Long _merchantId) { | |||
| merchantId = _merchantId; | |||
| } | |||
| public String getCoverImg() { | |||
| return coverImg; | |||
| } | |||
| public void setCoverImg(String _coverImg) { | |||
| coverImg = _coverImg; | |||
| } | |||
| public String getTitle() { | |||
| return title; | |||
| } | |||
| public void setTitle(String _title) { | |||
| title = _title; | |||
| } | |||
| public String getSubTitle() { | |||
| return subTitle; | |||
| } | |||
| public void setSubTitle(String _subTitle) { | |||
| subTitle = _subTitle; | |||
| } | |||
| public String getDetail() { | |||
| return detail; | |||
| } | |||
| public void setDetail(String _detail) { | |||
| detail = _detail; | |||
| } | |||
| public Integer getUnit() { | |||
| return unit; | |||
| } | |||
| public void setUnit(Integer unit) { | |||
| this.unit = unit; | |||
| } | |||
| public String getRemark() { | |||
| return remark; | |||
| } | |||
| public void setRemark(String _remark) { | |||
| remark = _remark; | |||
| } | |||
| public String getMerchantName() { | |||
| return merchantName; | |||
| } | |||
| public void setMerchantName(String _name) { | |||
| merchantName = _name; | |||
| } | |||
| public Integer getAmount() { | |||
| return amount; | |||
| } | |||
| public void setAmount(Integer amount) { | |||
| this.amount = amount; | |||
| } | |||
| public Integer getRemainingAmount() { | |||
| return remainingAmount; | |||
| } | |||
| public void setRemainingAmount(Integer remainingAmount) { | |||
| this.remainingAmount = remainingAmount; | |||
| } | |||
| public List<WxCardSpend> getCardSpendList() { | |||
| return cardSpendList; | |||
| } | |||
| public void setCardSpendList(List<WxCardSpend> cardSpendList) { | |||
| this.cardSpendList = cardSpendList; | |||
| } | |||
| } | |||
| @@ -99,5 +99,6 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| List<WxCouponOrder> findExpiredCouponOrderByValidDate(); | |||
| //// 卡相关接口 | |||
| List<WxCouponOrderCVo> findCardListOfCUser(WxCouponOrder wxCouponOrder); | |||
| List<WxCardCVo> findCardListOfCUser(WxCouponOrder wxCouponOrder); | |||
| WxCardCVo findCardDetailOfCUser(@Param("id")Long id); | |||
| } | |||
| @@ -5,7 +5,7 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.vo.CUserDateAmountVo; | |||
| import com.iformall.domain.vo.*; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @@ -13,10 +13,6 @@ import java.util.List; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import com.iformall.domain.vo.WxCouponOrderBVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCarCVo; | |||
| public interface WxCouponOrderService { | |||
| /** | |||
| @@ -169,7 +165,12 @@ public interface WxCouponOrderService { | |||
| * @param record C端用户 | |||
| */ | |||
| ResultData listCardVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize); | |||
| ResultData listCardVoAsPage(WxCardCVo record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * C用户查卡详情 | |||
| * | |||
| * @param ownerId C端用户 | |||
| */ | |||
| ResultData cardDetailCUserVo(Long ownerId, String couponOrderId); | |||
| } | |||
| @@ -13,10 +13,7 @@ import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxSharingOrderDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.CUserDateAmountVo; | |||
| import com.iformall.domain.vo.WxCouponOrderBVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCarCVo; | |||
| import com.iformall.domain.vo.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| @@ -589,8 +586,22 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| public ResultData listCardVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | |||
| public ResultData listCardVoAsPage(WxCardCVo record, Integer pageIndex, Integer pageSize) { | |||
| return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCardListOfCUser(record))); | |||
| } | |||
| @Override | |||
| public ResultData cardDetailCUserVo(Long ownerId, String couponOrderId) { | |||
| WxCUser wxCuser = wxCUserMapper.selectByPrimaryKey(ownerId); | |||
| if (wxCuser == null) { | |||
| logger.error("用户不存在:" + ownerId); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| WxCardCVo cardCVo = wxCouponOrderMapper.findCardDetailOfCUser(Long.valueOf(couponOrderId)); | |||
| if (cardCVo == null) | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| return new ResultData(cardCVo); | |||
| } | |||
| } | |||
| @@ -528,7 +528,11 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| couponOrder.setOwnerId(user.getId()); | |||
| couponOrder.setOrderId(order.getOrderNumber()); | |||
| couponOrder.setExpiredTime(valid_date); | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| if(!coupon.getType().equals(EnumCouponType.CARD_MULTIMCH)) { | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| } else { | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.CARD_USING.getCode()); | |||
| } | |||
| couponOrder.setCreateDate(curr); | |||
| couponOrder.setUpdateDate(curr); | |||
| couponOrder.setCouponPrice(order.getPayment()); | |||
| @@ -87,7 +87,4 @@ | |||
| </mapper> | |||
| @@ -569,26 +569,7 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap"> | |||
| select <include refid="allCUserCouponOrderListColumns" /> | |||
| from wx_coupon_order co,wx_coupon c | |||
| where 1=1 | |||
| and co.coupon_id = c.id | |||
| and co.coupon_type == 7 | |||
| <if test="cUserId != null"> | |||
| and co.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test="ownerId != null"> | |||
| and co.owner_id = #{ownerId} | |||
| </if> | |||
| <if test="tenantId != null"> | |||
| and co.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test="couponOrderStatus != null"> | |||
| AND co.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <select id="findDetailOfCUser" parameterType="java.lang.Long" resultMap="CVoResultMap"> | |||
| @@ -656,4 +637,82 @@ | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <resultMap id="CCardVoResultMap" type="com.iformall.domain.vo.WxCardCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| <result column="coupon_id" jdbcType="BIGINT" property="couponId" /> | |||
| <result column="coupon_type" jdbcType="INTEGER" property="couponType" /> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||
| <result column="owner_id" jdbcType="BIGINT" property="ownerId" /> | |||
| <result column="b_user_id" jdbcType="BIGINT" property="bUserId" /> | |||
| <result column="order_id" jdbcType="BIGINT" property="orderId" /> | |||
| <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" /> | |||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" /> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <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="detail" jdbcType="VARCHAR" property="detail" /> | |||
| <result column="unit" jdbcType="INTEGER" property="unit" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="amount" jdbcType="INTEGER" property="amount" /> | |||
| <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" /> | |||
| <collection column="{productId=coupon_id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| javaType="java.util.List" | |||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | |||
| </collection> | |||
| <collection column="{cardId=id}" property="cardSpendList" | |||
| ofType="com.iformall.domain.po.WxCardSpend" | |||
| javaType="java.util.List" | |||
| select="com.iformall.mapper.WxCardSpendMapper.findList" > | |||
| </collection> | |||
| </resultMap> | |||
| <sql id="allCUserCardListColumns"> | |||
| co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date, | |||
| c.cover_img,c.title,c.sub_title,c.detail,c.unit,c.remark, | |||
| a.amount,a.remaining_amount | |||
| </sql> | |||
| <sql id="allCUserCardDetailColumns"> | |||
| co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, | |||
| c.cover_img,c.title,c.sub_title,c.sale_price,c.price,c.unit,c.detail,c.remark, | |||
| a.amount,a.remaining_amount | |||
| </sql> | |||
| <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="CCardVoResultMap"> | |||
| select <include refid="allCUserCardListColumns" /> | |||
| from wx_coupon_order co | |||
| inner join wx_coupon c on co.coupon_id = c.id | |||
| inner join wx_card_info a on co.id=a.id | |||
| where 1=1 | |||
| and co.coupon_type = 7 | |||
| <if test="tenantId != null"> | |||
| and co.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test="cUserId != null"> | |||
| and co.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test="ownerId != null"> | |||
| and co.owner_id = #{ownerId} | |||
| </if> | |||
| <if test="couponOrderStatus != null"> | |||
| and co.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||
| <select id="findCardDetailOfCUser" parameterType="java.lang.Long" resultMap="CCardVoResultMap"> | |||
| select <include refid="allCUserCardDetailColumns" /> | |||
| from wx_coupon_order co,wx_coupon c, wx_card_info a | |||
| where co.coupon_id = c.id and co.id = a.id | |||
| and co.id = #{id} | |||
| </select> | |||
| </mapper> | |||