Commit a5c7fa77 by 王世昌

将微商城的订单 订单状态是否退款的状判断放在集中的地方

parent 770738e8
......@@ -102,6 +102,7 @@ import java.text.DecimalFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.freemud.constant.OrderRefundConstant.ALLOW_REFUND;
......@@ -1922,39 +1923,49 @@ public class OrderAdapter {
* @return
*/
public boolean checkRefundButton(QueryOrdersResponse.DataBean.OrderBean orderBean, String wxAppId) {
OrderStatus status = OrderStatus.getByCode(orderBean.getStatus());
if (Objects.isNull(status)){
return false;
}
// [华莱士20210410] 微商城订单判断
if(Objects.equals(com.freemud.sdk.api.assortment.order.enums.OrderSourceType.SAASMALL.getCode(),orderBean.getSource()) ){
// 除 未支付 拒单 和 取消外,其他可退款
return Stream.of(OrderStatus.WAIT_PAY,OrderStatus.REFUSE,OrderStatus.CALCEL).noneMatch(s -> Objects.equals(status,s));
}
boolean canRefund = false;
List<AssortmentOpenPlatformPartnerWxappConfig> wxappConfigs = cacheWxappConfigManager.cacheSelectDefaultPage(wxAppId, "2");
Map<String, AssortmentOpenPlatformPartnerWxappConfig> configMap = wxappConfigs.stream().collect(Collectors.toMap(AssortmentOpenPlatformPartnerWxappConfig::getAppKey, Function.identity()));
AssortmentOpenPlatformPartnerWxappConfig orderRefund;
//订单状态
switch (orderBean.getStatus()) {
switch (status) {
// 未接单
case 1:
case TAKE_ORDER:
//区分外卖单和到店订单,判断是否可以退款
if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_TAKE_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.TAKEORDER_REFUND.getKeyValue());
}
if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) {
if (orderRefund == null || ALLOW_REFUND.equals(orderRefund.getAppValue())) {
canRefund = true;
}
break;
//已接单
case 3:
case RECEIPT:
if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_RECEIPT_ORDER_REFUND.getKeyValue());
}else {
orderRefund = configMap.get(OrderRefundEnum.RECEIPTORDER_REFUND.getKeyValue());
}
if (orderRefund == null || (orderRefund != null && ALLOW_REFUND.equals(orderRefund.getAppValue()))) {
if (orderRefund == null || ALLOW_REFUND.equals(orderRefund.getAppValue())) {
canRefund = true;
}
break;
//制作完成
case 31:
case COMPLETE_MAKE:
if(OrderType.TAKE_OUT.getCode().equals(orderBean.getOrderType())) {
orderRefund = configMap.get(OrderRefundEnum.DELIVERY_COMPLETE_MAKE_ORDER_REFUND.getKeyValue());
}else {
......@@ -1965,7 +1976,7 @@ public class OrderAdapter {
}
break;
// 订单完成
case 5:
case COMPLETE:
long currentTime = System.currentTimeMillis();
long gmtModified = orderBean.getGmtModified();
......
......@@ -2191,13 +2191,11 @@ public class OrderServiceImpl implements Orderservice {
}
// 【优化】【小程序】顾客申请退款提交时,判断当前的订单状态,是否允许申请退款
//if (OrderStatus.COMPLETE.getCode().equals(orderBean.getStatus())) {
//微商城订单不校验
if (!com.freemud.sdk.api.assortment.order.enums.OrderSourceType.SAASMALL.getCode().equalsIgnoreCase(orderBean.getSource())) {
boolean refundButton = orderAdapter.checkRefundButton(queryOrderByIdResponse.getData(), userInfo.getWxAppId());
if (!refundButton) {
return ResponseUtil.error(ResponseResult.ORDER_NOT_ALLOW_REFUND.getCode(), ResponseResult.ORDER_NOT_ALLOW_REFUND.getMessage());
}
}
//}
List<AssortmentOpenPlatformPartnerWxappConfig> partnerWxappConfigs = cacheOpenPlatformPartnerWxappConfigManager.cacheSelectDefaultPage(userInfo.getWxAppId(), "2");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment