| @@ -3,14 +3,13 @@ package com.iformall.schedule; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.config.PayProperty; | |||
| import com.iformall.domain.dto.WxSharingOrderDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumCouponOrderStatus; | |||
| import com.iformall.enums.EnumCouponType; | |||
| import com.iformall.enums.EnumPayType; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxPayOrderService; | |||
| import com.iformall.service.WxProfitSharingOrderService; | |||
| import com.iformall.service.WxRefundOrderService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -38,11 +37,14 @@ public class CouponOrderExpiringSchedule { | |||
| private WxRefundOrderService wxRefundOrderService; | |||
| @Autowired | |||
| private WxPayOrderService wxPayOrderService; | |||
| private WxProfitSharingOrderService wxProfitSharingOrderService; | |||
| @Autowired | |||
| private WxAppinfoMapper wxAppinfoMapper; | |||
| @Autowired | |||
| private WxPayOrderMapper wxPayOrderMapper; | |||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @@ -60,7 +62,8 @@ public class CouponOrderExpiringSchedule { | |||
| // 券过期与退款分离 | |||
| couponOrderExpire(co); | |||
| if(!co.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode())) { | |||
| if(!co.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode()) | |||
| && !co.getAutoRefund().equals(EnumCouponAutoRefund.UNSUPPORTED.getCode())) { | |||
| // 非储值卡, 可以退款 | |||
| WxAppinfo appinfo = new WxAppinfo(); | |||
| appinfo.setTenantId(co.getTenantId()); | |||
| @@ -74,6 +77,35 @@ public class CouponOrderExpiringSchedule { | |||
| } | |||
| } | |||
| if (co.getAutoRefund().equals(EnumCouponAutoRefund.UNSUPPORTED.getCode())){ | |||
| // 微信分账 | |||
| try { | |||
| WxPayOrder wxPayOrder = new WxPayOrder(); | |||
| wxPayOrder.setTenantId(co.getTenantId()); | |||
| wxPayOrder.setOrderId(co.getOrderId()); | |||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder); | |||
| if (wxPayOrder != null && wxPayOrder.getShare().equals(EnumPayShare.YES.getCode())) { | |||
| WxSharingOrderDto wxSharingOrderDto = new WxSharingOrderDto(); | |||
| wxSharingOrderDto.setcUserId(wxPayOrder.getcUserId()); | |||
| wxSharingOrderDto.setMerchantId(0L); | |||
| wxSharingOrderDto.setType(EnumProfitSharingOrderType.PROFIT_SHARING_FINISH.getCode()); | |||
| wxSharingOrderDto.setPayAmount(wxPayOrder.getPayAmount()); | |||
| wxSharingOrderDto.setOrderId(wxPayOrder.getId()); | |||
| wxSharingOrderDto.setPayTimeStart(wxPayOrder.getPayTimeStart()); | |||
| wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); | |||
| wxSharingOrderDto.setTenantId(wxPayOrder.getTenantId()); | |||
| wxSharingOrderDto.setTransactionId(wxPayOrder.getTransactionId()); | |||
| wxSharingOrderDto.setShareAmount(wxPayOrder.getShareAmount()); | |||
| wxProfitSharingOrderService.finishSharingOrder(wxSharingOrderDto); | |||
| } | |||
| co.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_FORCE_USED.getCode()); | |||
| wxCouponOrderMapper.updateByPrimaryKeySelective(co); | |||
| } catch (Exception e) { | |||
| logger.error("券过期不退款: " + co.getId() + " ERROR:" + e.getMessage()); | |||
| } | |||
| } | |||
| }); | |||
| } | |||
| @@ -138,6 +138,11 @@ public class WxCoupon implements Serializable { | |||
| /**是否支持转送(0:不支持,1支持)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="是否支持转送(0:不支持,1支持)",name="supportTransfer") | |||
| private Integer supportTransfer; | |||
| /**过期退款(0:正常,1不退)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="过期退款(0:正常,1不退)",name="autoRefund") | |||
| private Integer autoRefund; | |||
| /**补贴类型(0:不支持, 1:微信支付立减与折扣, 2:线下结算, 3:微信付款到银行卡 )**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="补贴类型(0:不支持, 1:微信支付立减与折扣, 2:线下结算, 3:微信付款到银行卡)",name="subsidyType") | |||
| private Integer subsidyType; | |||
| @@ -409,6 +414,14 @@ public class WxCoupon implements Serializable { | |||
| this.pressLimitHours = pressLimitHours; | |||
| } | |||
| public Integer getAutoRefund() { | |||
| return autoRefund; | |||
| } | |||
| public void setAutoRefund(Integer autoRefund) { | |||
| this.autoRefund = autoRefund; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| @@ -77,7 +77,19 @@ public class WxCouponOrder implements Serializable { | |||
| /**单券实际购买价格**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "单券实际购买价格", name = "couponPrice") | |||
| private Integer couponPrice; | |||
| /**过期退款(0:正常,1不退)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="过期退款(0:正常,1不退)",name="autoRefund") | |||
| private Integer autoRefund; | |||
| public Integer getAutoRefund() { | |||
| return autoRefund; | |||
| } | |||
| public void setAutoRefund(Integer autoRefund) { | |||
| this.autoRefund = autoRefund; | |||
| } | |||
| @Transient | |||
| private String couponName; | |||
| @Transient | |||
| @@ -64,6 +64,11 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="1.主动领取2.定向投放",name="sendType") | |||
| private Integer sendType; | |||
| /**过期退款(0:正常,1不退)**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="过期退款(0:正常,1不退)",name="autoRefund") | |||
| private Integer autoRefund; | |||
| @Transient | |||
| private String salePriceStr; | |||
| @@ -243,4 +248,12 @@ public class WxCouponChannelVo extends WxCouponChannel implements Serializable { | |||
| public void setPressLimitNum(Integer pressLimitNum) { | |||
| this.pressLimitNum = pressLimitNum; | |||
| } | |||
| public Integer getAutoRefund() { | |||
| return autoRefund; | |||
| } | |||
| public void setAutoRefund(Integer autoRefund) { | |||
| this.autoRefund = autoRefund; | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumCouponAutoRefund { | |||
| // 0-可投放;1-已作废; | |||
| NORMAL(0, "正常"), | |||
| UNSUPPORTED(1, "不退"), | |||
| ; | |||
| public static EnumCouponAutoRefund getEnum(Integer code) { | |||
| for (EnumCouponAutoRefund value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCouponAutoRefund(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -10,6 +10,8 @@ public enum EnumCouponOrderStatus { | |||
| COUPON_ORDER_USED(1, "已核销"), | |||
| COUPON_ORDER_OVER_TIME(2, "已过期"), | |||
| COUPON_ORDER_INVALID(3, "已作废"), | |||
| COUPON_ORDER_FORCE_USED(9, "已回收(未退款)"), | |||
| CARD_USING(4, "使用中"), | |||
| CARD_OVER_TIME(5, "已过期"), | |||
| CARD_COMPLETE(6, "已用完"), | |||
| @@ -403,7 +403,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| wxSharingOrderDto.setTenantId(wxPayOrder.getTenantId()); | |||
| wxSharingOrderDto.setTransactionId(wxPayOrder.getTransactionId()); | |||
| wxSharingOrderDto.setShareAmount(wxPayOrder.getShareAmount()); | |||
| wxProfitSharingOrderService.createSharingOrder(wxSharingOrderDto); | |||
| wxProfitSharingOrderService.finishSharingOrder(wxSharingOrderDto); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("微信分账: " + e.getMessage()); | |||
| @@ -583,6 +583,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| couponOrder.setCouponType(coupon.getType()); | |||
| couponOrder.setCUserId(user.getId()); | |||
| couponOrder.setOwnerId(user.getId()); | |||
| couponOrder.setAutoRefund(coupon.getAutoRefund()); | |||
| couponOrder.setOrderId(order.getOrderNumber()); | |||
| couponOrder.setExpiredTime(valid_date); | |||
| if(!isCard) { | |||
| @@ -108,7 +108,7 @@ | |||
| <sql id="CouponChannelVoColumns"> | |||
| <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.use_price,c.price,c.unit,c.use_limit_quantity,c.send_type,c.support_transfer,c.press_limit_num,c.auto_refund | |||
| </sql> | |||
| <resultMap id="CouponChannelVoMap" type="com.iformall.domain.vo.WxCouponChannelVo"> | |||
| @@ -136,6 +136,8 @@ | |||
| <result column="send_type" jdbcType="INTEGER" property="sendType"/> | |||
| <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/> | |||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| <collection column="{productId=coupon_id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| @@ -156,7 +158,7 @@ | |||
| c.tenant_id,c.type,c.cover_img,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.support_transfer,c.press_limit_num | |||
| c.create_date,c.update_date,c.business,c.support_transfer,c.press_limit_num, c.auto_refund | |||
| </sql> | |||
| <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo"> | |||
| @@ -191,7 +193,8 @@ | |||
| <result column="business" jdbcType="INTEGER" property="business"/> | |||
| <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/> | |||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| <collection column="{productId=coupon_id}" property="merchantVoList" | |||
| ofType="com.iformall.domain.vo.WxMerchantVo" | |||
| javaType="java.util.List" | |||
| @@ -31,13 +31,15 @@ | |||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/> | |||
| <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/> | |||
| <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`type`,`cover_img`,`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`,`support_transfer`,`subsidy_num`,`subsidy_type`, | |||
| `press_limit_num`, `press_limit_hours` | |||
| `press_limit_num`, `press_limit_hours`, `auto_refund` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -159,6 +161,11 @@ | |||
| and `press_limit_hours` = #{pressLimitHours} | |||
| </if> | |||
| <if test=" null != autoRefund "> | |||
| and `auto_refund` = #{autoRefund} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -15,10 +15,11 @@ | |||
| <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="auto_refund" jdbcType="INTEGER" property="autoRefund" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price` | |||
| `id`,`tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -75,6 +76,11 @@ | |||
| <if test=" null != couponPrice "> | |||
| and `coupon_price` = #{couponPrice} | |||
| </if> | |||
| <if test=" null != autoRefund "> | |||
| and `auto_refund` = #{autoRefund} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -259,7 +265,6 @@ | |||
| </select> | |||
| <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| @@ -280,6 +285,8 @@ | |||
| <result column="sale_price" jdbcType="INTEGER" property="salePrice" /> | |||
| <result column="use_price" jdbcType="INTEGER" property="usePrice" /> | |||
| <result column="price" jdbcType="INTEGER" property="price" /> | |||
| <result column="unit" jdbcType="INTEGER" property="unit" /> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund" /> | |||
| <result column="name" jdbcType="VARCHAR" property="bUserName" /> | |||
| <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" /> | |||
| @@ -295,7 +302,7 @@ | |||
| <sql id="allAdminCouponOrderListColumns"> | |||
| co.id,co.tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price, | |||
| c.title,c.sale_price,c.use_price,c.price,c.unit, | |||
| c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund, | |||
| (case when com.mc=1 then | |||
| (select m.name from wx_merchant m, wx_coupon_merchant cm | |||
| where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name | |||
| @@ -303,7 +310,7 @@ | |||
| <sql id="allAdminCouponOrderDetailColumns"> | |||
| 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.type,c.title,c.sale_price,c.use_price,c.price,c.unit, | |||
| c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund, | |||
| bu.name, bu.phone as bphone, | |||
| cu.phone, | |||
| m.name as merchant_name | |||
| @@ -471,13 +478,13 @@ | |||
| <sql id="allCUserCouponOrderListColumns"> | |||
| co.id,co.coupon_id,co.coupon_type,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.use_price,c.price,c.unit,c.valid_start_date,c.valid_end_date, | |||
| c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_start_date,c.valid_end_date,c.auto_refund, | |||
| cal.channel_type as send_channel_type | |||
| </sql> | |||
| <sql id="allCUserCouponOrderDetailColumns"> | |||
| 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.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.auto_refund, | |||
| </sql> | |||
| <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo"> | |||
| @@ -507,6 +514,7 @@ | |||
| <result column="remark" jdbcType="VARCHAR" property="remark" /> | |||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/> | |||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/> | |||
| <result column="auto_refund" jdbcType="INTEGER" property="autoRefund" /> | |||
| <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" /> | |||