Просмотр исходного кода

退款/投诉 管理后台设置

licailing 5 лет назад
Родитель
Сommit
3243474e17

+ 1 - 0
src/main/java/com/izouma/dingdong/domain/OrderRefundApply.java

@@ -42,6 +42,7 @@ public class OrderRefundApply extends BaseEntity {
     @ApiModelProperty(value = "理由", name = "reason")
     private RefundReason reason;
 
+    @Enumerated(EnumType.STRING)
     @ApiModelProperty(value = "状态", name = "status")
     private RefundStatus status;
 

+ 1 - 0
src/main/java/com/izouma/dingdong/enums/OrderStatus.java

@@ -7,6 +7,7 @@ public enum OrderStatus {
     RATED("待评价"),
     CANCELLED("已取消"),
     REFUNDED_PENDING("申请退款中"),
+    REFUNDING("退款中"),
     REFUNDED("已退款"),
     COMPLETED("已完成");
 

+ 2 - 1
src/main/java/com/izouma/dingdong/enums/RefundStatus.java

@@ -2,8 +2,9 @@ package com.izouma.dingdong.enums;
 
 public enum RefundStatus {
     PENDING("待处理"),
-    REFUNDING("退款中"),
+   // REFUNDING("退款中"),
     SUCCESS("成功"),
+    PENDING_PAYMENT("待打款"),
     DENY("失败"),
     CANCEL("取消退款");
     private final String description;

+ 0 - 1
src/main/java/com/izouma/dingdong/repo/MoneyRecordRepo.java

@@ -3,7 +3,6 @@ package com.izouma.dingdong.repo;
 import com.izouma.dingdong.domain.MoneyRecord;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.domain.Specification;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;

+ 1 - 0
src/main/java/com/izouma/dingdong/repo/OrderRefundApplyRepo.java

@@ -27,4 +27,5 @@ public interface OrderRefundApplyRepo extends JpaRepository<OrderRefundApply, Lo
     @Transactional
     void deleteById(Long id);
 
+    OrderRefundApply findByOrderId(Long orderId);
 }

+ 10 - 14
src/main/java/com/izouma/dingdong/service/OrderInfoService.java

@@ -61,7 +61,6 @@ public class OrderInfoService {
     private RiderRepo riderRepo;
     private RiderService riderService;
     private MerchantSettingsService merchantSettingsService;
-    private ShoppingCartService shoppingCartService;
 
     /*
     用户下单
@@ -266,8 +265,9 @@ public class OrderInfoService {
                         orderInfo.setStatus(OrderStatus.RATED);
 
                         //支付价钱
-                        this.orderCarryOut(orderId);
-
+                        orderRefundApplyService.orderCarryOut(orderId);
+                        //添加销量数据
+                        salesService.addSale(orderInfo);
                         break;
                 }
                 orderInfoRepo.save(orderInfo);
@@ -344,6 +344,11 @@ public class OrderInfoService {
         //用户已支付
         if (OrderStatus.PAID.equals(orderInfo.getStatus())) {
 
+            //已接单,已完成,不能退 只能投诉
+            if (RiderStatus.CARRY_OUT.equals(orderInfo.getRiderStatus())) {
+                throw new BusinessException("已完成无法取消");
+            }
+
             OrderRefundApply apply = orderRefundApplyService.apply(id, reason, null);
             //商家未接单,直接退
             if (MerchantStatus.NOT_RECEIVED.equals(orderInfo.getMerchantStatus())) {
@@ -353,13 +358,7 @@ public class OrderInfoService {
                 //骑手未接单 直接退
                 if (RiderStatus.NOT_RECEIVED.equals(orderInfo.getRiderStatus())) {
                     orderRefundApplyService.audit(apply.getId(), true, false);
-                } else {
-                    //已接单,已完成,不能退 只能投诉
-                    if (RiderStatus.CARRY_OUT.equals(orderInfo.getRiderStatus())) {
-                        throw new BusinessException("已完成无法取消");
-                    }
                 }
-
             }
         }
         orderInfo.setCancel(true);
@@ -379,12 +378,9 @@ public class OrderInfoService {
     /*
     订单完成结算钱
      */
-    public void orderCarryOut(Long orderId) {
+/*    public void orderCarryOut(Long orderId) {
         OrderInfo orderInfo = orderInfoRepo.findById(orderId).orElseThrow(new BusinessException("无订单"));
 
-        //添加销量数据
-        salesService.addSale(orderInfo);
-
         //扣除金额
         SysConfig sysConfig = sysConfigRepo.findByName("commission").orElseThrow(new BusinessException("无设置"));
         //平台抽成
@@ -396,7 +392,7 @@ public class OrderInfoService {
 
         //骑手应得
         riderService.income(orderInfo.getRiderId(), orderInfo.getUserId(), orderInfo.getDeliveryAmount(), FinancialType.INCOME);
-    }
+    }*/
 
     /*
     支付倒计时

+ 71 - 25
src/main/java/com/izouma/dingdong/service/OrderRefundApplyService.java

@@ -3,15 +3,15 @@ package com.izouma.dingdong.service;
 import cn.hutool.core.util.ObjectUtil;
 import com.izouma.dingdong.domain.OrderInfo;
 import com.izouma.dingdong.domain.OrderRefundApply;
-import com.izouma.dingdong.domain.User;
+import com.izouma.dingdong.domain.SysConfig;
 import com.izouma.dingdong.enums.*;
 import com.izouma.dingdong.exception.BusinessException;
 import com.izouma.dingdong.repo.OrderInfoRepo;
 import com.izouma.dingdong.repo.OrderRefundApplyRepo;
+import com.izouma.dingdong.repo.SysConfigRepo;
 import com.izouma.dingdong.repo.UserRepo;
 import com.izouma.dingdong.repo.merchant.MerchantRepo;
 import com.izouma.dingdong.repo.rider.RiderRepo;
-import com.izouma.dingdong.service.merchant.MerchantService;
 import com.izouma.dingdong.service.merchant.MerchantSettingsService;
 import com.izouma.dingdong.service.rider.RiderService;
 import com.izouma.dingdong.utils.SnowflakeIdWorker;
@@ -32,24 +32,20 @@ public class OrderRefundApplyService {
 
     @Autowired
     private OrderRefundApplyRepo orderRefundApplyRepo;
-
     @Autowired
     private OrderInfoRepo orderInfoRepo;
-
     @Autowired
     private UserRepo userRepo;
-
     @Autowired
     private MerchantRepo merchantRepo;
-
     @Autowired
     private MerchantSettingsService merchantSettingsService;
-
     @Autowired
     private RiderService riderService;
-
     @Autowired
     private RiderRepo riderRepo;
+    @Autowired
+    private SysConfigRepo sysConfigRepo;
 
     private OrderStatus status;
 
@@ -103,15 +99,17 @@ public class OrderRefundApplyService {
             return;
         }
 
-        OrderInfo orderInfo = apply.getOrderInfo();
+        //OrderInfo orderInfo = apply.getOrderInfo();
+        OrderInfo orderInfo = orderInfoRepo.findById(apply.getOrderId()).orElseThrow(new BusinessException("无订单"));
+
         userRepo.findById(orderInfo.getUserId()).orElseThrow(new BusinessException("无用户"));
         if (merchantAgree) {
 
             String refundId = String.valueOf(new SnowflakeIdWorker(1, 1).nextId());
-            apply.setStatus(RefundStatus.SUCCESS);
+            apply.setStatus(RefundStatus.PENDING_PAYMENT);
             apply.setMerchantAgree(true);
 
-            //商家同意损失都由商家承担
+            //商家同意损失都由商家承担 完成订单商家才得到钱,所以无需减
             apply.setMerchantLiability(BigDecimal.ONE);
             apply.setRiderLiability(BigDecimal.ZERO);
             apply.setPlatformLiability(BigDecimal.ZERO);
@@ -121,7 +119,7 @@ public class OrderRefundApplyService {
             }
 
             //退款,线下退款订单完成商家才得款
-
+            orderInfo.setStatus(OrderStatus.REFUNDING);
 
             //骑手得应得的
             if (payRider) {
@@ -129,10 +127,11 @@ public class OrderRefundApplyService {
                 BigDecimal deliveryAmount = orderInfo.getDeliveryAmount();
                 //骑手收入
                 Long merId = merchantRepo.findUserIdById(orderInfo.getMerchantId());
-                riderService.income(orderInfo.getRiderId(), merId, deliveryAmount, FinancialType.INCOME);
+                riderService.income(orderInfo.getRiderId(), merId, deliveryAmount, FinancialType.INCOME, apply.getOrderId().toString());
                 //商家支出
-                Long riderUserId = userRepo.findById(riderRepo.findUserIdById(orderInfo.getRiderId())).orElseThrow(new BusinessException("无用户")).getId();
-                merchantSettingsService.income(apply.getMerchantId(), riderUserId, deliveryAmount, FinancialType.LOSE_MONEY);
+                //User riderUser = userRepo.findById(riderRepo.findUserIdById(orderInfo.getRiderId())).orElseThrow(new BusinessException("无用户"));
+                Long riderUserId = orderInfo.getRiderId();
+                merchantSettingsService.income(apply.getMerchantId(), riderUserId, deliveryAmount, FinancialType.LOSE_MONEY, apply.getOrderId().toString());
             }
 
         } else {
@@ -174,7 +173,7 @@ public class OrderRefundApplyService {
 
 
     //平台
-    public void platformAudit(Long applyId, Boolean agree, BigDecimal merchantLiability, BigDecimal riderLiability) {
+    public void platformAudit(Long applyId, Boolean agree, BigDecimal merchantLiability, BigDecimal riderLiability, Boolean isCarryOut) {
 
         OrderRefundApply apply = orderRefundApplyRepo.findById(applyId).orElseThrow(new BusinessException("无记录"));
         if (ObjectUtil.isNull(merchantLiability)) {
@@ -183,35 +182,82 @@ public class OrderRefundApplyService {
         if (ObjectUtil.isNull(riderLiability)) {
             riderLiability = BigDecimal.ZERO;
         }
+
+        OrderInfo orderInfo = orderInfoRepo.findById(apply.getOrderId()).orElseThrow(new BusinessException("无订单"));
+
         if (agree) {
             apply.setPlatformAgree(true);
             apply.setPlatformLiability(BigDecimal.ONE.subtract(riderLiability).subtract(merchantLiability));
             apply.setRiderLiability(riderLiability);
             apply.setMerchantLiability(merchantLiability);
 
+            if (!isCarryOut) {
+                //先收入钱
+                this.orderCarryOut(apply.getOrderId());
+            }
+
             if (!merchantLiability.equals(BigDecimal.ZERO)) {
                 //商家所赔金额
-                BigDecimal merAmount = apply.getOrderInfo().getRealAmount().multiply(merchantLiability);
-                merchantSettingsService.income(apply.getMerchantId(), apply.getOrderInfo().getUserId(), merAmount, FinancialType.REFUND);
+                BigDecimal merAmount = orderInfo.getRealAmount().multiply(merchantLiability);
+                merchantSettingsService.income(apply.getMerchantId(), orderInfo.getUserId(), merAmount, FinancialType.REFUND, apply.getOrderId().toString());
             }
 
             if (!riderLiability.equals(BigDecimal.ZERO)) {
                 //骑手赔付金额
-                BigDecimal riderAmount = apply.getOrderInfo().getRealAmount().multiply(riderLiability);
-                riderService.income(apply.getOrderInfo().getRiderId(), apply.getOrderInfo().getUserId(), riderAmount, FinancialType.REFUND);
+                BigDecimal riderAmount = orderInfo.getRealAmount().multiply(riderLiability);
+                riderService.income(orderInfo.getRiderId(), orderInfo.getUserId(), riderAmount, FinancialType.REFUND, apply.getOrderId().toString());
             }
 
-            apply.getOrderInfo().setStatus(OrderStatus.REFUNDED);
+            //改状态
+            orderInfo.setStatus(OrderStatus.REFUNDING);
+            apply.setStatus(RefundStatus.PENDING_PAYMENT);
         } else {
             apply.setPlatformAgree(false);
             //原状态
-            apply.getOrderInfo().setStatus(status);
-            apply.getOrderInfo().setCancel(false);
+            orderInfo.setStatus(status);
+            orderInfo.setCancel(false);
+            //改状态
+            apply.setStatus(RefundStatus.DENY);
         }
 
-        orderInfoRepo.save(apply.getOrderInfo());
-
+        orderInfoRepo.save(orderInfo);
         apply.setPlatformAuditTime(LocalDateTime.now());
         orderRefundApplyRepo.save(apply);
     }
+
+    /*
+    订单完成结算钱
+    */
+    public void orderCarryOut(Long orderId) {
+        OrderInfo orderInfo = orderInfoRepo.findById(orderId).orElseThrow(new BusinessException("无订单"));
+
+        //扣除金额
+        SysConfig sysConfig = sysConfigRepo.findByName("commission").orElseThrow(new BusinessException("无设置"));
+
+        //实付减运费
+        BigDecimal subtractDelivery = orderInfo.getRealAmount().subtract(orderInfo.getDeliveryAmount());
+        //平台抽成 (实付金额减运费)
+        BigDecimal platform = subtractDelivery.multiply(new BigDecimal(sysConfig.getValue()));
+
+        //商家应得 = 减去骑手应得,减去平台抽成
+        BigDecimal deserve = subtractDelivery.subtract(platform);
+        merchantSettingsService.income(orderInfo.getMerchantId(), orderInfo.getUserId(), deserve, FinancialType.INCOME, orderInfo.getId().toString());
+
+        //骑手应得
+        riderService.income(orderInfo.getRiderId(), orderInfo.getUserId(), orderInfo.getDeliveryAmount(), FinancialType.INCOME, orderInfo.getId().toString());
+    }
+
+    /*
+    打款
+     */
+    public void payment(Long applyId) {
+        OrderRefundApply apply = orderRefundApplyRepo.findById(applyId).orElseThrow(new BusinessException("无退款申请"));
+        apply.setStatus(RefundStatus.SUCCESS);
+        apply.setRefundTime(LocalDateTime.now());
+
+        OrderInfo orderInfo = orderInfoRepo.findById(apply.getOrderId()).orElseThrow(new BusinessException("无订单"));
+        orderInfo.setStatus(OrderStatus.REFUNDED);
+        orderInfoRepo.save(orderInfo);
+        orderRefundApplyRepo.save(apply);
+    }
 }

+ 2 - 1
src/main/java/com/izouma/dingdong/service/merchant/MerchantSettingsService.java

@@ -88,7 +88,7 @@ public class MerchantSettingsService {
     /*
     商户叮咚币记录
      */
-    public void income(Long merchantId, Long fromUserId, BigDecimal amount, FinancialType type) {
+    public void income(Long merchantId, Long fromUserId, BigDecimal amount, FinancialType type, String remark) {
         //按商户Id找出用户
         User userMer = userRepo.findById(merchantRepo.findUserIdById(merchantId)).orElseThrow(new BusinessException("无用户"));
         //商家应得 = 减去骑手应得,减去平台抽成
@@ -109,6 +109,7 @@ public class MerchantSettingsService {
                         .userId(userMer.getId())
                         .fromUserId(fromUserId)
                         .enabled(true)
+                        .remark(remark)
                         .build()
         );
     }

+ 0 - 2
src/main/java/com/izouma/dingdong/service/merchant/SalesService.java

@@ -25,8 +25,6 @@ public class SalesService {
 
     private SalesRepo salesRepo;
 
-    private AppraisalRepo appraisalRepo;
-
     private MerchantClassificationRepo merchantClassificationRepo;
 
     private OrderGoodsSpecRepo orderGoodsSpecRepo;

+ 1 - 1
src/main/java/com/izouma/dingdong/service/rider/RiderService.java

@@ -32,7 +32,7 @@ public class RiderService {
     /*
     骑手收入,且保存到记录表
      */
-    public void income(Long riderId, Long fromUserId, BigDecimal amount, FinancialType type) {
+    public void income(Long riderId, Long fromUserId, BigDecimal amount, FinancialType type, String remark) {
         //骑手应得  riderRepo.findUserIdById(riderId)
         User riderUser = userRepo.findById(riderId).orElseThrow(new BusinessException("无用户"));
         riderUser.setMoney(riderUser.getMoney().add(amount));

+ 8 - 2
src/main/java/com/izouma/dingdong/web/OrderRefundApplyController.java

@@ -98,8 +98,14 @@ public class OrderRefundApplyController extends BaseController {
 
     @ApiOperation("平台是否同意退款")
     @GetMapping("/platformAudit")
-    public void platformAudit(Long applyId, Boolean agree, BigDecimal merchantLiability, BigDecimal riderLiability) {
-        orderRefundApplyService.platformAudit(applyId, agree, merchantLiability, riderLiability);
+    public void platformAudit(Long id, Boolean agree, BigDecimal merchantLiability, BigDecimal riderLiability) {
+        orderRefundApplyService.platformAudit(id, agree, merchantLiability, riderLiability, false);
+    }
+
+    @ApiOperation("已打款")
+    @GetMapping("/payment")
+    public void payment(@RequestParam Long id){
+        orderRefundApplyService.payment(id);
     }
 }
 

+ 4 - 2
src/main/java/com/izouma/dingdong/web/backstage/ComplaintController.java

@@ -71,9 +71,10 @@ public class ComplaintController extends BaseController {
     public void refund(Long id, BigDecimal merchantLiability, BigDecimal riderLiability, String remark) {
         Complaint complaint = complaintRepo.findById(id).orElseThrow(new BusinessException("无记录"));
         OrderRefundApply apply = orderRefundApplyService.apply(complaint.getOrderId(), RefundReason.USER_COMPLAINTS, remark);
-        orderRefundApplyService.audit(apply.getId(), false, true);
-        orderRefundApplyService.platformAudit(apply.getId(), true, merchantLiability, riderLiability);
+        orderRefundApplyService.audit(apply.getId(), false, false);
+        orderRefundApplyService.platformAudit(apply.getId(), true, merchantLiability, riderLiability, true);
         complaint.setSolution(Solution.REFUND);
+        complaint.setResolve(true);
         complaintRepo.save(complaint);
     }
 
@@ -82,6 +83,7 @@ public class ComplaintController extends BaseController {
         Complaint complaint = complaintRepo.findById(id).orElseThrow(new BusinessException("无记录"));
         userCouponService.issue(userId, couponId);
         complaint.setSolution(Solution.ISSUE_COUPONS);
+        complaint.setResolve(true);
         complaintRepo.save(complaint);
     }
 }

+ 18 - 2
src/main/vue/src/router.js

@@ -443,7 +443,7 @@ const router = new Router({
                 {
                     path: '/orderRefundApplyEdit',
                     name: 'OrderRefundApplyEdit',
-                    component: () => import(/* webpackChunkName: "withdrawalsRecordEdit" */ '@/views/backstage/OrderRefundApplyEdit.vue'),
+                    component: () => import(/* webpackChunkName: "orderRefundApplyEdit" */ '@/views/backstage/OrderRefundApplyEdit.vue'),
                     meta: {
                         title: '退款申请编辑',
                     },
@@ -451,11 +451,27 @@ const router = new Router({
                 {
                     path: '/orderRefundApplyList',
                     name: 'OrderRefundApplyList',
-                    component: () => import(/* webpackChunkName: "withdrawalsRecordList" */ '@/views/backstage/OrderRefundApplyList.vue'),
+                    component: () => import(/* webpackChunkName: "orderRefundApplyList" */ '@/views/backstage/OrderRefundApplyList.vue'),
                     meta: {
                         title: '退款申请',
                     },
                 },
+                {
+                    path: '/withdrawApplyEdit',
+                    name: 'WithdrawApplyEdit',
+                    component: () => import(/* webpackChunkName: "withdrawApplyEdit" */ '@/views/backstage/WithdrawApplyEdit.vue'),
+                    meta: {
+                        title: '退款申请编辑',
+                    },
+                },
+                {
+                    path: '/withdrawApplyList',
+                    name: 'WithdrawApplyList',
+                    component: () => import(/* webpackChunkName: "withdrawApplyList" */ '@/views/backstage/WithdrawApplyList.vue'),
+                    meta: {
+                        title: '提现申请',
+                    },
+                },
             ],
         },
         {

+ 45 - 26
src/main/vue/src/views/OrderInfoList.vue

@@ -12,6 +12,16 @@
             <el-button @click="download" type="primary" icon="el-icon-download"
                        :loading="downloading" class="filter-item">导出EXCEL
             </el-button>
+
+            <el-select v-model="status" class="filter-item" placeholder="筛选状态" clearable filterable
+                       @change="getData">
+                <el-option
+                        v-for="item in statusOptions"
+                        :label="item.label"
+                        :value="item.value"
+                        :key="item.value"
+                />
+            </el-select>
         </div>
         <el-table :data="tableData" row-key="id" ref="table"
                   header-row-class-name="table-header-row"
@@ -21,6 +31,7 @@
             <el-table-column v-if="multipleMode" align="center" type="selection"
                              width="50">
             </el-table-column>
+            <el-table-column prop="status" label="状态" :formatter="statusFormatter"></el-table-column>
             <el-table-column prop="id" label="ID" width="100">
             </el-table-column>
             <el-table-column prop="user.nickname" label="用户"
@@ -43,9 +54,9 @@
                              :formatter="riderStatusFormatter"
             >
             </el-table-column>
-<!--            <el-table-column prop="goodsAmount" label="商品总价"-->
-<!--            >-->
-<!--            </el-table-column>-->
+            <!--            <el-table-column prop="goodsAmount" label="商品总价"-->
+            <!--            >-->
+            <!--            </el-table-column>-->
             <el-table-column prop="deliveryAmount" label="配送费"
             >
             </el-table-column>
@@ -56,19 +67,18 @@
                              :formatter="payMethodFormatter"
             >
             </el-table-column>
-<!--            <el-table-column prop="cancel" label="取消订单"
-            >
-                <template slot-scope="{row}">
-                    <el-tag :type="row.cancel?'':'info'">{{row.cancel}}</el-tag>
-                </template>
-            </el-table-column>-->
-<!--            <el-table-column prop="rated" label="已评价"
-            >
-                <template slot-scope="{row}">
-                    <el-tag :type="row.rated?'':'info'">{{row.rated}}</el-tag>
-                </template>
-            </el-table-column>-->
-            <el-table-column prop="status" label="状态" :formatter="statusFormatter"></el-table-column>
+            <!--            <el-table-column prop="cancel" label="取消订单"
+                        >
+                            <template slot-scope="{row}">
+                                <el-tag :type="row.cancel?'':'info'">{{row.cancel}}</el-tag>
+                            </template>
+                        </el-table-column>-->
+            <!--            <el-table-column prop="rated" label="已评价"
+                        >
+                            <template slot-scope="{row}">
+                                <el-tag :type="row.rated?'':'info'">{{row.rated}}</el-tag>
+                            </template>
+                        </el-table-column>-->
             <el-table-column prop="orderTime" label="下单时间"
                              :formatter="datetimeFormatter"
             >
@@ -138,15 +148,16 @@
                 search: "",
                 url: "/orderInfo/all",
                 downloading: false,
-                statusOptions:[{"label": "未支付", "value": "UNPAID"},
-                    { "label": "已支付","value": "PAID"},
-                    { "label": "待评价","value": "RATED"},
-                    { "label": "已取消","value": "CANCELLED"},
-                    { "label": "申请退款中","value": "REFUNDED_PENDING"},
+                statusOptions: [{"label": "未支付", "value": "UNPAID"},
+                    {"label": "已支付", "value": "PAID"},
+                    {"label": "待评价", "value": "RATED"},
+                    {"label": "已取消", "value": "CANCELLED"},
+                    {"label": "申请退款中", "value": "REFUNDED_PENDING"},
+                    {"label": "退款中", "value": "REFUNDING"},
                     {"label": "已退款", "value": "REFUNDED"},
                     {"label": "已完成", "value": "COMPLETED"}],
 
-                merchantStatusOptions:[{"label": "接单", "value": "RECEIVED"}, {
+                merchantStatusOptions: [{"label": "接单", "value": "RECEIVED"}, {
                     "label": "未接单",
                     "value": "NOT_RECEIVED"
                 }, {"label": "已拒单", "value": "REJECTED"}],
@@ -160,6 +171,8 @@
                     "label": "货到付款",
                     "value": "CASH_DELIVERY"
                 }, {"label": "信用卡", "value": "CREDIT_CARD"}],
+
+                status: ''
             }
         },
         computed: {
@@ -197,9 +210,15 @@
                 return '';
             },
             beforeGetData() {
-                if (this.search) {
-                    return {search: this.search};
-                }
+
+                return {
+                    search: this.search,
+                    query: {
+                        status: this.status,
+                    },
+                    sort: "createdAt,desc"
+                };
+
             },
             toggleMultipleMode(multipleMode) {
                 this.multipleMode = multipleMode;
@@ -219,7 +238,7 @@
                 this.$router.push({
                     path: "/orderInfoEdit",
                     query: {
-                    id: row.id
+                        id: row.id
                     }
                 });
             },

+ 33 - 22
src/main/vue/src/views/backstage/ComplaintEdit.vue

@@ -8,10 +8,10 @@
             <el-form-item prop="target" label="投诉目标">
                 <el-select v-model="formData.target" clearable filterable placeholder="请选择">
                     <el-option disabled
-                            v-for="item in targetOptions"
-                            :key="item.value"
-                            :label="item.label"
-                            :value="item.value">
+                               v-for="item in targetOptions"
+                               :key="item.value"
+                               :label="item.label"
+                               :value="item.value">
                     </el-option>
                 </el-select>
             </el-form-item>
@@ -20,23 +20,28 @@
             </el-form-item>
             <el-form-item prop="img" label="图片">
                 <!--<multi-upload v-model="formData.img"></multi-upload>-->
-                <el-image style="width: 30px; height: 30px"
-                          :src="picList(formData.img)[0]" fit="cover"
-                          :preview-src-list="picList(row.img)?picList(row.img):[]"></el-image>
+                <!-- <el-image style="width: 30px; height: 30px"
+                           :src="picList(formData.img)[0]" fit="cover"
+                           :preview-src-list="picList(row.img)?picList(row.img):[]"></el-image>-->
+
+                <el-image v-for="item in picList(formData.img)" style="width: 80px; height: 80px; padding-right: 10px"
+                          :src="item" fit="cover" :preview-src-list="[item]"
+                ></el-image>
             </el-form-item>
             <el-form-item prop="content" label="内容">
-                <el-input type="textarea" v-model="formData.content"></el-input>
+                <el-input type="textarea" v-model="formData.content" readonly></el-input>
             </el-form-item>
             <el-form-item prop="resolve" label="是否解决">
                 <el-switch v-model="formData.resolve"></el-switch>
             </el-form-item>
             <el-form-item prop="time" label="投诉时间">
-                <el-date-picker
-                        v-model="formData.time"
-                        type="datetime"
-                        value-format="yyyy-MM-dd HH:mm:ss"
-                        placeholder="选择日期时间">
-                </el-date-picker>
+                <!--     <el-date-picker
+                             v-model="formData.time"
+                             type="datetime"
+                             value-format="yyyy-MM-dd HH:mm:ss"
+                             placeholder="选择日期时间">
+                     </el-date-picker>-->
+                <el-input v-model="formData.time" readonly></el-input>
             </el-form-item>
             <el-form-item prop="solution" label="解决方式">
                 <el-select v-model="formData.solution" clearable filterable placeholder="请选择">
@@ -51,7 +56,7 @@
                            @click="showCoupon">发放优惠券
                 </el-button>
                 <el-button class="left" type="warning" v-if="formData.solution==='REFUND'" size="mini"
-                           @click="onRefund">退款
+                           @click="dislogForm=true">退款
                 </el-button>
             </el-form-item>
             <el-form-item>
@@ -102,10 +107,10 @@
                                      :min='0' :step="0.01" :max="1"></el-input-number>
                 </el-form-item>
                 <el-form-item label="备注">
-                    <el-input v-model="remark"></el-input>
+                    <el-input v-model="remark" type="textarea"></el-input>
                 </el-form-item>
                 <el-form-item>
-                    <el-button>确定</el-button>
+                    <el-button @click="onRefundApply">确定</el-button>
                 </el-form-item>
             </el-form>
 
@@ -149,6 +154,13 @@
             }
         },
         methods: {
+            picList(row) {
+                if (row) {
+                    return row.split(",");
+                } else {
+                    return "";
+                }
+            },
             onSave() {
                 this.$refs.form.validate((valid) => {
                     if (valid) {
@@ -224,11 +236,7 @@
                         console.log(e);
                     });
             },
-            onRefund() {
-                this.dislogForm = true;
-            },
             onRefundApply() {
-                this.dislogTableCoupon = true;
                 if (this.merchantLiability + this.riderLiability > 1) {
                 }
                 this.$http
@@ -240,10 +248,13 @@
 
                     })
                     .then(res => {
-
+                        this.formData.resolve = true;
+                        this.$message.success("退款成功");
+                        this.$router.go(0);
                     })
                     .catch(e => {
                         console.log(e);
+                        this.$message.error(e.error || '退款失败');
                     });
 
             }

+ 77 - 20
src/main/vue/src/views/backstage/OrderRefundApplyList.vue

@@ -40,7 +40,7 @@
             <!--            <el-table-column prop="orderId" label="订单ID"
                         >
                         </el-table-column>-->
-            <el-table-column prop="orderForm.num" label="订单号"
+            <el-table-column prop="orderId" label="订单号"
             >
             </el-table-column>
             <el-table-column prop="remark" label="备注"></el-table-column>
@@ -101,33 +101,40 @@
                                 <el-button @click="deleteRow(row)" type="danger" size="mini" plain>删除</el-button>
                             </template>
                         </el-table-column>-->
-            <el-table-column label="操作" align="center" fixed="right" min-width="150">
+            <el-table-column label="操作" align="center" fixed="right" min-width="250">
                 <template slot-scope="{ row }">
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
                     <el-button
-                            v-if="row.status === 'PENDING'"
+                            v-if="row.status === 'PENDING_PAYMENT'"
                             :loading="row.loading"
-                            @click="audit(row, true)"
+                            @click="payment(row)"
+                            type="primary"
+                            size="mini"
+                            plain
+                    >打款
+                    </el-button>
+                    <el-button
+                            v-if="row.status === 'PENDING' && row.report"
+                            :loading="row.loading"
+                            @click="audit(row)"
                             type="primary"
                             size="mini"
                             plain
                     >通过
-                    </el-button
-                    >
+                    </el-button>
                     <el-button
-                            v-if="row.status === 'PENDING'"
-                            @click="audit(row, false)"
+                            v-if="row.status === 'PENDING' && row.report"
+                            @click="platformAudit(row, false)"
                             type="danger"
                             size="mini"
                             plain
                     >拒绝
-                    </el-button
-                    >
+                    </el-button>
                 </template>
             </el-table-column>
         </el-table>
         <div class="pagination-wrapper">
-            <div class="multiple-mode-wrapper">
+            <!--<div class="multiple-mode-wrapper">
                 <el-button v-if="!multipleMode"
                            @click="toggleMultipleMode(true)">批量编辑
                 </el-button>
@@ -136,7 +143,7 @@
                     <el-button @click="operation2">批量操作2</el-button>
                     <el-button @click="toggleMultipleMode(false)">取消</el-button>
                 </el-button-group>
-            </div>
+            </div>-->
             <el-pagination background @size-change="onSizeChange"
                            @current-change="onCurrentChange" :current-page="page"
                            :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize"
@@ -145,6 +152,30 @@
             </el-pagination>
         </div>
 
+        <el-dialog
+                title="退款"
+                center
+                :visible.sync="dislogForm"
+                width="400px"
+        >
+            <el-form>
+                <el-form-item label="商家责任">
+                    <el-input-number type="number" v-model="merchantLiability"
+                                     :min='0' :step="0.01" :max="1"></el-input-number>
+                </el-form-item>
+                <el-form-item label="骑手责任">
+                    <el-input-number type="number" v-model="riderLiability"
+                                     :min='0' :step="0.01" :max="1"></el-input-number>
+                </el-form-item>
+                <el-form-item label="备注">
+                    <el-input v-model="remark" type="textarea"></el-input>
+                </el-form-item>
+                <el-form-item>
+                    <el-button @click="platformAudit(row)">确定</el-button>
+                </el-form-item>
+            </el-form>
+
+        </el-dialog>
     </div>
 </template>
 <script>
@@ -165,8 +196,9 @@
                 downloading: false,
                 statusOptions: [
                     {"label": "待处理", "value": "PENDING"},
-                    {"label": "退款中", "value": "REFUNDING"},
+                    /*{"label": "退款中", "value": "REFUNDING"},*/
                     {"label": "成功", "value": "SUCCESS"},
+                    {"label": "待打款", "value": "PENDING_PAYMENT"},
                     {"label": "失败", "value": "DENY"},
                     {"label": "取消退款", "value": "CANCEL"}],
                 reasonOptions: [
@@ -184,7 +216,11 @@
                     {"label": "临时有事不想要了", "value": "DO_NOT_WANT_SOMETHING_TEMPORARILY"},
                     {"label": "用户投诉", "value": "USER_COMPLAINTS"},
                     {"label": "其他原因", "value": "OTHER"}],
-                status: ''
+                status: '',
+                dislogForm: false,
+                merchantLiability: 0,
+                riderLiability: 0,
+                remark: '',
             }
         },
         computed: {
@@ -215,9 +251,6 @@
                     search: this.search,
                     query: {
                         status: this.status,
-                        //只需要上报的退款订单
-                        report: true,
-
                     },
                     sort: "applyTime,desc"
                 };
@@ -294,12 +327,16 @@
                     }
                 })
             },
-            audit(row, consent) {
+            platformAudit(row, agree) {
                 this.$set(row, 'loading', true);
                 this.$http
-                    .get('/orderRefundApply/audit', {
+                    .get('/orderRefundApply/platformAudit', {
                         id: row.id,
-                        consent: consent
+                        agree: agree,
+                        merchantLiability: this.merchantLiability,
+                        riderLiability: this.riderLiability,
+                        remark: this.remark
+
                     })
                     .then(res => {
                         this.$set(row, 'loading', false);
@@ -311,6 +348,26 @@
                         this.$set(row, 'loading', false);
                         this.$message.error(e.error);
                     });
+            },
+            payment(row) {
+                this.$alert('确认后将无法恢复,确认要已打款?', '提示', {type: 'warning'}).then(() => {
+                    return this.$http.get(`/orderRefundApply/payment`, {
+                        id: row.id
+                    })
+                }).then(() => {
+                    this.$message.success('确认成功');
+                    this.getData();
+                }).catch(action => {
+                    if (action === 'cancel') {
+                        this.$message.info('确认取消');
+                    } else {
+                        this.$message.error('确认失败');
+                    }
+                })
+            },
+            audit(row) {
+                this.dislogForm = true;
+
             }
         }
     }

+ 1 - 1
src/test/java/com/izouma/dingdong/service/OrderInfoServiceTest.java

@@ -15,7 +15,7 @@ public class OrderInfoServiceTest {
 
     @Test
     public void testCancel(){
-        System.out.println(orderInfoService.cancel(537L, RefundReason.DO_NOT_WANT_SOMETHING_TEMPORARILY));
+        System.out.println(orderInfoService.cancel(1359L, RefundReason.ORDER_TIMEOUT));
     }
 
 

+ 2 - 1
src/test/java/com/izouma/dingdong/service/OrderRefundApplyServiceTest.java

@@ -15,6 +15,7 @@ public class OrderRefundApplyServiceTest {
 
     @Test
     public void test() {
-        orderRefundApplyService.audit(1776L, false, true);
+        //需要商家同意 都需要赔付骑手
+        orderRefundApplyService.audit(1813L, false, true);
     }
 }

+ 1 - 5
src/test/java/com/izouma/dingdong/service/ShoppingCartServiceTest.java

@@ -68,11 +68,7 @@ public class ShoppingCartServiceTest {
             System.out.println("null");
         } else {
             List<OrderGoodsSpec> specs = cart.getOrderGoodsSpecs();
-            if (CollUtil.isEmpty(specs)) {
-                System.out.println("null");
-            } else {
-                System.out.println(specs);
-            }
+            System.out.println(specs);
         }
     }
 }