* @day: 2017/11/11 */ namespace app\admin\controller\user; use app\admin\controller\AuthController; use crmeb\repositories\OrderRepository; use crmeb\repositories\ShortLetterRepositories; use crmeb\services\{ExpressService, JsonService, JsonService as Json, MiniProgramService, WechatService, FormBuilder as Form, CacheService, UtilService as Util}; use app\admin\model\ump\StorePink; use crmeb\basic\BaseModel; use think\facade\Route as Url; use crmeb\services\YLYService; use think\facade\Log; use think\facade\Validate; /** * 订单管理控制器 同一个订单表放在一个控制器 * Class StoreOrder * @package app\admin\controller\store */ class UserEnter extends AuthController { /** * @return mixed */ public function index() { return $this->fetch(); } public function list() { $where = Util::getMore([ ['status', ''], ['page', 1], ['limit', 20], ['stage', ''], ['order_id', ''], ['excel', 0], ['data', ''], ['many_id',''], ['name', ''] ]); return Json::successlayui(\app\admin\model\user\UserEnter::list($where)); } /** * 删除 * @param $id * @return void * @throws \Exception */ public function delete($id) { if (!$id) Json::fail('删除失败'); $model = new \app\admin\model\user\UserEnter(); $res = $model->where('id', $id)->delete(); if ($res){ return Json::success('删除成功!'); }else{ return Json::fail($model->getErrorInfo()); } } /** * 审核通过 * @param $id * @return void */ public function tg($id) { if (!$id) Json::fail('通过失败'); $model = new \app\admin\model\user\UserEnter(); $details = $model->find($id); $details['status'] = 1; $res1 = \app\models\user\User::where('uid', $details['uid'])->update(['is_merchant' => 1]); $res2 = $details->save(); if ($res1 && $res2){ return Json::success('成功!'); }else{ return Json::fail($model->getErrorInfo()); } } /** * 拒绝 * @param $id * @return string * @throws \Exception */ public function jj($id) { $f = []; $f[] = Form::textarea('fail_message', '不通过理由'); $f[] = Form::hidden('id', $id); $form = Form::make_post_form('添加', $f, Url::buildUrl('jj_save')); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 不通过理由 * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function jj_save() { $data = Util::postMore([ ['id', ''], ['fail_message', ''] ]); if (empty($data['fail_message'])) return Json::fail('填写拒绝理由'); if (empty($data['id'])) return Json::fail('数据不存在'); $details = \app\admin\model\user\UserEnter::find($data['id']); $details['fail_message'] = $data['fail_message']; $details['status'] = -1; if ($details->save()){ return Json::success('成功!'); }else{ return Json::fail('失败'); } } }