diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java
index 1f54b38f6..22f6af0e9 100644
--- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java
+++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java
@@ -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());
+ }
+
+ }
});
}
diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
index 2518186a1..6ee4e4caf 100644
--- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
+++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
@@ -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")
diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java
index a5df56ae9..aeb9928c9 100644
--- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java
+++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java
@@ -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
diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponChannelVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponChannelVo.java
index c2d030200..ec8854d36 100644
--- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponChannelVo.java
+++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponChannelVo.java
@@ -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;
+ }
}
diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponAutoRefund.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponAutoRefund.java
new file mode 100644
index 000000000..51542555e
--- /dev/null
+++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponAutoRefund.java
@@ -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;
+ }
+}
diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderStatus.java
index b21955aa8..5eb4022f3 100644
--- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderStatus.java
+++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponOrderStatus.java
@@ -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, "已用完"),
diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
index 87fc382a5..53c75a175 100644
--- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
+++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
@@ -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());
diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
index dda53108b..adea70632 100644
--- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
+++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
@@ -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) {
diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
index 901bddede..50d8025c2 100644
--- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
@@ -108,7 +108,7 @@
,
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
@@ -136,6 +136,8 @@
+
+
@@ -191,7 +193,8 @@
-
+
+
+
+
`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`
@@ -159,6 +161,11 @@
and `press_limit_hours` = #{pressLimitHours}
+
+ and `auto_refund` = #{autoRefund}
+
+
+
and id in
diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml
index 5e4a01a5b..3744e8b1e 100644
--- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml
@@ -15,10 +15,11 @@
+
- `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`
@@ -75,6 +76,11 @@
and `coupon_price` = #{couponPrice}
+
+
+ and `auto_refund` = #{autoRefund}
+
+
and id in
@@ -259,7 +265,6 @@
-
@@ -280,6 +285,8 @@
+
+
@@ -295,7 +302,7 @@
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 @@
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 @@
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
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,
@@ -507,6 +514,7 @@
+