1 个管道
的构建
通过
耗费
10 秒
增加提交废品表单审核通过之后增加积分
正在显示
7 个修改的文件
包含
107 行增加
和
5 行删除
@@ -108,12 +108,14 @@ class Porder extends Backend | @@ -108,12 +108,14 @@ class Porder extends Backend | ||
108 | if ($ids) { | 108 | if ($ids) { |
109 | $pk = $this->model->getPk(); | 109 | $pk = $this->model->getPk(); |
110 | $res = $this->model->where($pk, '=', $ids)->find(); | 110 | $res = $this->model->where($pk, '=', $ids)->find(); |
111 | + Db::startTrans(); | ||
111 | if ($res['is_due'] == 0) { | 112 | if ($res['is_due'] == 0) { |
112 | $data = $this->model->where($pk, '=', $ids)->find(); | 113 | $data = $this->model->where($pk, '=', $ids)->find(); |
113 | $userModel = new User(); | 114 | $userModel = new User(); |
114 | $money = (1 - $this->percent) * $data['total_price']; | 115 | $money = (1 - $this->percent) * $data['total_price']; |
115 | //用户账户增加余额 | 116 | //用户账户增加余额 |
116 | $result = $userModel->where(['id'=>$data['s_uid'],'status'=>'normal'])->setInc('money',$money); | 117 | $result = $userModel->where(['id'=>$data['s_uid'],'status'=>'normal'])->setInc('money',$money); |
118 | + | ||
117 | //平台账户增加余额 | 119 | //平台账户增加余额 |
118 | $platformModel = new Platform(); | 120 | $platformModel = new Platform(); |
119 | $account_balance = $this->percent * $data['total_price']; | 121 | $account_balance = $this->percent * $data['total_price']; |
@@ -121,8 +123,10 @@ class Porder extends Backend | @@ -121,8 +123,10 @@ class Porder extends Backend | ||
121 | //订单更新扣取费用字段 | 123 | //订单更新扣取费用字段 |
122 | $result2 = $this->model->where($pk, '=', $ids)->update(['is_due'=>1]); | 124 | $result2 = $this->model->where($pk, '=', $ids)->update(['is_due'=>1]); |
123 | if($result && $result1 && $result2){ | 125 | if($result && $result1 && $result2){ |
126 | + Db::commit(); | ||
124 | $this->success('扣取成功'); | 127 | $this->success('扣取成功'); |
125 | }else{ | 128 | }else{ |
129 | + Db::rollback(); | ||
126 | $this->error('扣取失败'); | 130 | $this->error('扣取失败'); |
127 | } | 131 | } |
128 | } else { | 132 | } else { |
@@ -3,7 +3,8 @@ | @@ -3,7 +3,8 @@ | ||
3 | namespace app\admin\controller; | 3 | namespace app\admin\controller; |
4 | 4 | ||
5 | use app\common\controller\Backend; | 5 | use app\common\controller\Backend; |
6 | - | 6 | +use app\admin\model\User; |
7 | +use think\Db; | ||
7 | /** | 8 | /** |
8 | * 卖废品管理 | 9 | * 卖废品管理 |
9 | * | 10 | * |
@@ -74,4 +75,44 @@ class Sell extends Backend | @@ -74,4 +75,44 @@ class Sell extends Backend | ||
74 | } | 75 | } |
75 | return $this->view->fetch(); | 76 | return $this->view->fetch(); |
76 | } | 77 | } |
78 | + | ||
79 | + //审核通过 | ||
80 | + public function adopt($ids){ | ||
81 | + if ($ids) { | ||
82 | + $pk = $this->model->getPk(); | ||
83 | + $result2 = $this->model->where($pk, '=', $ids)->update(['status' => 1]); | ||
84 | + //给自己增加积分 | ||
85 | + $data = $this->model->where($pk, '=', $ids)->find(); | ||
86 | + $userModel = new User(); | ||
87 | + $scoreRule = Db::name('score') | ||
88 | + ->where('set_rule', 'like', '%卖废品%') | ||
89 | + ->field('set_score') | ||
90 | + ->find(); | ||
91 | + $score = 0; | ||
92 | + if ($scoreRule) { | ||
93 | + $score = $scoreRule['set_score']; | ||
94 | + } | ||
95 | + $result = $userModel->where(['id' => $data['uid'], 'status' => 'normal'])->setInc('score', $score); | ||
96 | + if ($result2 && $result) { | ||
97 | + $this->success('成功'); | ||
98 | + } else { | ||
99 | + $this->error('失败'); | ||
100 | + } | ||
101 | + } | ||
102 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
103 | + } | ||
104 | + | ||
105 | + //审核驳回 | ||
106 | + public function reject($ids){ | ||
107 | + if ($ids) { | ||
108 | + $pk = $this->model->getPk(); | ||
109 | + $result2 = $this->model->where($pk, '=', $ids)->update(['status' => 2]); | ||
110 | + if ($result2) { | ||
111 | + $this->success('成功'); | ||
112 | + } else { | ||
113 | + $this->error('失败'); | ||
114 | + } | ||
115 | + } | ||
116 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
117 | + } | ||
77 | } | 118 | } |
@@ -66,6 +66,9 @@ return [ | @@ -66,6 +66,9 @@ return [ | ||
66 | 'pre_list' => '预约单', | 66 | 'pre_list' => '预约单', |
67 | 'purchase' => '购买', | 67 | 'purchase' => '购买', |
68 | 68 | ||
69 | + 'in_audit' => '审核中', | ||
70 | + 'adopt' => '通过', | ||
71 | + 'reject' => '驳回', | ||
69 | 72 | ||
70 | 'Locked' => '锁定', | 73 | 'Locked' => '锁定', |
71 | 'Submit' => '提交', | 74 | 'Submit' => '提交', |
@@ -8,6 +8,7 @@ return [ | @@ -8,6 +8,7 @@ return [ | ||
8 | 'Pre_time' => '预约时间', | 8 | 'Pre_time' => '预约时间', |
9 | 'Images' => '废品图片', | 9 | 'Images' => '废品图片', |
10 | 'Description' => '废品描述', | 10 | 'Description' => '废品描述', |
11 | + 'status' => '状态', | ||
11 | 'Createtime' => '创建时间', | 12 | 'Createtime' => '创建时间', |
12 | 'User.username' => '用户名', | 13 | 'User.username' => '用户名', |
13 | 'User.avatar' => '头像' | 14 | 'User.avatar' => '头像' |
@@ -62,8 +62,8 @@ class Sell extends Api | @@ -62,8 +62,8 @@ class Sell extends Api | ||
62 | $data['images'] = $sell_data['images']; | 62 | $data['images'] = $sell_data['images']; |
63 | $data = $sell::create($data); | 63 | $data = $sell::create($data); |
64 | //给自己增加积分 | 64 | //给自己增加积分 |
65 | - $data1 = $person->getPersonScore('person_sell'); | ||
66 | - if($data && $data1){ | 65 | +// $data1 = $person->getPersonScore('person_sell'); |
66 | + if($data){ | ||
67 | $this->success('保存成功'); | 67 | $this->success('保存成功'); |
68 | }else{ | 68 | }else{ |
69 | $this->error('保存失败'); | 69 | $this->error('保存失败'); |
@@ -45,11 +45,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -45,11 +45,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
45 | text: __('完成'), | 45 | text: __('完成'), |
46 | title: __('完成'), | 46 | title: __('完成'), |
47 | classname: 'btn btn-xs btn-success btn-magic btn-ajax', | 47 | classname: 'btn btn-xs btn-success btn-magic btn-ajax', |
48 | - icon: 'fa fa-magic', | 48 | + icon: 'fa', |
49 | url: 'porder/finish', | 49 | url: 'porder/finish', |
50 | confirm: '确认完成', | 50 | confirm: '确认完成', |
51 | success: function (data, ret) { | 51 | success: function (data, ret) { |
52 | Layer.alert(ret.msg); | 52 | Layer.alert(ret.msg); |
53 | + $(".btn-refresh").trigger("click"); | ||
53 | //如果需要阻止成功提示,则必须使用return false; | 54 | //如果需要阻止成功提示,则必须使用return false; |
54 | //return false; | 55 | //return false; |
55 | }, | 56 | }, |
@@ -31,8 +31,60 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -31,8 +31,60 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
31 | {field: 'address', title: __('Address')}, | 31 | {field: 'address', title: __('Address')}, |
32 | {field: 'pre_date', title: __('Pre_date'), operate:'RANGE', addclass:'datetimerange'}, | 32 | {field: 'pre_date', title: __('Pre_date'), operate:'RANGE', addclass:'datetimerange'}, |
33 | {field: 'pre_time', title: __('Pre_time')}, | 33 | {field: 'pre_time', title: __('Pre_time')}, |
34 | + {field: 'status', title: __('status'), formatter: Table.api.formatter.flag,searchList: {0: __('in_audit'), 1: __('adopt'),2: __('reject')}}, | ||
34 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 35 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
35 | - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 36 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [ |
37 | + { | ||
38 | + name: 'ajax', | ||
39 | + text: __('通过'), | ||
40 | + title: __('通过'), | ||
41 | + classname: 'btn btn-xs btn-success btn-magic btn-ajax', | ||
42 | + icon: 'fa', | ||
43 | + url: 'sell/adopt', | ||
44 | + confirm: '确认通过', | ||
45 | + success: function (data, ret) { | ||
46 | + Layer.alert(ret.msg); | ||
47 | + $(".btn-refresh").trigger("click"); | ||
48 | + //如果需要阻止成功提示,则必须使用return false; | ||
49 | + //return false; | ||
50 | + }, | ||
51 | + error: function (data, ret) { | ||
52 | + Layer.alert(ret.msg); | ||
53 | + return false; | ||
54 | + },visible: function (row) { | ||
55 | + if(row.status == 1){ | ||
56 | + return false;//隐藏 | ||
57 | + }else{ | ||
58 | + return true; | ||
59 | + } | ||
60 | + } | ||
61 | + }, | ||
62 | + { | ||
63 | + name: 'ajax', | ||
64 | + text: __('驳回'), | ||
65 | + title: __('驳回'), | ||
66 | + classname: 'btn btn-xs btn-danger btn-magic btn-ajax', | ||
67 | + icon: 'fa', | ||
68 | + url: 'sell/reject', | ||
69 | + confirm: '确认驳回', | ||
70 | + success: function (data, ret) { | ||
71 | + Layer.alert(ret.msg); | ||
72 | + $(".btn-refresh").trigger("click"); | ||
73 | + //如果需要阻止成功提示,则必须使用return false; | ||
74 | + //return false; | ||
75 | + }, | ||
76 | + error: function (data, ret) { | ||
77 | + Layer.alert(ret.msg); | ||
78 | + return false; | ||
79 | + },visible: function (row) { | ||
80 | + if(row.status == 2){ | ||
81 | + return false;//隐藏 | ||
82 | + }else{ | ||
83 | + return true; | ||
84 | + } | ||
85 | + } | ||
86 | + } | ||
87 | + ]} | ||
36 | ] | 88 | ] |
37 | ] | 89 | ] |
38 | }); | 90 | }); |
-
请 注册 或 登录 后发表评论