diff --git a/.gitignore b/.gitignore index 3fc276b..ff712e7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ yarn-error.log .idea .vscode/launch.json +/storage/debugbar \ No newline at end of file diff --git a/app/Admin/Common/Auth.php b/app/Admin/Common/Auth.php new file mode 100644 index 0000000..e085779 --- /dev/null +++ b/app/Admin/Common/Auth.php @@ -0,0 +1,61 @@ +>1.添加市场经理前,去查询是否已存在相同的帐号 + $count = $adu->where(['username' => $form->phone])->count(); + if ($count) { + $row->delete(); + return '-1'; + } + //>>2.添加市场经理登陆帐号 + $adu->username = $form->phone; + $adu->password = Hash::make(substr($form->phone, -5)); + $adu->name = $form->name; + $adu->status = $form->status; + $res = $adu->save(); + if (!$res) { + //删除刚添加数据 + $row->delete(); + return '-2'; + } + //>>3.将帐号id关联 + $row->admin_user_id = $adu->id; + $row->save(); + + //>>4.添加到admin roles中 + $lanzu_role = AdminRoles::where('slug', $roles)->first(); + $aru = new AdminRoleUsers(); + $aru->role_id = $lanzu_role->id; + $aru->user_id = $adu->id; + $aru->save(); + + //>>5.生成可提现金额信息 + LanzuUserBalance::create($adu->id, 3); + } +} diff --git a/app/Admin/Common/Images.php b/app/Admin/Common/Images.php new file mode 100644 index 0000000..e4e384a --- /dev/null +++ b/app/Admin/Common/Images.php @@ -0,0 +1,144 @@ +select('appid','appsecret') + ->where('uniacid', 2) + ->first(); + $appid=$row->appid; + $secret=$row->appsecret; + $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); + $data = curl_exec($ch); + curl_close($ch); + $data = json_decode($data,true); + return $data['access_token']; + } + + public function createQrCode($param,$path) + { + $access_token = $this->getWxToken(); + $data=array( + 'scene'=>$param, + "page"=>$path, + "width"=>100 + ); + $data = json_encode($data); + $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$access_token.""; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); + curl_setopt($ch, CURLOPT_POST,1); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data); + $data = curl_exec($ch); + curl_close($ch); + return $data; + + } + + /** + * 上传文件到oss + * @param $base64 //文件流 + * @param $fileName //文件名称 + * @return bool + */ + public function uploadOss($base64,$fileName) + { + return Storage::put($fileName,$base64); + } + + + public function test() + { + $wx_head = 'http://www.marketmanage.com/uploads/20200728/d5a491cd3d8d071e3212c3478e8e35a1.jpg'; + $avatar_file = file_get_contents($wx_head); + file_put_contents('./logo.jpg',$avatar_file); + $logo = $this->changeAvatar($avatar_file); + file_put_contents('./logo_new.jpg',$logo); + + + //$qr_code = $this->createQrCode('',''); + + + } + + + public function changeAvatar($avatar) + { + //处理用户头像为圆形icon + $avatar = imagecreatefromstring($avatar); + $w = imagesx($avatar)-5; + $h = imagesy($avatar)-5; + $w = min($w, $h); + $h = $w; + + $img = imagecreatetruecolor($w, $h); + imagesavealpha($img, true); + $bg = imagecolorallocatealpha($img, 255, 255, 255, 127); + imagefill($img, 0, 0, $bg); + + $r = $w / 2; //圆半径 + $y_x = $r; //圆心X坐标 + $y_y = $r; //圆心Y坐标 + for ($x = 0; $x < $w; $x++) { + for ($y = 0; $y < $h; $y++) { + $rgbColor = imagecolorat($avatar, $x, $y); + + if (((($x - $r) * ($x - $r) + ($y - $r) * ($y - $r)) < ($r * $r))) { + imagesetpixel($img, $x, $y, $rgbColor); + } + } + } + + ob_start(); + imagepng($img); + imagedestroy($img); + imagedestroy($avatar); + $contents = ob_get_contents(); //读取缓存区的内容 + ob_end_clean(); //清空缓存区 + return $contents; + } + + + public function makeOnePic($qr_code, $logo) //二维码与头像组合 + { + $qr_code = imagecreatefromstring($qr_code); //生成的二维码底色为白色 + //设置二维码为透明底 + imagesavealpha($qr_code, true); //这个设置一定要加上 + $bg = imagecolorallocatealpha($qr_code, 255, 255, 255, 127); //拾取一个完全透明的颜色,最后一个参数127为全透明 + imagefill($qr_code, 0, 0, $bg); + $icon = imagecreatefromstring($logo); //生成中间圆形logo (微信头像获取到的logo的大小为132px 132px) + + $qr_width = imagesx($qr_code); //二维码图片宽度 + $lg_width = imagesx($icon); //logo图片宽度 + $lg_height = imagesy($icon); //logo图片高度 + + $qr_lg_width = $qr_width / 2.2; + $scale = $lg_width / $qr_lg_width; + $qr_lg_height = $lg_height / $scale; + $start_width = ($qr_width - $lg_width) / 2 ; //(获取logo的左上方的位置:( 外部的正方形-logo的宽 ) / 2,我这边存在1px的偏差 我就给+2啦) + + imagecopyresampled($qr_code, $icon, $start_width, $start_width, 0, 0, $qr_lg_width, $qr_lg_height, $lg_width, $lg_height); + imagejpeg($qr_code,'./qrcode.png'); //保存 + + imagedestroy($qr_code); + imagedestroy($icon); + } +} diff --git a/app/Admin/Common/WxPay.php b/app/Admin/Common/WxPay.php new file mode 100644 index 0000000..ae1a395 --- /dev/null +++ b/app/Admin/Common/WxPay.php @@ -0,0 +1,45 @@ +transfer->toBalance([ + 'partner_trade_no' => $data['partner_trade_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号) + 'openid' => $data['openid'], + 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名 + 're_user_name' => $data['re_user_name'], // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名 + 'amount' => $data['amount'], // 企业付款金额,单位为分 + 'desc' => $data['desc'], // 企业付款操作说明信息。必填 + ]); + return $res; + } + + public static function pay($model,$form) + { + $data = []; + $user = ImsCjdcUser::find($model->user_id); + $data['openid'] = $user->openid; + $data['amount'] = $form->model()->money * 100; + $data['partner_trade_no'] = $form->model()->id; + $data['re_user_name'] = $model->name; + $data['desc'] = $model->name; + return self::transfers($data); + } +} diff --git a/app/Admin/Controllers/LanzuCsInfoController.php b/app/Admin/Controllers/LanzuCsInfoController.php new file mode 100644 index 0000000..9002423 --- /dev/null +++ b/app/Admin/Controllers/LanzuCsInfoController.php @@ -0,0 +1,131 @@ +isRole('lanzu_cs')) {//如何是社区站点角色登陆,则只能看到自己的信息 + $grid->model()->where('admin_user_id', $user->id); + $grid->disableDeleteButton(); + $grid->disableCreateButton(); + $grid->disableEditButton(); + } + $grid->id->sortable(); + $grid->name; + $grid->phone; + $grid->column('userBalance.balance', '可提现金额'); + $grid->column('qrcode_path', '二维码')->image('', 50, 50); + $grid->column('market_id', '所属市场')->display(function () { + return ImsCjdcMarket::find($this->market_id)->name; + }); + $grid->status('状态')->using(['禁用', '启用']); + $grid->address; + $grid->created_at->display(function ($time) { + return date('Y-m-d H:i', $time); + }); + $grid->disableViewButton(); + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id'); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new LanzuCsInfo(), function (Show $show) { + $show->id; + $show->name; + $show->phone; + $show->address; + $show->admin_user_id; + $show->status; + $show->created_at; + $show->updated_at; + }); + } + + /** + * Make a form builder. + * @return Form + */ + protected function form() + { + return Form::make(new LanzuCsInfo(), function (Form $form) { + $form->display('id'); + $form->text('name', '名称')->required(); + $form->text('user_id', '用户ID')->required(); + $form->mobile('phone')->required(); + $form->select('market_id', '所属市场')->options(ImsCjdcMarket::getMarket())->required(); + $form->text('address', '社区地址')->required(); + $form->radio('status', '状态')->options(['禁用', '启用'])->default(1); + //$form->datetime('start_time')->value('1598239137'); + $form->saved(function (Form $form, $cid) { + $model = new modelCsInfo(); + if ($form->isCreating()) { + //>>1.添加登录帐号 + $res = Auth::addAdminUser($form, $model, $cid, 'lanzu_cs'); + if ($res == -1) { + return $form->error('该手机号作为登陆帐号已存在!'); + } elseif ($res == -2) { + return $form->error('添加失败!'); + } + + //>>2.生成小程序二维码 + $cs = $model->find($cid); + $aid = $cs->admin_user_id; + $images = new Images(); + $param = "p=index&sid={$aid}"; + $path = 'zh_cjdianc/pages/Liar/loginindex'; + $qrcode = $images->createQrCode($param, $path); + $fileName = 'public/upload/' . 'qrcode' . '/' . date('Y') . '/' . date('m-d') . '/' . rand(100000000000000, 999999999999999) . '.png'; + $result = $images->uploadOss($qrcode, $fileName); + if ($result == true) { + //>>3.保存二维码路径 + $cs->qrcode_path = $fileName; + $cs->save(); + } + } else { + //>>4.编辑时同步登陆帐号状态 + $adu = new AdminUsers(); + $id = $form->getKey(); + $row = $model::find($id); + $ad = $adu->find($row->admin_user_id); + $ad->status = $form->status; + $ad->save(); + } + }); + }); + } +} diff --git a/app/Admin/Controllers/LanzuCsWithdrawController.php b/app/Admin/Controllers/LanzuCsWithdrawController.php new file mode 100644 index 0000000..5b9dd1d --- /dev/null +++ b/app/Admin/Controllers/LanzuCsWithdrawController.php @@ -0,0 +1,156 @@ +isRole('lanzu_cs')) {//如果不是社区站点的角色登陆,则隐藏提现入口 + $grid->disableCreateButton(); + $grid->actions(function (Grid\Displayers\Actions $actions) use ($grid) { + if ($actions->row->status != 0) {//状态一但改变,就不能编辑 + $actions->disableEdit(); + } + }); + } else { + $grid->disableEditButton(); + } + $grid->disableViewButton(); + $grid->disableDeleteButton(); + $grid->id->sortable(); + $grid->cs_id('提现用户')->display(function () { + return LanzuCsInfo::where('id', $this->cs_id)->first()->name; + }); + $grid->money; + $grid->status('状态')->using([1 => '已同意', -1 => '已拒绝', 0 => '待审核'])->label([1 => 'success', -1 => 'danger', 0 => 'default']); + $grid->is_pay('是否到账')->using(['否', '是']); + $grid->created_at; + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id'); + }); + + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new LanzuCsWithdraw(), function (Show $show) { + $show->id; + $show->cs_id('提现用户'); + $show->money; + $show->status('状态'); + $show->is_pay('是否到帐'); + $show->created_at; + $show->updated_at; + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new LanzuCsWithdraw('csInfo'), function (Form $form) { + $form->display('id'); + $user = Admin::user(); + + if ($form->isCreating()) {//如果是添加操作 + if ($user->isRole('lanzu_cs')) {//如果是社区站点角色 + $cs = LanzuCsInfo::where('admin_user_id', $user->id)->first(); + if ($cs) { + $form->text('amount', '可提现金额')->value(LanzuUserBalance::getBalance($cs->id, 3))->disable(); + $form->hidden('cs_id', '提现用户id')->value($cs->id); + $form->text('csInfo.name', '提现用户')->value($cs->name)->disable(); + $form->number('money')->min(0)->max(env('MAX_MONEY')); + $form->saving(function (Form $form) use ($user) { + //保存前校验提现金额是否符合申请条件 + if ($form->money < env('MIN_MONEY') || $form->money > env('MAX_MONEY')) { + return $form->error('申请提现金额不得小于 ' . env('MIN_MONEY') . ' 元 或 不得大于 ' . env('MAX_MONEY') . ' 元.'); + } + $res = LanzuUserBalance::checkBalance($user->id, $form->money); + if (!$res) { + return $form->error('您可提现金额不足!'); + } + }); + } + } + + $form->saved(function () use ($cs, $form) {//扣减提现金额 + LanzuUserBalance::reduceBalance($cs->admin_user_id, 3, $form->money); + }); + + } else {//编辑操作 + $form->display('amount', '可提现金额')->value(LanzuUserBalance::getBalance($form->model()->cs_id, 3)); + $form->display('cs_id', '提现用户')->value($form->model()->name); + $form->display('money'); + + if ($form->model()->status != 0) {//提现审核后 就能再编辑 + $form->radio('status', '状态')->options([1 => '同意', -1 => '拒绝'])->disable(); + } else { + $form->radio('status', '状态')->options([1 => '同意', -1 => '拒绝'])->default(-1); + } + + $form->saved(function () use ($form) { + if ($form->status == -1) {//如何审核被拒绝,退回提现金额 + LanzuUserBalance::returnBalance($form->model()->cs_id, 3, $form->model()->money); + } elseif ($form->status == 1) {//调用微信企业付 + //获取站点信息 + $csInfo = LanzuCsInfo::find($form->model()->cs_id); + $res = WxPay::pay($csInfo, $form); + if ($res['result_code'] == "SUCCESS") {//更新到账状态 + $csw = modelCsWithdraw::find($form->model()->id); + $csw->is_pay = 1; + $csw->save(); + + //添加流水记录 + $model = FinancialRecord::getFinancialRecordModel($csInfo->admin_user_id); + $model->user_id = $csInfo->admin_user_id; + $model->user_type = 4; + $model->money = $form->model()->money; + $model->money_type = 104; + $model->desc = '社区站点提现'; + $model->comment = '社区站点提现'; + $model->save(); + } else { + //记录失败日志 + Log::error('提现失败.', $res); + } + } + }); + + } + }); + } + +} diff --git a/app/Admin/Controllers/LanzuFinancialRecord.php b/app/Admin/Controllers/LanzuFinancialRecord.php new file mode 100644 index 0000000..109273f --- /dev/null +++ b/app/Admin/Controllers/LanzuFinancialRecord.php @@ -0,0 +1,39 @@ +id; + $grid->user_id('用户'); + $grid->money('金额'); + $grid->desc('说明'); + $grid->created_at('创建时间'); + $grid->filter(function (Grid\Filter $filter){ + $filter->equal('id'); + }); + $grid->disableViewButton(); + $grid->disableCreateButton(); + $grid->disableEditButton(); + $grid->disableDeleteButton(); + }); + } + + protected function form() + { + return Form::make(new FinancialRecord0(),function (Form $form){ + $form->datetime('created_at'); + }); + } +} diff --git a/app/Admin/Controllers/LanzuMpWithdrawController.php b/app/Admin/Controllers/LanzuMpWithdrawController.php index 4eaf9c9..d912933 100755 --- a/app/Admin/Controllers/LanzuMpWithdrawController.php +++ b/app/Admin/Controllers/LanzuMpWithdrawController.php @@ -99,7 +99,6 @@ class LanzuMpWithdrawController extends AdminController protected function lanzu_bis_form(){ //管理员或者lanzu_bis操作 return Form::make(new LanzuMpWithdraw(['mpInfo']), function (Form $form) { - $form->footer(function ($footer) { // 去掉`查看`checkbox $footer->disableViewCheck(); diff --git a/app/Admin/Controllers/LanzuServiceRewardController.php b/app/Admin/Controllers/LanzuServiceRewardController.php new file mode 100644 index 0000000..f0908ed --- /dev/null +++ b/app/Admin/Controllers/LanzuServiceRewardController.php @@ -0,0 +1,90 @@ +column('first_reward', '首单奖励')->display(function () { + return $this->set_reward['first_reward'] . ' 元'; + }); + $grid->column('new_user_reward', '站点奖励')->display(function () { + return $this->set_reward['new_user_reward'] . ' 元'; + }); + $grid->column('flow_reward', '流水奖励')->display(function () { + $f = $this->set_reward['flow_reward']; + return $f .= '%'; + }); + $grid->type->using([0 => '-', 1 => '社区']); + $grid->created_at; + $grid->updated_at; + $grid->disableViewButton(); + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id'); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new LanzuServiceReward(), function (Show $show) { + $show->field('first_reward', '首单奖励')->value($show->model()->set_reward['first_reward']); + $show->field('new_user_reward', '新用户奖励')->value($show->model()->set_reward['new _user_reward']); + $show->field('flow_reward', '流水奖励')->value($show->model()->set_reward['flow_reward']); + $show->field('type')->value('社区'); + $show->created_at; + $show->updated_at; + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new LanzuServiceReward(), function (Form $form) { + $form->display('id'); + $form->embeds('set_reward', '奖励配置', function ($form) { + $form->number('first_reward', '首单奖励(元)')->min(0); + $form->number('new_user_reward', '站点奖励(元)')->min(0); + $form->number('flow_reward', '流水奖励(%)'); + + }); + $form->radio('type')->options([1 => '社区'])->default(1); + $form->saved(function (Form $form) { + $ssdb = SsdbClient::client(env('SSDB_HOST'), env('SSDB_PORT')); + $data = [ + 'first_reward' => $form->set_reward['first_reward'], + 'new_user_reward' => $form->set_reward['new_user_reward'], + 'flow_reward' => $form->set_reward['flow_reward'], + ]; + $ssdb->multi_hset('set_reward_' . $form->type, $data); + }); + $form->disableViewButton(); + }); + } +} diff --git a/app/Admin/Repositories/LanzuCsInfo.php b/app/Admin/Repositories/LanzuCsInfo.php new file mode 100644 index 0000000..a27b31a --- /dev/null +++ b/app/Admin/Repositories/LanzuCsInfo.php @@ -0,0 +1,16 @@ +resource('/store', 'ImsCjdcStoreController'); $router->resource('/mp_withdraw', 'LanzuMpWithdrawController'); $router->resource('/mm_withdraw', 'LanzuMmWithdrawController'); + $router->resource('/cs', 'LanzuCsInfoController'); + $router->resource('/cs_withdraw', 'LanzuCsWithdrawController'); + $router->resource('/service_reward', 'LanzuServiceRewardController'); + $router->resource('/financial_record', 'LanzuFinancialRecord'); $router->any('/mm_list', 'LanzuMmWithdrawController@mmInfoList'); $router->any('/api/getMarket', 'LanzuMmInfoController@getMarket'); diff --git a/app/Libs/SsdbClient.php b/app/Libs/SsdbClient.php index 3af2677..ab9d6b7 100644 --- a/app/Libs/SsdbClient.php +++ b/app/Libs/SsdbClient.php @@ -7,23 +7,25 @@ class SsdbClient { public $SSDB; - public function __construct() - { - // $host = env('SSDB_HOST'); - // $port = env('SSDB_PORT'); + //public function __construct() + //{ + // $host = env('SSDB_HOST'); + // $port = env('SSDB_PORT'); + // + // try{ + // $SSDB = new SimpleSSDB($host, $port); + // $SSDB->auth(env('SSDB_AUTH')); + // }catch(\Exception $e){ + // dd($e); + // } + //} + - // try{ - // $SSDB = new SimpleSSDB($host, $port); - // $SSDB->auth(env('SSDB_AUTH')); - // }catch(\Exception $e){ - // dd($e); - // } - } - public function client() + public static function client($host=null,$port=null) { - $host = env('SSDB_HOST'); - $port = env('SSDB_PORT'); + $host = $host??env('SSDB_HOST'); + $port = $port??env('SSDB_PORT'); try{ $SSDB = new SimpleSSDB($host, $port); @@ -34,4 +36,4 @@ class SsdbClient return $SSDB; } -} \ No newline at end of file +} diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 9f2ca45..42c0da3 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -7,4 +7,5 @@ use Illuminate\Database\Eloquent\Model; class BaseModel extends Model { protected $dateFormat = 'U'; + } diff --git a/app/Models/FinancialRecord.php b/app/Models/FinancialRecord.php index 1357f5d..424b841 100644 --- a/app/Models/FinancialRecord.php +++ b/app/Models/FinancialRecord.php @@ -1,85 +1,25 @@ setTable($table_name); - $buider = $model; - //$buider = $buider::where('id',1); - // $buider = $buider::where('id',1); - default: - # code... - break; - } - - //if(empty($table)) $table = 'lanzu_financial_record_0'; - $this->setTable($table_name); - parent::__construct([]); - } - + use HasDateTimeFormatter; + protected $dateFormat = 'U'; + + /** + * 根据用户id创建不同模型 + * @param $user_id + * @return string + */ public static function getFinancialRecordModel($user_id){ $buider = null; $index = $user_id % 5; - - switch ($index) { - case 0: - case 1: - case 2: - case 3: - case 4: - dump($index); - $model_name = 'App\\Models\\'.'FinancialRecord'.$index; - $buider = $model_name; - default: - # code... - break; - } + $model_name = 'App\\Models\\'.'FinancialRecord'.$index; + $buider = new $model_name(); return $buider; } + } diff --git a/app/Models/FinancialRecord0.php b/app/Models/FinancialRecord0.php index b38cf3b..0f2dfd3 100644 --- a/app/Models/FinancialRecord0.php +++ b/app/Models/FinancialRecord0.php @@ -4,7 +4,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class FinancialRecord0 extends Model +class FinancialRecord0 extends FinancialRecord { protected $table = 'lanzu_financial_record_0'; + } diff --git a/app/Models/FinancialRecord1.php b/app/Models/FinancialRecord1.php index 4b5e9d2..4e656b3 100644 --- a/app/Models/FinancialRecord1.php +++ b/app/Models/FinancialRecord1.php @@ -4,7 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class FinancialRecord1 extends Model +class FinancialRecord1 extends FinancialRecord { protected $table = 'lanzu_financial_record_1'; } diff --git a/app/Models/FinancialRecord2.php b/app/Models/FinancialRecord2.php index 5aa3a43..85eefb7 100644 --- a/app/Models/FinancialRecord2.php +++ b/app/Models/FinancialRecord2.php @@ -4,7 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class FinancialRecord2 extends Model +class FinancialRecord2 extends FinancialRecord { protected $table = 'lanzu_financial_record_2'; } diff --git a/app/Models/FinancialRecord3.php b/app/Models/FinancialRecord3.php index 52c54fd..ca5218c 100644 --- a/app/Models/FinancialRecord3.php +++ b/app/Models/FinancialRecord3.php @@ -4,7 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class FinancialRecord3 extends Model +class FinancialRecord3 extends FinancialRecord { protected $table = 'lanzu_financial_record_3'; } diff --git a/app/Models/FinancialRecord4.php b/app/Models/FinancialRecord4.php index 2bb5cd3..25fb416 100644 --- a/app/Models/FinancialRecord4.php +++ b/app/Models/FinancialRecord4.php @@ -4,7 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class FinancialRecord4 extends Model +class FinancialRecord4 extends FinancialRecord { protected $table = 'lanzu_financial_record_4'; } diff --git a/app/Models/ImsCjdcMarket.php b/app/Models/ImsCjdcMarket.php index 3a5c050..8f441d5 100644 --- a/app/Models/ImsCjdcMarket.php +++ b/app/Models/ImsCjdcMarket.php @@ -29,5 +29,18 @@ class ImsCjdcMarket extends Model return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id'); } + /** + * 获取市场信息 + * @return \Illuminate\Http\JsonResponse + */ + public static function getMarket() + { + $markets = self::get(); + $item = []; + foreach ($markets as $market) { + $item[$market->id] = $market->name; + } + return $item; + } } diff --git a/app/Models/LanzuCsInfo.php b/app/Models/LanzuCsInfo.php new file mode 100644 index 0000000..a9b3f70 --- /dev/null +++ b/app/Models/LanzuCsInfo.php @@ -0,0 +1,26 @@ +hasOne("\App\Models\LanzuUserBalance",'source_id','admin_user_id'); + } + + public function csWithdraw() + { + return $this->hasOne("\App\Models\LanzuCsWithdraw",'cs_id','id'); + } + + +} diff --git a/app/Models/LanzuCsWithdraw.php b/app/Models/LanzuCsWithdraw.php new file mode 100644 index 0000000..086eb9b --- /dev/null +++ b/app/Models/LanzuCsWithdraw.php @@ -0,0 +1,30 @@ +hasOne("\App\Models\LanzuCsInfo",'id','cs_id'); + } + + + public function getCreatedAtAttribute($value) + { + return date('Y-m-d H:i',$value); + } + public function getUpdatedAtAttribute($value) + { + return date('Y-m-d H:i',$value); + } +} diff --git a/app/Models/LanzuServiceReward.php b/app/Models/LanzuServiceReward.php new file mode 100644 index 0000000..3d84d60 --- /dev/null +++ b/app/Models/LanzuServiceReward.php @@ -0,0 +1,27 @@ +'json' + ]; + + public function getCreatedAtAttribute($value) + { + return date('Y-m-d H:i',$value); + } + public function getUpdatedAtAttribute($value) + { + return date('Y-m-d H:i',$value); + } + +} diff --git a/app/Models/LanzuUserBalance.php b/app/Models/LanzuUserBalance.php new file mode 100644 index 0000000..d8e6950 --- /dev/null +++ b/app/Models/LanzuUserBalance.php @@ -0,0 +1,76 @@ + $uid, 'user_type' => $uType])->first(); + if ($row) { + return $row->balance; + } else { + return '0.00'; + } + } + + /** + * 扣减可提现金额 + */ + public static function reduceBalance($sid, $type, $reduceMoney) + { + $row = self::where(['source_id' => $sid, 'user_type' => $type])->first(); + if ($row) { + $row->balance = $row->balance - $reduceMoney; + return $row->save(); + } else { + return false; + } + } + + /** + * 回退审核未通过时的提现金额 + */ + public static function returnBalance($sid, $uType, $returnMoney) + { + $row = self::where(['source_id' => $sid, 'user_type' => $uType])->first(); + if ($row) { + $row->balance = $row->balance + $returnMoney; + return $row->save(); + } else { + return false; + } + } + + /** + * 生成一条数据 + */ + public static function create($aduid, $type) + { + $self = new self(); + $self->source_id = $aduid; + $self->user_type = $type; + $self->balance = 0; + $self->save(); + } + + /** + * 校验是否在足够的可提现金额 + */ + public static function checkBalance($aduid,$money) + { + return self::where('source_id',$aduid)->where('balance','>',$money)->count(); + } +} diff --git a/app/Models/MpBalance.php b/app/Models/MpBalance.php index 9154c33..784d1e1 100644 --- a/app/Models/MpBalance.php +++ b/app/Models/MpBalance.php @@ -8,7 +8,7 @@ use Illuminate\Database\Eloquent\Model; class MpBalance extends Model { - protected $table = 'lanzu_mp_balance'; + protected $table = 'lanzu_user_balance'; protected $dateFormat = 'U'; /** diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 7bc758f..b196c5b 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -67,6 +67,8 @@ namespace Dcat\Admin { * @property Grid\Column|Collection mp_id * @property Grid\Column|Collection is_pay * @property Grid\Column|Collection mm_id + * @property Grid\Column|Collection admin_user_id + * @property Grid\Column|Collection cs_id * @property Grid\Column|Collection activity * @property Grid\Column|Collection forward * @property Grid\Column|Collection repay @@ -1152,13 +1154,12 @@ namespace Dcat\Admin { * @property Grid\Column|Collection logo_url * @property Grid\Column|Collection success * @property Grid\Column|Collection error + * @property Grid\Column|Collection qrcode_path * @property Grid\Column|Collection user_type * @property Grid\Column|Collection money_type * @property Grid\Column|Collection source_type * @property Grid\Column|Collection comment - * @property Grid\Column|Collection admin_user_id * @property Grid\Column|Collection is_del - * @property Grid\Column|Collection balance * @property Grid\Column|Collection is_operated * @property Grid\Column|Collection c_attitude * @property Grid\Column|Collection c_service @@ -1168,8 +1169,10 @@ namespace Dcat\Admin { * @property Grid\Column|Collection user_created_at * @property Grid\Column|Collection qr_url * @property Grid\Column|Collection head_url + * @property Grid\Column|Collection set_reward * @property Grid\Column|Collection device_name * @property Grid\Column|Collection bind_time + * @property Grid\Column|Collection balance * @property Grid\Column|Collection bind_type * @property Grid\Column|Collection json_data * @property Grid\Column|Collection email_verified_at @@ -1230,6 +1233,8 @@ namespace Dcat\Admin { * @method Grid\Column|Collection mp_id(string $label = null) * @method Grid\Column|Collection is_pay(string $label = null) * @method Grid\Column|Collection mm_id(string $label = null) + * @method Grid\Column|Collection admin_user_id(string $label = null) + * @method Grid\Column|Collection cs_id(string $label = null) * @method Grid\Column|Collection activity(string $label = null) * @method Grid\Column|Collection forward(string $label = null) * @method Grid\Column|Collection repay(string $label = null) @@ -2315,13 +2320,12 @@ namespace Dcat\Admin { * @method Grid\Column|Collection logo_url(string $label = null) * @method Grid\Column|Collection success(string $label = null) * @method Grid\Column|Collection error(string $label = null) + * @method Grid\Column|Collection qrcode_path(string $label = null) * @method Grid\Column|Collection user_type(string $label = null) * @method Grid\Column|Collection money_type(string $label = null) * @method Grid\Column|Collection source_type(string $label = null) * @method Grid\Column|Collection comment(string $label = null) - * @method Grid\Column|Collection admin_user_id(string $label = null) * @method Grid\Column|Collection is_del(string $label = null) - * @method Grid\Column|Collection balance(string $label = null) * @method Grid\Column|Collection is_operated(string $label = null) * @method Grid\Column|Collection c_attitude(string $label = null) * @method Grid\Column|Collection c_service(string $label = null) @@ -2331,8 +2335,10 @@ namespace Dcat\Admin { * @method Grid\Column|Collection user_created_at(string $label = null) * @method Grid\Column|Collection qr_url(string $label = null) * @method Grid\Column|Collection head_url(string $label = null) + * @method Grid\Column|Collection set_reward(string $label = null) * @method Grid\Column|Collection device_name(string $label = null) * @method Grid\Column|Collection bind_time(string $label = null) + * @method Grid\Column|Collection balance(string $label = null) * @method Grid\Column|Collection bind_type(string $label = null) * @method Grid\Column|Collection json_data(string $label = null) * @method Grid\Column|Collection email_verified_at(string $label = null) @@ -2398,6 +2404,8 @@ namespace Dcat\Admin { * @property Show\Field|Collection mp_id * @property Show\Field|Collection is_pay * @property Show\Field|Collection mm_id + * @property Show\Field|Collection admin_user_id + * @property Show\Field|Collection cs_id * @property Show\Field|Collection activity * @property Show\Field|Collection forward * @property Show\Field|Collection repay @@ -3483,13 +3491,12 @@ namespace Dcat\Admin { * @property Show\Field|Collection logo_url * @property Show\Field|Collection success * @property Show\Field|Collection error + * @property Show\Field|Collection qrcode_path * @property Show\Field|Collection user_type * @property Show\Field|Collection money_type * @property Show\Field|Collection source_type * @property Show\Field|Collection comment - * @property Show\Field|Collection admin_user_id * @property Show\Field|Collection is_del - * @property Show\Field|Collection balance * @property Show\Field|Collection is_operated * @property Show\Field|Collection c_attitude * @property Show\Field|Collection c_service @@ -3499,8 +3506,10 @@ namespace Dcat\Admin { * @property Show\Field|Collection user_created_at * @property Show\Field|Collection qr_url * @property Show\Field|Collection head_url + * @property Show\Field|Collection set_reward * @property Show\Field|Collection device_name * @property Show\Field|Collection bind_time + * @property Show\Field|Collection balance * @property Show\Field|Collection bind_type * @property Show\Field|Collection json_data * @property Show\Field|Collection email_verified_at @@ -3561,6 +3570,8 @@ namespace Dcat\Admin { * @method Show\Field|Collection mp_id(string $label = null) * @method Show\Field|Collection is_pay(string $label = null) * @method Show\Field|Collection mm_id(string $label = null) + * @method Show\Field|Collection admin_user_id(string $label = null) + * @method Show\Field|Collection cs_id(string $label = null) * @method Show\Field|Collection activity(string $label = null) * @method Show\Field|Collection forward(string $label = null) * @method Show\Field|Collection repay(string $label = null) @@ -4646,13 +4657,12 @@ namespace Dcat\Admin { * @method Show\Field|Collection logo_url(string $label = null) * @method Show\Field|Collection success(string $label = null) * @method Show\Field|Collection error(string $label = null) + * @method Show\Field|Collection qrcode_path(string $label = null) * @method Show\Field|Collection user_type(string $label = null) * @method Show\Field|Collection money_type(string $label = null) * @method Show\Field|Collection source_type(string $label = null) * @method Show\Field|Collection comment(string $label = null) - * @method Show\Field|Collection admin_user_id(string $label = null) * @method Show\Field|Collection is_del(string $label = null) - * @method Show\Field|Collection balance(string $label = null) * @method Show\Field|Collection is_operated(string $label = null) * @method Show\Field|Collection c_attitude(string $label = null) * @method Show\Field|Collection c_service(string $label = null) @@ -4662,8 +4672,10 @@ namespace Dcat\Admin { * @method Show\Field|Collection user_created_at(string $label = null) * @method Show\Field|Collection qr_url(string $label = null) * @method Show\Field|Collection head_url(string $label = null) + * @method Show\Field|Collection set_reward(string $label = null) * @method Show\Field|Collection device_name(string $label = null) * @method Show\Field|Collection bind_time(string $label = null) + * @method Show\Field|Collection balance(string $label = null) * @method Show\Field|Collection bind_type(string $label = null) * @method Show\Field|Collection json_data(string $label = null) * @method Show\Field|Collection email_verified_at(string $label = null) diff --git a/resources/lang/zh-CN/lanzu-cs-info.php b/resources/lang/zh-CN/lanzu-cs-info.php new file mode 100644 index 0000000..54aa90f --- /dev/null +++ b/resources/lang/zh-CN/lanzu-cs-info.php @@ -0,0 +1,15 @@ + [ + 'LanzuCsInfo' => 'LanzuCsInfo', + ], + 'fields' => [ + 'name' => '名称', + 'phone' => '电话', + 'address' => '地址', + 'admin_user_id' => '系统登陆帐号', + 'status' => '状态 0/1/2 未审核/已审核', + ], + 'options' => [ + ], +]; diff --git a/resources/lang/zh-CN/lanzu-cs-withdraw.php b/resources/lang/zh-CN/lanzu-cs-withdraw.php new file mode 100644 index 0000000..3d44afe --- /dev/null +++ b/resources/lang/zh-CN/lanzu-cs-withdraw.php @@ -0,0 +1,14 @@ + [ + 'LanzuCsWithdraw' => 'LanzuCsWithdraw', + ], + 'fields' => [ + 'cs_id' => '关联的社区服务站id', + 'money' => '提现金额', + 'status' => '提现状态 0/1/-1 待审核/已同意/已拒绝', + 'is_pay' => '是否支付到账 0/1 否/是', + ], + 'options' => [ + ], +]; diff --git a/resources/lang/zh-CN/lanzu-service-reward.php b/resources/lang/zh-CN/lanzu-service-reward.php new file mode 100644 index 0000000..a81cf0a --- /dev/null +++ b/resources/lang/zh-CN/lanzu-service-reward.php @@ -0,0 +1,12 @@ + [ + 'LanzuServiceReward' => 'LanzuServiceReward', + ], + 'fields' => [ + 'set_reward' => '奖励配置', + 'type' => '类型', + ], + 'options' => [ + ], +];