wupengfei 2 år sedan
förälder
incheckning
249c2bd87f

+ 1 - 0
addons/shopro/model/UserWalletLog.php

@@ -50,6 +50,7 @@ class UserWalletLog extends Model
         'invite_integral' => ['code' => 'invite_integral', 'name' => '邀请会员注册奖励'],
         'be_invited' => ['code' => 'be_invited', 'name' => '被邀请注册奖励'],
         'not_be_invited' => ['code' => 'not_be_invited', 'name' => '注册奖励'],
+        'order_shift' => ['code' => 'order_shift', 'name' => '订单转换奖励'],
 
         // admin
         'admin_recharge' => ['code' => 'admin_recharge', 'name' => '后台充值'],

+ 33 - 36
application/admin/controller/shopro/order/OrderShift.php

@@ -1,7 +1,9 @@
 <?php
 
 namespace app\admin\controller\shopro\order;
+use addons\shopro\model\User;
 use app\admin\controller\shopro\Base;
+use think\Db;
 /**
  * 交易订单管理
  *
@@ -89,46 +91,41 @@ class OrderShift extends Base
     }
 
 
-
-    // 构建查询条件
-    private function buildSearchOrder()
+    public function audit($ids)
     {
-        $filter = $this->request->get("filter", '');
-        $filter = (array)json_decode($filter, true);
-        $filter = $filter ? $filter : [];
-
-        $status = isset($filter['status']) ? $filter['status'] : 'all';
-        $nickname = isset($filter['nickname']) ? $filter['nickname'] : '';
-        $mobile = isset($filter['user_phone']) ? $filter['user_phone'] : '';
-
-        $name = $this->model->getQuery()->getTable();
-        $tableName = $name . '.';
-
-        $orders = $this->model->withTrashed();
-
-        if ($nickname || $mobile) {
-            $orders = $orders->whereExists(function ($query) use ($nickname, $mobile, $tableName) {
-                $userTableName = (new \app\admin\model\User())->getQuery()->getTable();
-
-                $query = $query->table($userTableName)->where($userTableName . '.id=' . $tableName . 'user_id');
+        $ids = explode(',', $ids);
+        $successCount = 0;
+        $failedCount = 0;
+        $applyList = $this->model->where('id', 'in', $ids)->select();
+        if (!$applyList) $this->error('未找到申请记录');
+        $operate = $this->request->post('operate');
+        $integral = intval($this->request->post('integral')) ;
+        foreach ($applyList as $apply) {
+            Db::startTrans();
+            try {
+                if($operate == 1 && $integral> 0)User::score($integral, $apply->user_id, 'order_shift',$apply->id);
+                $apply->sh_status = $operate;
+                $apply->remark = $this->request->post('remark');
+                $apply->sh_time = date("Y-m-d H:i:s");
+                if($integral> 0 && $operate == 1)  $apply->integral = $integral;
+                $apply->save();
+                Db::commit();
+            } catch (\Exception $e) {
+                Db::rollback();
+                $failedCount++;
+                $lastErrorMessage = $e->getMessage();
+            }
+        }
+        if (count($ids) === 1) {
+            if ($successCount) $this->success('操作成功');
+            if ($failedCount) $this->error($lastErrorMessage);
+        } else {
+            $this->success('成功: ' . $successCount . '笔' . ' | 失败: ' . $failedCount . '笔');
+        }
+    }
 
-                if ($nickname) {
-                    $query = $query->where('nickname', 'like', "%{$nickname}%");
-                }
 
-                if ($mobile) {
-                    $query = $query->where('mobile', 'like', "%{$mobile}%");
-                }
 
-                return $query;
-            });
-        }
 
-        // 订单状态
-        if ($status != 'all' && in_array($status, ['invalid', 'cancel', 'nopay', 'payed', 'finish'])) {
-            $orders = $orders->{$status}();
-        }
 
-        return $orders;
-    }
 }

+ 9 - 5
application/admin/view/shopro/order/order_shift/index.html

@@ -163,6 +163,9 @@
         justify-content: flex-end;
         margin-top: 30px;
     }
+    .custom-table-color-primary {
+        color: #6E3DC8;
+    }
 </style>
 <script src="__CDN__/assets/addons/shopro/libs/vue.js"></script>
 <script src="__CDN__/assets/addons/shopro/libs/element/element.js"></script>
@@ -272,6 +275,7 @@
             <el-table-column min-width="140" fixed="right" label="操作" align="left">
                 <template slot-scope="scope">
                     <span v-if="scope.row.sh_status==0" class="custom-table-operation-text custom-table-color-primary"  @click="openAgreeDialog(scope.row)">审核</span>
+                    <span v-if="scope.row.sh_status!=0" class="custom-table-operation-text custom-table-color-primary">已审核</span>
                 </template>
             </el-table-column>
 
@@ -288,12 +292,12 @@
     <el-dialog custom-class="refuse-dialog agree-dialog" title="操作提示" :visible.sync="agreeDialogVisible"
                :before-close="closeAgreeDialog">
         <span slot="footer">
-            <div>
-                <el-input v-model="auditForm.remark" placeholder="请输入审核备注"></el-input>
-                <el-input v-model="auditForm.integral" placeholder="请输入兑换积分数量"></el-input>
-            </div>
+            <div><el-input v-model="auditForm.remark" placeholder="请输入审核备注"></el-input></div><br>
+            <div><el-input v-model="auditForm.integral" placeholder="请输入兑换积分数量"></el-input></div>
+            <br>
             <el-button @click="closeAgreeDialog" size="small">取消</el-button>
-            <el-button type="primary" @click="agreePayment()" size="small" plain>同意</el-button>
+            <el-button v-if="agreeRow.sh_status==0" type="primary" @click="audit()" size="small" plain>同意</el-button>
+            <el-button v-if="agreeRow.sh_status==0" type="danger"  @click="audit()" size="small">拒绝</el-button>
         </span>
     </el-dialog>
 </div>

+ 36 - 5
public/assets/js/backend/shopro/order/order_shift.js

@@ -68,14 +68,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
                         },
                         focusi: false,
-                        // 同意
+                        //审核
                         agreeDialogVisible : false,
-
                         agreeRow : {},
-
                         auditForm: {
                             remark: '',
-                            integral: '0',
+                            integral: '',
                         },
                     }
                 },
@@ -112,7 +110,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 limit: that.limit,
                             }
                         }, function (ret, res) {
-                            console.log(res)
                             that.orderList = res.data.rows;
                             that.totalPage = res.data.total;
                             that.focusi = false;
@@ -150,6 +147,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     closeAgreeDialog() {
                         this.agreeDialogVisible = false;
                     },
+                    reqApplyOper(row, status, remark,integral) {
+                        let that = this;
+                        let ids = ''
+                        if (Array.isArray(row)) {
+                            let idsArr = []
+                            row.forEach(m => {
+                                idsArr.push(m.id)
+                            })
+                            ids = idsArr.join(',')
+                        } else {
+                            ids = row.id
+                        }
+                        let reaData = {
+                            operate: status,
+                            remark:remark,
+                            integral:integral,
+                        }
+                        Fast.api.ajax({
+                            url: `shopro/order/order_shift/audit/ids/${ids}`,
+                            loading: true,
+                            type: 'POST',
+                            data: reaData
+                        }, function (ret, res) {
+                            that.getData(that.offset, that.limit);
+                            that.agreeDialogVisible = false
+                            that.refuseDialogVisible = false;
+                            that.auditForm.remark = "";
+                            return false;
+                        })
+                    },
+                    audit() {
+                        this.reqApplyOper(this.agreeRow, this.auditForm.sh_status, this.auditForm.remark,this.auditForm.integral)
+                    },
+
                 },
             })
         },