正在显示
8 个修改的文件
包含
162 行增加
和
25 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
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 | +use app\admin\model\User; | ||
6 | use think\Db; | 7 | use think\Db; |
7 | 8 | ||
8 | /** | 9 | /** |
@@ -19,6 +20,7 @@ class Porder extends Backend | @@ -19,6 +20,7 @@ class Porder extends Backend | ||
19 | */ | 20 | */ |
20 | protected $model = null; | 21 | protected $model = null; |
21 | protected $status = 0; | 22 | protected $status = 0; |
23 | + protected $percent = 0.01;//按照比例扣取费用1% | ||
22 | 24 | ||
23 | public function _initialize() | 25 | public function _initialize() |
24 | { | 26 | { |
@@ -93,4 +95,26 @@ class Porder extends Backend | @@ -93,4 +95,26 @@ class Porder extends Backend | ||
93 | } | 95 | } |
94 | return $this->view->fetch(); | 96 | return $this->view->fetch(); |
95 | } | 97 | } |
98 | + | ||
99 | + //按照比例扣取费用 | ||
100 | + public function finish($ids){ | ||
101 | + if ($ids) { | ||
102 | + $pk = $this->model->getPk(); | ||
103 | + $res = $this->model->where($pk, '=', $ids)->find(); | ||
104 | + if ($res['is_due'] == 0) { | ||
105 | + $data = $this->model->where($pk, '=', $ids)->find(); | ||
106 | + $userModel = new User(); | ||
107 | + $money = (1 - $this->percent) * $data['total_price']; | ||
108 | + $result = $userModel->where(['id'=>$data['s_uid'],'status'=>'normal'])->setInc('money',$money); | ||
109 | + if($result){ | ||
110 | + $this->success('扣取成功'); | ||
111 | + }else{ | ||
112 | + $this->error('扣取失败'); | ||
113 | + } | ||
114 | + } else { | ||
115 | + $this->error('您已经扣取过了'); | ||
116 | + } | ||
117 | + } | ||
118 | + $this->error(__('Parameter %s can not be empty', 'ids')); | ||
119 | + } | ||
96 | } | 120 | } |
@@ -49,11 +49,11 @@ class Line extends Backend | @@ -49,11 +49,11 @@ class Line extends Backend | ||
49 | return $this->selectpage(); | 49 | return $this->selectpage(); |
50 | } | 50 | } |
51 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | 51 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); |
52 | - $uid = $this->request->ids; | 52 | + $uid = $this->request->param('ids'); |
53 | $total = $this->model | 53 | $total = $this->model |
54 | ->with(['user']) | 54 | ->with(['user']) |
55 | ->where($where) | 55 | ->where($where) |
56 | -// ->where('uid',$uid) | 56 | + ->where('uid',$uid) |
57 | ->group('off_uid') | 57 | ->group('off_uid') |
58 | ->order($sort, $order) | 58 | ->order($sort, $order) |
59 | ->count(); | 59 | ->count(); |
@@ -62,7 +62,7 @@ class Line extends Backend | @@ -62,7 +62,7 @@ class Line extends Backend | ||
62 | ->with(['user']) | 62 | ->with(['user']) |
63 | ->field('sum(s_score) as score') | 63 | ->field('sum(s_score) as score') |
64 | ->where($where) | 64 | ->where($where) |
65 | -// ->where('uid',$uid) | 65 | + ->where('uid',$uid) |
66 | ->group('off_uid') | 66 | ->group('off_uid') |
67 | ->order($sort, $order) | 67 | ->order($sort, $order) |
68 | ->limit($offset, $limit) | 68 | ->limit($offset, $limit) |
@@ -7,6 +7,7 @@ use addons\epay\library\Service; | @@ -7,6 +7,7 @@ use addons\epay\library\Service; | ||
7 | use app\admin\model\Porder; | 7 | use app\admin\model\Porder; |
8 | use think\Db; | 8 | use think\Db; |
9 | use Yansongda\Pay\Pay; | 9 | use Yansongda\Pay\Pay; |
10 | +use app\admin\model\Account; | ||
10 | use think\Log; | 11 | use think\Log; |
11 | use fast\Http; | 12 | use fast\Http; |
12 | use think\Validate; | 13 | use think\Validate; |
@@ -16,8 +17,8 @@ use Exception; | @@ -16,8 +17,8 @@ use Exception; | ||
16 | */ | 17 | */ |
17 | class Wxpay extends Api | 18 | class Wxpay extends Api |
18 | { | 19 | { |
19 | - protected $noNeedLogin = ['notify','wechatReturn']; | ||
20 | - protected $noNeedRight = ['notify','wechatReturn']; | 20 | + protected $noNeedLogin = ['notify','wechatReturn','notifyCharge']; |
21 | + protected $noNeedRight = ['notify','wechatReturn','notifyCharge']; | ||
21 | protected $user_id = '';//token存贮user_id | 22 | protected $user_id = '';//token存贮user_id |
22 | protected $order_status = [];//订单状态 | 23 | protected $order_status = [];//订单状态 |
23 | public function _initialize() | 24 | public function _initialize() |
@@ -85,7 +86,46 @@ class Wxpay extends Api | @@ -85,7 +86,46 @@ class Wxpay extends Api | ||
85 | } | 86 | } |
86 | } | 87 | } |
87 | 88 | ||
88 | - //支付成功回调 | 89 | + /** |
90 | + * @ApiTitle (商品订单去付款) | ||
91 | + * @ApiSummary (商品订单去付款) | ||
92 | + * @ApiMethod (POST) | ||
93 | + * @ApiRoute (/api/wxpay/toPay) | ||
94 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
95 | + * @ApiParams (name="o_id", type="integer", required=true, description="订单id") | ||
96 | + * @ApiReturn ({ | ||
97 | + "code": 1, | ||
98 | + "msg": "成功", | ||
99 | + "time": "1554184134", | ||
100 | + "data": { | ||
101 | + "pay_order_sn": "155418413436253500503" | ||
102 | + } | ||
103 | + }) | ||
104 | + */ | ||
105 | + public function toPay(){ | ||
106 | + if($this->request->isGet()){ | ||
107 | + $o_id = $this->request->get('o_id');//订单id | ||
108 | + $pay = $this->auth->genPayOrderSn();//支付订单号 | ||
109 | + $rule = config('site.orders'); | ||
110 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
111 | + if (!$validate->check(['o_id'=>$o_id])) { | ||
112 | + $this->error($validate->getError()); | ||
113 | + } | ||
114 | + $p_order = new Porder(); | ||
115 | + $res = $p_order->where(['id'=>$o_id,'uid'=>$this->user_id])->update(['pay_order_sn'=>$pay]); | ||
116 | + if($res){ | ||
117 | + $this->success('成功',['pay_order_sn'=>$pay]); | ||
118 | + }else{ | ||
119 | + $this->error('失败'); | ||
120 | + } | ||
121 | + }else{ | ||
122 | + $this->error('请求方式错误'); | ||
123 | + } | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * 支付成功回调 | ||
128 | + */ | ||
89 | public function notify(){ | 129 | public function notify(){ |
90 | $pay = Service::checkNotify('wechat'); | 130 | $pay = Service::checkNotify('wechat'); |
91 | if (!$pay) { | 131 | if (!$pay) { |
@@ -102,7 +142,9 @@ class Wxpay extends Api | @@ -102,7 +142,9 @@ class Wxpay extends Api | ||
102 | return; | 142 | return; |
103 | } | 143 | } |
104 | 144 | ||
105 | - //微信异步通知 | 145 | + /** |
146 | + * 微信异步通知 | ||
147 | + */ | ||
106 | public function wechatReturn(){ | 148 | public function wechatReturn(){ |
107 | $pay = Service::checkReturn('wechat'); | 149 | $pay = Service::checkReturn('wechat'); |
108 | if (!$pay) { | 150 | if (!$pay) { |
@@ -113,4 +155,53 @@ class Wxpay extends Api | @@ -113,4 +155,53 @@ class Wxpay extends Api | ||
113 | return; | 155 | return; |
114 | } | 156 | } |
115 | 157 | ||
158 | + public function payCharge(){ | ||
159 | + if($this->request->isPost()){ | ||
160 | + $amount = $this->request->request('amount'); | ||
161 | + $openid = $this->request->post('openid');//小程序传递openid | ||
162 | + if(empty($openid)){ | ||
163 | + $this->error("openid必填"); | ||
164 | + } | ||
165 | + $pay = Pay::wechat(Service::getConfig('wechat')); | ||
166 | + if (!$amount || $amount < 0) { | ||
167 | + $this->error("充值金额必须大于0"); | ||
168 | + } | ||
169 | + $pay_order_sn = $this->auth->genPayOrderSn();//支付订单号 | ||
170 | + //构建订单信息 | ||
171 | + $order = [ | ||
172 | + 'out_trade_no' => $pay_order_sn,//支付订单号 | ||
173 | + 'body' => '广西小纸皮再生资源回收有限公司', | ||
174 | +// 'total_fee' => 1, | ||
175 | + 'total_fee' => floatval($amount)*100,//单位:分 | ||
176 | + 'openid' => $openid, | ||
177 | + 'notify_url' => url('api/Wxpay/notifyCharge','','',true), | ||
178 | + 'return_url' => url('api/Wxpay/wechatReturn','','',true), | ||
179 | + ]; | ||
180 | + //跳转或输出 | ||
181 | + $this->success('成功',$pay->miniapp($order)); | ||
182 | + }else{ | ||
183 | + $this->error('请求方式错误'); | ||
184 | + } | ||
185 | + } | ||
186 | + | ||
187 | + /** | ||
188 | + * 充值成功回调 | ||
189 | + */ | ||
190 | + public function notifyCharge(){ | ||
191 | + $pay = Service::checkNotify('wechat'); | ||
192 | + if (!$pay) { | ||
193 | + $this->error('签名错误'); | ||
194 | + } | ||
195 | + //你可以在这里你的业务处理逻辑,比如处理你的订单状态、给会员加余额等等功能 | ||
196 | + $data = $pay->verify(); | ||
197 | + if($data['return_code'] == 'SUCCESS' && $data['result_code'] == 'SUCCESS') { | ||
198 | + $accountModel = new Account(); | ||
199 | + Log::info($data); | ||
200 | + Log::info('充值回调'); | ||
201 | + //下面这句必须要执行,且在此之前不能有任何输出 | ||
202 | + echo $pay->success(); | ||
203 | + } | ||
204 | + return; | ||
205 | + } | ||
206 | + | ||
116 | } | 207 | } |
@@ -268,4 +268,13 @@ return array ( | @@ -268,4 +268,13 @@ return array ( | ||
268 | 'page.number' => '页码必须是数字', | 268 | 'page.number' => '页码必须是数字', |
269 | ] | 269 | ] |
270 | ], | 270 | ], |
271 | + 'orders' => [ | ||
272 | + 'rule' => [ | ||
273 | + 'o_id' => 'require|number', | ||
274 | + ], | ||
275 | + 'msg' => [ | ||
276 | + 'o_id.require' => '订单id不能为空', | ||
277 | + 'o_id.number' => '订单id必须是数字', | ||
278 | + ] | ||
279 | + ], | ||
271 | ); | 280 | ); |
@@ -27,8 +27,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -27,8 +27,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
27 | {field: 'id', title: __('Id')}, | 27 | {field: 'id', title: __('Id')}, |
28 | {field: 'user.username', title: __('User.username')}, | 28 | {field: 'user.username', title: __('User.username')}, |
29 | {field: 'user.avatar', title: __('User.avatar'),formatter:Table.api.formatter.image}, | 29 | {field: 'user.avatar', title: __('User.avatar'),formatter:Table.api.formatter.image}, |
30 | - {field: 'bank.open_bank', title: __('Bank.open_bank')}, | ||
31 | - {field: 'bank.bank_num', title: __('Bank.bank_num')}, | 30 | + // {field: 'bank.open_bank', title: __('Bank.open_bank')}, |
31 | + // {field: 'bank.bank_num', title: __('Bank.bank_num')}, | ||
32 | {field: 'money', title: __('Money'), operate:'BETWEEN'}, | 32 | {field: 'money', title: __('Money'), operate:'BETWEEN'}, |
33 | {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('Withdrawal'), 1: __('Recharge')}}, | 33 | {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('Withdrawal'), 1: __('Recharge')}}, |
34 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 34 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
@@ -15,7 +15,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -15,7 +15,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
15 | }); | 15 | }); |
16 | 16 | ||
17 | var table = $("#table"); | 17 | var table = $("#table"); |
18 | - | ||
19 | // 初始化表格 | 18 | // 初始化表格 |
20 | table.bootstrapTable({ | 19 | table.bootstrapTable({ |
21 | url: $.fn.bootstrapTable.defaults.extend.index_url, | 20 | url: $.fn.bootstrapTable.defaults.extend.index_url, |
@@ -31,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -31,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
31 | // {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('pre_list'), 1: __('purchase')}}, | 30 | // {field: 'type', title: __('Type'),formatter: Table.api.formatter.label,searchList: {0: __('pre_list'), 1: __('purchase')}}, |
32 | {field: 'score', title: __('Score')}, | 31 | {field: 'score', title: __('Score')}, |
33 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 32 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
34 | - // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 33 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} |
35 | ] | 34 | ] |
36 | ] | 35 | ] |
37 | }); | 36 | }); |
@@ -49,18 +48,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -49,18 +48,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
49 | bindevent: function () { | 48 | bindevent: function () { |
50 | Form.api.bindevent($("form[role=form]")); | 49 | Form.api.bindevent($("form[role=form]")); |
51 | } | 50 | } |
52 | - },queryParams: function (params) { | ||
53 | - // 自定义搜索条件 | ||
54 | - var filter = params.filter ? JSON.parse(params.filter) : {}; | ||
55 | - var op = params.op ? JSON.parse(params.op) : {}; | ||
56 | - //filter.后跟的是在ajax里使用的名称只需修改这两行 | ||
57 | - filter.uid = Config.ids; | ||
58 | - //opop后跟的也是ajax里使用的名称,后面是条件 | ||
59 | - op.uid = 'in'; | ||
60 | - params.filter = JSON.stringify(filter); | ||
61 | - params.op = JSON.stringify(op); | ||
62 | - // console.log(params); | ||
63 | - return params; | ||
64 | } | 51 | } |
65 | }; | 52 | }; |
66 | return Controller; | 53 | return Controller; |
@@ -39,7 +39,33 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -39,7 +39,33 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
39 | {field: 'u_user.address', title: __('s_address')}, | 39 | {field: 'u_user.address', title: __('s_address')}, |
40 | {field: 'status', title: __('status'), formatter: Table.api.formatter.flag,searchList: {'-1': __('cancel_pay'),0: __('to_pay'), 1: __('to_receive'),2: __('to_comment'), 3: __('finish')}}, | 40 | {field: 'status', title: __('status'), formatter: Table.api.formatter.flag,searchList: {'-1': __('cancel_pay'),0: __('to_pay'), 1: __('to_receive'),2: __('to_comment'), 3: __('finish')}}, |
41 | {field: 'createtime', title: __('createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 41 | {field: 'createtime', title: __('createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
42 | - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 42 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [ |
43 | + { | ||
44 | + name: 'ajax', | ||
45 | + text: __('完成'), | ||
46 | + title: __('完成'), | ||
47 | + classname: 'btn btn-xs btn-success btn-magic btn-ajax', | ||
48 | + icon: 'fa fa-magic', | ||
49 | + url: 'porder/finish', | ||
50 | + confirm: '确认完成', | ||
51 | + success: function (data, ret) { | ||
52 | + Layer.alert(ret.msg); | ||
53 | + //如果需要阻止成功提示,则必须使用return false; | ||
54 | + //return false; | ||
55 | + }, | ||
56 | + error: function (data, ret) { | ||
57 | + Layer.alert(ret.msg); | ||
58 | + return false; | ||
59 | + },visible: function (row) { | ||
60 | + if(row.status == 3){ | ||
61 | + return true; | ||
62 | + }else{ | ||
63 | + return false; | ||
64 | + } | ||
65 | + | ||
66 | + } | ||
67 | + } | ||
68 | + ]} | ||
43 | ] | 69 | ] |
44 | ] | 70 | ] |
45 | }); | 71 | }); |
@@ -44,7 +44,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -44,7 +44,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
44 | {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, | 44 | {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search}, |
45 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, | 45 | {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}}, |
46 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [ | 46 | {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [ |
47 | - {name: 'team', text: '我的团队', title: '我的团队', icon: 'fa fa-list', classname: 'btn btn-xs btn-success btn-dialog', url: 'off/line/index'} | 47 | + {name: 'log', text: '我的团队', title: '我的团队', icon: 'fa fa-list', classname: 'btn btn-xs btn-success btn-dialog', url: "off/line/index"} |
48 | ]} | 48 | ]} |
49 | ] | 49 | ] |
50 | ] | 50 | ] |
-
请 注册 或 登录 后发表评论