| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace app\api\controller\v1;
- use app\agent\model\auth\Permission;
- use app\api\controller\ApiController;
- use app\api\model\user\MotorAgent;
- use app\common\model\China;
- use think\Exception;
- class Common extends ApiController
- {
- /**
- * @desc 摩的代理电话
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @author weichuanbao<654745815@qq.com>
- * @date 2021/12/22 0022
- */
- public function motorAgentPhone()
- {
- $params = input();
- $China = new China();
- $MotorAgent = new MotorAgent();
- $area = $China->field('id,name')
- ->where('name', $params['district'])
- ->find();
- if (!$area) {
- return $this->ApiJson(-1,'失败');
- }
- $row = $MotorAgent->field('id,mobile')
- ->where('area_id', $area['id'])
- ->find();
- if ($row) {
- return $this->ApiJson(0,'成功', $row);
- }
- return $this->ApiJson(-1,'失败');
- }
- public function demo()
- {
- $Permission = new Permission();
- $list = $Permission->whereNotLike('url', '#%')
- ->where('url', '<>', 'javascript:;')
- ->where('type', 1)
- ->selectOrFail();
- $result = false;
- $Permission->startTrans();
- try {
- $data = [];
- foreach ($list as $item) {
- if (strstr($item['url'], '/agent')) {
- $item->url = str_replace('/agent', '', $item['url']);
- $loop = $item->getChangedData();
- $loop['id'] = $item['id'];
- $data[] = $loop;
- }
- }
- // p($data, 1);
- $result = $Permission->allowField(true)->saveAll($data);
- // $Permission->commit();
- }
- catch(Exception $e) {
- $Permission->rollback();
- }
- if ($result) {
- return $this->ApiJson(0,'成功');
- }
- return $this->ApiJson(-1,'失败');
- }
- }
|