正在显示
3 个修改的文件
包含
143 行增加
和
33 行删除
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | namespace app\admin\controller; | 3 | namespace app\admin\controller; |
4 | 4 | ||
5 | +use app\api\controller\Pay; | ||
5 | use app\common\controller\Backend; | 6 | use app\common\controller\Backend; |
6 | use think\Db; | 7 | use think\Db; |
7 | 8 | ||
@@ -71,6 +72,7 @@ class Iphone extends Backend | @@ -71,6 +72,7 @@ class Iphone extends Backend | ||
71 | $list = collection($list)->toArray(); | 72 | $list = collection($list)->toArray(); |
72 | foreach ($list as $k=>$v){ | 73 | foreach ($list as $k=>$v){ |
73 | $list[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('nickname'); | 74 | $list[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('nickname'); |
75 | + $list[$k]['user_phone'] = Db::name('user')->where('id',$v['user_id'])->value('mobile'); | ||
74 | } | 76 | } |
75 | $result = array("total" => $total, "rows" => $list); | 77 | $result = array("total" => $total, "rows" => $list); |
76 | 78 | ||
@@ -78,4 +80,111 @@ class Iphone extends Backend | @@ -78,4 +80,111 @@ class Iphone extends Backend | ||
78 | } | 80 | } |
79 | return $this->view->fetch(); | 81 | return $this->view->fetch(); |
80 | } | 82 | } |
83 | + | ||
84 | + /** | ||
85 | + * 编辑 | ||
86 | + */ | ||
87 | + public function edit($ids = null) | ||
88 | + { | ||
89 | + $row = $this->model->get($ids); | ||
90 | + if (!$row) { | ||
91 | + $this->error(__('No Results were found')); | ||
92 | + } | ||
93 | + $adminIds = $this->getDataLimitAdminIds(); | ||
94 | + if (is_array($adminIds)) { | ||
95 | + if (!in_array($row[$this->dataLimitField], $adminIds)) { | ||
96 | + $this->error(__('You have no permission')); | ||
97 | + } | ||
98 | + } | ||
99 | + if ($this->request->isPost()) { | ||
100 | + $params = $this->request->post("row/a"); | ||
101 | + if ($params) { | ||
102 | + $params = $this->preExcludeFields($params); | ||
103 | + | ||
104 | + | ||
105 | + //先查询一遍数据是否已经是支付状态 | ||
106 | + $data = Db::name('iphone')->where('id',$ids)->find(); | ||
107 | + | ||
108 | + //查询用户余额 | ||
109 | + $user_info = Db::name('user')->where('id',$data['user_id'])->find(); | ||
110 | + | ||
111 | + | ||
112 | + $result = false; | ||
113 | + Db::startTrans(); | ||
114 | + try { | ||
115 | + //是否采用模型验证 | ||
116 | + if ($this->modelValidate) { | ||
117 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
118 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | ||
119 | + $row->validateFailException(true)->validate($validate); | ||
120 | + } | ||
121 | + | ||
122 | + | ||
123 | + //未支付状态下才变更用户余额 | ||
124 | + if($data['status'] == 1){ | ||
125 | + if($params['status'] == 2){ | ||
126 | + //判断金额是否充足 | ||
127 | + if($user_info['money'] < $data['total']){ | ||
128 | + $this->error('您的余额不足,请充值后购买'); | ||
129 | + }else{ | ||
130 | + | ||
131 | + | ||
132 | + //用户购买的什么素材 | ||
133 | + if(empty($data['video_id'])){ | ||
134 | + $pic = Db::name('pic')->where('id',$data['pic_id'])->find(); | ||
135 | + | ||
136 | + //发送短信,通知客户 | ||
137 | + $mobile = $user_info['mobile']; | ||
138 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。图片标题:$pic[title],云盘地址:$pic[url]"; | ||
139 | + //发送短信 | ||
140 | + | ||
141 | + $send = new Pay(); | ||
142 | + $send->sms($mobile,$content); | ||
143 | + | ||
144 | + }elseif (empty($data['pic_id'])){ | ||
145 | + $video_id = unserialize($data['video_id']); | ||
146 | + $video = Db::name('video')->where('id',$video_id['id'])->find(); | ||
147 | + //发送短信,通知客户 | ||
148 | + $mobile = $user_info['mobile']; | ||
149 | + if($video_id['attr'] == 1){ | ||
150 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[two_url]"; | ||
151 | + }elseif ($video_id['attr'] == 2){ | ||
152 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[four_url]"; | ||
153 | + }elseif ($video_id['attr'] == 3){ | ||
154 | + $content = "【仁甲看见SHOP】,感谢您购买仁甲看见SHOP素材。视频标题:$video[title],云盘地址:$video[eight_url]"; | ||
155 | + } | ||
156 | + //发送短信 | ||
157 | + $send = new Pay(); | ||
158 | + $send->sms($mobile,$content); | ||
159 | + } | ||
160 | + $update = $user_info['money'] - $data['total']; | ||
161 | + Db::name('user')->where('id',$user_info['id'])->update(['money'=>$update]); | ||
162 | + } | ||
163 | + } | ||
164 | + } | ||
165 | + | ||
166 | + | ||
167 | + $result = $row->allowField(true)->save($params); | ||
168 | + Db::commit(); | ||
169 | + } catch (ValidateException $e) { | ||
170 | + Db::rollback(); | ||
171 | + $this->error($e->getMessage()); | ||
172 | + } catch (PDOException $e) { | ||
173 | + Db::rollback(); | ||
174 | + $this->error($e->getMessage()); | ||
175 | + } catch (Exception $e) { | ||
176 | + Db::rollback(); | ||
177 | + $this->error($e->getMessage()); | ||
178 | + } | ||
179 | + if ($result !== false) { | ||
180 | + $this->success(); | ||
181 | + } else { | ||
182 | + $this->error(__('No rows were updated')); | ||
183 | + } | ||
184 | + } | ||
185 | + $this->error(__('Parameter %s can not be empty', '')); | ||
186 | + } | ||
187 | + $this->view->assign("row", $row); | ||
188 | + return $this->view->fetch(); | ||
189 | + } | ||
81 | } | 190 | } |
1 | <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | 1 | <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> |
2 | 2 | ||
3 | + <!--<div class="form-group">--> | ||
4 | + <!--<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>--> | ||
5 | + <!--<div class="col-xs-12 col-sm-8">--> | ||
6 | + <!--<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">--> | ||
7 | + <!--</div>--> | ||
8 | + <!--</div>--> | ||
9 | + <!--<div class="form-group">--> | ||
10 | + <!--<label class="control-label col-xs-12 col-sm-2">{:__('Pic_id')}:</label>--> | ||
11 | + <!--<div class="col-xs-12 col-sm-8">--> | ||
12 | + <!--<input id="c-pic_id" data-rule="required" data-source="pic/index" class="form-control selectpage" name="row[pic_id]" type="text" value="{$row.pic_id|htmlentities}">--> | ||
13 | + <!--</div>--> | ||
14 | + <!--</div>--> | ||
15 | + <!--<div class="form-group">--> | ||
16 | + <!--<label class="control-label col-xs-12 col-sm-2">{:__('Video_id')}:</label>--> | ||
17 | + <!--<div class="col-xs-12 col-sm-8">--> | ||
18 | + <!--<input id="c-video_id" data-rule="required" data-source="video/index" class="form-control selectpage" name="row[video_id]" type="text" value="{$row.video_id|htmlentities}">--> | ||
19 | + <!--</div>--> | ||
20 | + <!--</div>--> | ||
21 | + <!--<div class="form-group">--> | ||
22 | + <!--<label class="control-label col-xs-12 col-sm-2">{:__('Total')}:</label>--> | ||
23 | + <!--<div class="col-xs-12 col-sm-8">--> | ||
24 | + <!--<input id="c-total" class="form-control" step="0.01" name="row[total]" type="number" value="{$row.total|htmlentities}">--> | ||
25 | + <!--</div>--> | ||
26 | + <!--</div>--> | ||
3 | <div class="form-group"> | 27 | <div class="form-group"> |
4 | - <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label> | 28 | + <label class="control-label col-xs-12 col-sm-2">{:__('支付状态')}:</label> |
5 | <div class="col-xs-12 col-sm-8"> | 29 | <div class="col-xs-12 col-sm-8"> |
6 | - <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}"> | ||
7 | - </div> | ||
8 | - </div> | ||
9 | - <div class="form-group"> | ||
10 | - <label class="control-label col-xs-12 col-sm-2">{:__('Pic_id')}:</label> | ||
11 | - <div class="col-xs-12 col-sm-8"> | ||
12 | - <input id="c-pic_id" data-rule="required" data-source="pic/index" class="form-control selectpage" name="row[pic_id]" type="text" value="{$row.pic_id|htmlentities}"> | ||
13 | - </div> | ||
14 | - </div> | ||
15 | - <div class="form-group"> | ||
16 | - <label class="control-label col-xs-12 col-sm-2">{:__('Video_id')}:</label> | ||
17 | - <div class="col-xs-12 col-sm-8"> | ||
18 | - <input id="c-video_id" data-rule="required" data-source="video/index" class="form-control selectpage" name="row[video_id]" type="text" value="{$row.video_id|htmlentities}"> | ||
19 | - </div> | ||
20 | - </div> | ||
21 | - <div class="form-group"> | ||
22 | - <label class="control-label col-xs-12 col-sm-2">{:__('Total')}:</label> | ||
23 | - <div class="col-xs-12 col-sm-8"> | ||
24 | - <input id="c-total" class="form-control" step="0.01" name="row[total]" type="number" value="{$row.total|htmlentities}"> | ||
25 | - </div> | ||
26 | - </div> | ||
27 | - <div class="form-group"> | ||
28 | - <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | ||
29 | - <div class="col-xs-12 col-sm-8"> | ||
30 | - <input id="c-status" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}"> | ||
31 | - </div> | ||
32 | - </div> | ||
33 | - <div class="form-group"> | ||
34 | - <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label> | ||
35 | - <div class="col-xs-12 col-sm-8"> | ||
36 | - <input id="c-num" class="form-control" name="row[num]" type="text" value="{$row.num|htmlentities}"> | 30 | + {:build_radios('row[status]', ['1'=>'待支付', '2'=>'已支付'],$row.status)} |
37 | </div> | 31 | </div> |
38 | </div> | 32 | </div> |
33 | + <!--<div class="form-group">--> | ||
34 | + <!--<label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>--> | ||
35 | + <!--<div class="col-xs-12 col-sm-8">--> | ||
36 | + <!--<input id="c-num" class="form-control" name="row[num]" type="text" value="{$row.num|htmlentities}">--> | ||
37 | + <!--</div>--> | ||
38 | + <!--</div>--> | ||
39 | <div class="form-group layer-footer"> | 39 | <div class="form-group layer-footer"> |
40 | <label class="control-label col-xs-12 col-sm-2"></label> | 40 | <label class="control-label col-xs-12 col-sm-2"></label> |
41 | <div class="col-xs-12 col-sm-8"> | 41 | <div class="col-xs-12 col-sm-8"> |
@@ -26,10 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -26,10 +26,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
26 | {checkbox: true}, | 26 | {checkbox: true}, |
27 | {field: 'id', title: __('Id')}, | 27 | {field: 'id', title: __('Id')}, |
28 | {field: 'user_id', title: __('用户昵称')}, | 28 | {field: 'user_id', title: __('用户昵称')}, |
29 | + {field: 'user_phone', title: __('用户手机号')}, | ||
29 | {field: 'pic.title', title: __('Pic.title'), operate:'like'}, | 30 | {field: 'pic.title', title: __('Pic.title'), operate:'like'}, |
30 | {field: 'video.title', title: __('Video.title'), operate:'like'}, | 31 | {field: 'video.title', title: __('Video.title'), operate:'like'}, |
31 | {field: 'total', title: __('Total'), operate:'BETWEEN'}, | 32 | {field: 'total', title: __('Total'), operate:'BETWEEN'}, |
32 | - {field: 'status', title: __('Status')}, | 33 | + {field: 'status', title: __('支付状态'),searchList: {"1":"待支付","2":'已支付'},formatter: Table.api.formatter.status}, |
33 | {field: 'num', title: __('Num')}, | 34 | {field: 'num', title: __('Num')}, |
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: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, | 36 | // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, |
-
请 注册 或 登录 后发表评论