| @@ -9,7 +9,7 @@ | |||||
| <version>1.0</version> | <version>1.0</version> | ||||
| </parent> | </parent> | ||||
| <artifactId>mallinkCclientApi</artifactId> | |||||
| <artifactId>mallinkCApi</artifactId> | |||||
| <dependencies> | <dependencies> | ||||
| <dependency> | <dependency> | ||||
| @@ -1,65 +0,0 @@ | |||||
| package com.simple.service.impl; | |||||
| import com.simple.domain.dto.WxUserCouponDto; | |||||
| import com.simple.domain.po.WxCoupon; | |||||
| import com.simple.domain.po.WxOrder; | |||||
| import com.simple.mapper.WxCouponMapper; | |||||
| import com.simple.service.WxOrderService; | |||||
| import com.simple.service.WxUserCouponService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.stream.Collectors; | |||||
| /** | |||||
| * Created by syf on 2018/8/10. | |||||
| */ | |||||
| @Service | |||||
| public class WxUserCouponServiceImpl implements WxUserCouponService { | |||||
| @Autowired | |||||
| private WxOrderService wxOrderService; | |||||
| @Autowired | |||||
| private WxCouponMapper wxCouponMapper; | |||||
| /** | |||||
| * | |||||
| * @param userId 用户id | |||||
| * @param status 用户卡券状态 | |||||
| * @return | |||||
| */ | |||||
| @Override | |||||
| public List<WxUserCouponDto> findList(Long userId, int status) { | |||||
| //TODO 待测试优化 | |||||
| List<WxUserCouponDto> wxUserCoupons = new ArrayList<>(); | |||||
| //查询订单表 | |||||
| WxOrder wxOrder = new WxOrder(); | |||||
| wxOrder.setCUserId(userId); | |||||
| wxOrder.setCouponStatus(status); | |||||
| List<WxOrder> orders = wxOrderService.findList(wxOrder); | |||||
| List<String> ids = orders.stream().map(p->p.getCouponId()+"").distinct().collect(Collectors.toList()); | |||||
| if(ids.size()>0){ | |||||
| //查询WxCoupon | |||||
| WxCoupon wxCoupon = new WxCoupon(); | |||||
| wxCoupon.setIds(ids); | |||||
| List<WxCoupon> wxCoupons = wxCouponMapper.findList(wxCoupon); | |||||
| Map<Long,String> couponNamesMap = wxCoupons.stream().collect(Collectors.toMap(WxCoupon::getId,p->p.getTitle())); | |||||
| for (WxOrder temp:orders) { | |||||
| wxUserCoupons.add(getWxUserCoupon(temp,couponNamesMap.get(temp.getCouponId()))); | |||||
| } | |||||
| } | |||||
| return wxUserCoupons; | |||||
| } | |||||
| public WxUserCouponDto getWxUserCoupon(WxOrder wxOrder, String title){ | |||||
| WxUserCouponDto wxUserCoupon = new WxUserCouponDto(); | |||||
| wxUserCoupon.setOrderId(wxOrder.getId()); | |||||
| wxUserCoupon.setcUserId(wxOrder.getCUserId()); | |||||
| wxUserCoupon.setCouponId(wxOrder.getCouponId()); | |||||
| wxUserCoupon.setCouponStatus(wxOrder.getCouponStatus()); | |||||
| wxUserCoupon.setValidDate(wxOrder.getValidDate()); | |||||
| wxUserCoupon.setCouponTitle(title); | |||||
| return wxUserCoupon; | |||||
| } | |||||
| } | |||||
| @@ -8,10 +8,12 @@ | |||||
| <result column="car_number" jdbcType="VARCHAR" property="carNumber" /> | <result column="car_number" jdbcType="VARCHAR" property="carNumber" /> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | ||||
| <result column="vendor_type" jdbcType="INTEGER" property="vendorType" /> | |||||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`c_user_id`,`car_number`,`create_date`,`update_date` | |||||
| `id`,`tenant_id`,`c_user_id`,`car_number`,`create_date`,`update_date`,`vendor_type`,`vendor_params` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -45,6 +47,16 @@ | |||||
| <if test=" null != updateDate "> | <if test=" null != updateDate "> | ||||
| and `update_date` = #{updateDate} | and `update_date` = #{updateDate} | ||||
| </if> | |||||
| <if test=" null != vendorType "> | |||||
| and `vendor_type` = #{vendorType} | |||||
| </if> | |||||
| <if test=" null != vendorParams "> | |||||
| and `vendor_params` like concat('%', #{vendorParams},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| @@ -10,7 +10,7 @@ | |||||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime" /> | <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime" /> | ||||
| <result column="status" jdbcType="INTEGER" property="status" /> | <result column="status" jdbcType="INTEGER" property="status" /> | ||||
| <result column="coupon_status" jdbcType="INTEGER" property="couponStatus" /> | <result column="coupon_status" jdbcType="INTEGER" property="couponStatus" /> | ||||
| <result column="validDate" jdbcType="TIMESTAMP" property="validDate" /> | |||||
| <result column="valid_date" jdbcType="TIMESTAMP" property="validDate" /> | |||||
| <result column="refund" jdbcType="INTEGER" property="refund" /> | <result column="refund" jdbcType="INTEGER" property="refund" /> | ||||
| <result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" /> | <result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" /> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| @@ -18,7 +18,7 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`coupon_id`,`c_user_id`,`payment`,`payment_time`,`status`,`coupon_status`,`validDate`,`refund`,`refund_time`,`create_date`,`update_date` | |||||
| `id`,`tenant_id`,`coupon_id`,`c_user_id`,`payment`,`payment_time`,`status`,`coupon_status`,`valid_date`,`refund`,`refund_time`,`create_date`,`update_date` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -65,7 +65,7 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != validDate "> | <if test=" null != validDate "> | ||||
| and `validDate` = #{validDate} | |||||
| and `valid_date` = #{validDate} | |||||
| </if> | </if> | ||||