| @@ -28,4 +28,5 @@ public class WxCouponCar extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") | |||
| private Map<String, Object> flowParams; | |||
| } | |||
| @@ -13,9 +13,6 @@ import java.util.List; | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCouponOrderCarCVo extends WxCouponOrderCVo { | |||
| @io.swagger.annotations.ApiModelProperty(value="couponFreeId",name="couponFreeId") | |||
| private Integer couponFreeId; | |||
| @io.swagger.annotations.ApiModelProperty(value="车场厂商相关信息",name="vendorParams") | |||
| private String vendorParams; | |||
| @@ -41,7 +41,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| //统一额度统计接口 | |||
| int queryPriceTotal(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrderCarCVo> findCarListOfCUser(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrder> findCarListOfCUser(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrder> findListOfOrderedByDateForBUser(Map dateMap); | |||
| List<WxCouponOrder> findListOfVerifiedByDateForBUser(Map dateMap); | |||
| @@ -222,4 +222,6 @@ public interface WxCouponOrderService { | |||
| /// POS接口 | |||
| List<WxCouponOrderCVo> findAvailCouponOrder(TenantEntity tenantEntity,Long cUserId,Long merchantId,Long posOrderId); | |||
| } | |||
| @@ -190,6 +190,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| WxShopMapper wxShopMapper; | |||
| @Autowired | |||
| WxMerchantShopMapper wxMerchantShopMapper; | |||
| @Autowired | |||
| WxCouponCarMapper wxCouponCarMapper; | |||
| private final SimpleDateFormat mydateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
| @@ -664,13 +667,126 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| @Override | |||
| public ResultData carListCUserVoAsPage(WxCouponOrder record, Integer pageIndex, Integer pageSize) { | |||
| return new ResultData(PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCarListOfCUser(record))); | |||
| return new ResultData(findCarListOfCUser(record,pageIndex,pageSize)); | |||
| } | |||
| @Override | |||
| public List<WxCouponOrderCarCVo> carListCUserVo(WxCouponOrder record) { | |||
| return wxCouponOrderMapper.findCarListOfCUser(record); | |||
| return findCarListOfCUser(record,1,10).getList(); | |||
| } | |||
| private PageInfo<WxCouponOrderCarCVo> findCarListOfCUser(WxCouponOrder wxCouponOrder,Integer pageIndex, Integer pageSize){ | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.updateTenantInfo(wxCouponOrder); | |||
| List<Integer> types = new ArrayList<Integer>(); | |||
| types.add(5); | |||
| types.add(51); | |||
| couponQ.setTypes(types); | |||
| List<Long> couponIdList = wxCouponMapper.findIdList(couponQ); | |||
| if (null == couponIdList || couponIdList.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| wxCouponOrder.setCouponIds(couponIdList); | |||
| PageInfo<WxCouponOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findCarListOfCUser(wxCouponOrder)); | |||
| PageInfo<WxCouponOrderCarCVo> retPageInfo = new PageInfo<WxCouponOrderCarCVo>(); | |||
| retPageInfo.setPageNum(pageInfo.getPageNum()); | |||
| retPageInfo.setPageSize(pageInfo.getPageSize()); | |||
| retPageInfo.setList(couponOrderListToCarVoList(wxCouponOrder,pageInfo.getList())); | |||
| return retPageInfo; | |||
| } | |||
| private List<WxCouponOrderCarCVo> couponOrderListToCarVoList(TenantEntity tenantEntity,List<WxCouponOrder> couponOrderList) { | |||
| if (null != couponOrderList) { | |||
| //查询coupon | |||
| List<Long> couponIds = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < couponOrderList.size(); i++){ | |||
| WxCouponOrder co = couponOrderList.get(i); | |||
| Long couponId = co.getCouponId(); | |||
| if (null != couponId && (!couponIds.contains(couponId))) { | |||
| couponIds.add(couponId); | |||
| } | |||
| } | |||
| WxCoupon couponQ = new WxCoupon(); | |||
| couponQ.updateTenantInfo(tenantEntity); | |||
| if (couponIds.size() > 0 ) { | |||
| couponQ.setIds(couponIds); | |||
| } | |||
| List<WxCoupon> couponList = wxCouponMapper.findTenantSimpleList(couponQ); | |||
| Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>(); | |||
| if (null != couponList) { | |||
| for (int i = 0 ; i < couponList.size(); i++ ) { | |||
| WxCoupon c = couponList.get(i); | |||
| if (null != c) { | |||
| couponMap.put(c.getId(), c); | |||
| } | |||
| } | |||
| } | |||
| WxCouponCar couponCarQ = new WxCouponCar(); | |||
| couponCarQ.updateTenantInfo(tenantEntity); | |||
| if (couponIds.size() > 0 ) { | |||
| couponCarQ.setIds(couponIds); | |||
| } | |||
| List<WxCouponCar> couponCarList = wxCouponCarMapper.findList(couponCarQ); | |||
| Map<Long,WxCouponCar> couponCarMap = new HashMap<Long,WxCouponCar>(); | |||
| if (null != couponCarList) { | |||
| for (int i = 0 ; i < couponCarList.size(); i++ ) { | |||
| WxCouponCar cc = couponCarList.get(i); | |||
| if (null != cc) { | |||
| couponCarMap.put(cc.getId(), cc); | |||
| } | |||
| } | |||
| } | |||
| List<WxCouponOrderCarCVo> volist = new ArrayList<WxCouponOrderCarCVo>(); | |||
| for (int i = 0 ; i < couponOrderList.size(); i++){ | |||
| WxCouponOrder co = couponOrderList.get(i); | |||
| WxCouponOrderCarCVo cvo = getCouponOrderCarVo(co,couponMap,couponCarMap); | |||
| if (null != cvo) { | |||
| volist.add(cvo); | |||
| } | |||
| } | |||
| return volist; | |||
| } | |||
| return null; | |||
| } | |||
| private WxCouponOrderCarCVo getCouponOrderCarVo(WxCouponOrder co,Map<Long,WxCoupon> couponMap,Map<Long,WxCouponCar> couponCarMap) { | |||
| if (null == co) { | |||
| return null; | |||
| } | |||
| try { | |||
| WxCouponOrderCarCVo cvo = new WxCouponOrderCarCVo(); | |||
| BeanUtils.copyProperties(cvo, co); | |||
| WxCoupon coupon = couponMap.get(cvo.getCouponId()); | |||
| if (null != coupon) { | |||
| cvo.setType(coupon.getType()); | |||
| cvo.setCoverImg(coupon.getCoverImg()); | |||
| cvo.setTitle(coupon.getTitle()); | |||
| cvo.setSubTitle(coupon.getSubTitle()); | |||
| cvo.setSalePrice(coupon.getSalePrice()); | |||
| cvo.setUsePrice(coupon.getUsePrice()); | |||
| cvo.setPrice(coupon.getPrice()); | |||
| cvo.setUnit(coupon.getUnit()); | |||
| cvo.setValidType(coupon.getValidType()); | |||
| cvo.setValidStartDate(coupon.getValidStartDate()); | |||
| cvo.setValidEndDate(coupon.getValidEndDate()); | |||
| cvo.setAutoRefund(coupon.getAutoRefund()); | |||
| } | |||
| WxCouponCar couponCar= couponCarMap.get(cvo.getCouponId()); | |||
| if (null != couponCar) { | |||
| cvo.setVendorParams(couponCar.getVendorParams()); | |||
| } | |||
| return cvo; | |||
| } catch (IllegalAccessException | InvocationTargetException e) { | |||
| logger.error("getCouponOrderCarVo error.",e); | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public ResultData listAdminAsPage(WxCouponOrderBVo wxCouponOrderBVo, Integer pageIndex, Integer pageSize) { | |||
| @@ -371,8 +371,13 @@ public class EtcpHelper { | |||
| String ret = ""; | |||
| try { | |||
| String couponFreeId = couponFreeIdFromJson(userCar.getVendorParams()); | |||
| if (StringUtils.isBlank(couponFreeId)) { | |||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "vendorParams解析错误"); | |||
| } | |||
| ret = etcp.bCouponRecord(url, merchantNo, merchantKey, version, | |||
| etcpToken, park.getParkId(), businessId, carNumber, String.valueOf(userCar.getCouponFreeId())); | |||
| etcpToken, park.getParkId(), businessId, carNumber, couponFreeId); | |||
| } catch (MallinkException e) { | |||
| logger.error("ETCP failed: " + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| @@ -392,6 +397,20 @@ public class EtcpHelper { | |||
| } | |||
| } | |||
| private String couponFreeIdFromJson(String json) { | |||
| if (StringUtils.isBlank(json)) { | |||
| return null; | |||
| } | |||
| JSONObject object = JSON.parseObject(json); | |||
| if (null != object) { | |||
| Integer id = object.getInteger("id"); | |||
| if (null != id) { | |||
| return String.valueOf(id); | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| public void updateWxCouponOrderUsed(WxCouponOrderCarCVo userCar,WxPark park) throws Exception { | |||
| // 券状态设为已使用 | |||
| WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| @@ -303,8 +303,8 @@ | |||
| <if test=" null != notinTypes "> | |||
| and type not in | |||
| <foreach collection="notinTypes" index="index" item="typeItem" open="(" separator="," close=")"> | |||
| #{typeItem} | |||
| <foreach collection="notinTypes" index="index" item="ntypeItem" open="(" separator="," close=")"> | |||
| #{ntypeItem} | |||
| </foreach> | |||
| </if> | |||
| @@ -314,6 +314,13 @@ | |||
| #{statusItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != types "> | |||
| and type in | |||
| <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")"> | |||
| #{typeItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| @@ -332,6 +339,12 @@ | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != types "> | |||
| and type in | |||
| <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")"> | |||
| #{typeItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| <select id="findSimpleDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap"> | |||
| @@ -788,7 +788,7 @@ | |||
| select | |||
| co.id,co.tenant_id,co.parent_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,co.verify_type,co.verify_remark, co.pay_vendor, | |||
| co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`, | |||
| co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info` | |||
| FROM wx_coupon_order co | |||
| where co.`tenant_id` = #{tenantId} | |||
| <choose> | |||
| @@ -955,7 +955,7 @@ | |||
| <select id="findDetailOfCUser" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select | |||
| co.id,co.tenant_id,co.parent_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,co.verify_type,co.verify_remark,co.pay_vendor, | |||
| co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`, | |||
| co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info` | |||
| from wx_coupon_order co | |||
| where co.id = #{id} and co.tenant_id = #{tenantId} | |||
| </select> | |||
| @@ -988,78 +988,32 @@ | |||
| </if> | |||
| </select> | |||
| <sql id="allCUserCouponOrderCarListColumns"> | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor, | |||
| c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit, | |||
| json_extract(car.vendor_params,'$.id') as coupon_free_id,car.vendor_params | |||
| </sql> | |||
| <resultMap id="CCarVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCarCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <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="coupon_price" jdbcType="INTEGER" property="couponPrice" /> | |||
| <result column="verify_type" jdbcType="INTEGER" property="verifyType" /> | |||
| <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" /> | |||
| <result column="pay_vendor" jdbcType="INTEGER" property="payVendor" /> | |||
| <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="detail" jdbcType="VARCHAR" property="detail" /> | |||
| <result column="price" jdbcType="INTEGER" property="price" /> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="vendor_params" jdbcType="VARCHAR" property="vendorParams" /> | |||
| <result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/> | |||
| <collection column="{productId=coupon_id,tenantId=tenant_id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| javaType="java.util.List" | |||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | |||
| </collection> | |||
| </resultMap> | |||
| <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap"> | |||
| select <include refid="allCUserCouponOrderCarListColumns" /> | |||
| from wx_coupon_order co, wx_coupon c, wx_coupon_car car | |||
| where co.coupon_id = c.id | |||
| and co.coupon_id = car.id | |||
| and c.type in (5,51) | |||
| <if test="cUserId != null"> | |||
| and co.c_user_id = #{cUserId} | |||
| </if> | |||
| <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="BaseResultMap"> | |||
| select | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor | |||
| from wx_coupon_order co | |||
| where co.c_user_id = #{cUserId} | |||
| <if test="id != null"> | |||
| and co.id = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and co.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and co.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="id != null"> | |||
| and co.id = #{id} | |||
| </if> | |||
| <if test="couponOrderStatus != null and 0 == couponOrderStatus "> | |||
| AND ( co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 ) | |||
| </if> | |||
| <if test="couponOrderStatus != null and 0 != couponOrderStatus "> | |||
| AND co.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != couponIds"> | |||
| and co.coupon_id in | |||
| <foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")"> | |||
| #{couponIdItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </select> | |||