Ver código fonte

登录+语言包

lizhen_gitee 1 ano atrás
pai
commit
b82c99ad60

+ 1 - 1
application/api/controller/company/User.php

@@ -15,7 +15,7 @@ use think\Db;
  */
 class User extends Apic
 {
-    protected $noNeedLogin = ['mobilelogin'];
+    protected $noNeedLogin = ['mobilelogin','accountlogin'];
     protected $noNeedRight = '*';
 
     public function _initialize()

+ 3 - 0
application/api/lang/zh-cn/company/common.php

@@ -0,0 +1,3 @@
+<?php
+
+return [];

+ 39 - 0
application/api/lang/zh-cn/company/user.php

@@ -0,0 +1,39 @@
+<?php
+
+return [
+    'User center'                           => '会员中心',
+    'Register'                              => '注册',
+    'Login'                                 => '登录',
+    'Sign up successful'                    => '注册成功',
+    'Username can not be empty'             => '用户名不能为空',
+    'Username must be 3 to 30 characters'   => '用户名必须3-30个字符',
+    'Username must be 6 to 30 characters'   => '用户名必须6-30个字符',
+    'Password can not be empty'             => '密码不能为空',
+    'Password must be 6 to 30 characters'   => '密码必须6-30个字符',
+    'Mobile is incorrect'                   => '手机格式不正确',
+    'Username already exist'                => '用户名已经存在',
+    'Nickname already exist'                => '昵称已经存在',
+    'Email already exist'                   => '邮箱已经存在',
+    'Mobile already exist'                  => '手机号已经存在',
+    'Username is incorrect'                 => '用户名不正确',
+    'Email is incorrect'                    => '邮箱不正确',
+    'Account is locked'                     => '账户已经被锁定',
+    'Password is incorrect'                 => '密码不正确',
+    'Account is incorrect'                  => '账户不正确',
+    'Account not exist'                     => '账户不存在',
+    'Account can not be empty'              => '账户不能为空',
+    'Username or password is incorrect'     => '用户名或密码不正确',
+    'You are not logged in'                 => '你当前还未登录',
+    'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
+    'Profile'                               => '个人资料',
+    'Verify email'                          => '邮箱验证',
+    'Change password'                       => '修改密码',
+    'Captcha is incorrect'                  => '验证码不正确',
+    'Logged in successful'                  => '登录成功',
+    'Logout successful'                     => '退出成功',
+    'Operation failed'                      => '操作失败',
+    'Invalid parameters'                    => '参数不正确',
+    'Change password failure'               => '修改密码失败',
+    'Change password successful'            => '修改密码成功',
+    'Reset password successful'             => '重置密码成功',
+];

+ 1 - 1
application/common/library/Authcompany.php

@@ -27,7 +27,7 @@ class Authcompany
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'name', 'mobile','address', 'image', 'status','longitude','latitude','bank_name','bank_branchname','bank_account','bank_card','company_name','company_image'];
+    protected $allowFields = ['id', 'name', 'logo','image','contacts', 'mobile','province_name','city_name','area_name','province_id','city_id','area_id','address','full_address','longitude','latitude','aptitude_images','open_hours','staff'];
 
 
     public function __construct($options = [])

+ 168 - 0
application/common/model/Walletcompany.php

@@ -0,0 +1,168 @@
+<?php
+namespace app\common\model;
+use think\Model;
+use think\Db;
+/**
+ * 货币模型
+ */
+class Walletcompany extends Model
+{
+    /**
+     * 获取交易类型配置
+     * @return mixed
+     */
+    public function getlogtype($type = '')
+    {
+        $conf = config('wallet.logtype');
+        if($type){
+            return $conf[$type] ?: $type;
+        }
+        return $conf;
+    }
+
+    //获取钱包名称
+    public function getwalletname($name = ''){
+        $conf = config('wallet.moneyname');
+        if($name){
+            return $conf[$name] ?: $name;
+        }
+        return $conf;
+    }
+
+    /**
+     * 获取钱包余额
+     * @param string $username 用户编号
+     * @param string $wallet_name 指定钱包名
+     * @return array|float
+     */
+    public function getWallet($user_id = '', $wallet_name = '')
+    {
+        //所有钱包余额
+        $wallet = Db::name('company_wallet')->lock(true)->where(['user_id' => $user_id])->find();
+        if(!$wallet) {
+            abort(500,'钱包余额获取失败');
+        }
+
+        if($wallet_name) { //返回指定钱包
+            return isset($wallet[$wallet_name]) ? $wallet[$wallet_name] : 0;
+        } else { //返回所有钱包
+            return $wallet;
+        }
+    }
+
+
+    /**
+     *
+     * @param floatval $number 金额(正数进账,负数出账)
+     * @param $accountType 货币类型,money,score
+     * @param $logtype 日志的类型
+     * @param $remark  备注
+     * @param $user_id  用户id
+     * @param $table  来源表
+     * @param $data_id  表id
+     * @param $isAdmin 是否是管理员处理
+     * @return array
+     * @return array[status]
+     * @return array[msg]
+     * @return array[log_table]
+     * @return array[log_id]
+     */
+    public function lockChangeAccountRemain($user_id,$accountType='money',$number,$logtype='',$remark='',$table='',$table_id=0,$isAdmin=false)
+    {
+        //初始化
+        $result = array(
+            'status'=>false,
+            'code' => 0, //报错时候采用
+            'msg'=>'',
+            'log_table' => '',
+            'log_id' => '',
+        );
+
+        //获取小数点
+        $point = $accountType == 'money' ? 2 : 0;
+        bcscale($point);
+
+        //钱包名称
+        $wallet_name = $this->getwalletname($accountType);
+
+        //检测
+        $number = floatval( $number );
+        if( $number == 0 )
+        {
+            $result['msg'] = '交易金额:0';
+            return $result;
+        }
+        if(0 === bccomp($number, 0)){
+            $result['msg'] = '交易金额:0';
+            return $result;
+        }
+
+
+        //检测
+        $wallet = Db::name('company_wallet')->lock(true)->where(['user_id'=>$user_id])->find();
+        if(!$wallet)
+        {
+            $result['msg'] = '不存在的用户';
+            return $result;
+        }
+
+        if(bccomp(bcadd($wallet[$accountType], $number), 0) === -1)
+        {
+            $result['code'] = 10;
+            $result['msg'] = $wallet_name.'余额不足!';
+            return $result;
+        }
+
+        if(0 !== bccomp($number, 0))
+        {
+
+            //钱币记录
+            $data = array();
+            $data['user_id'] = $user_id;
+            $data['log_type'] = $logtype;
+            $data['before'] = $wallet[$accountType];
+            $data['change_value'] = $number;
+            $data['remain'] = bcadd($wallet[$accountType], $number);
+            $data['table'] = $table;
+            $data['table_id'] = $table_id;
+            $data['remark'] = $remark;
+            $data['createtime'] = time();
+            $data['updatetime'] = time();
+
+            //新的方式
+            $rs1 = Db::name('company_wallet')->where(['user_id'=>$user_id])->update([$accountType => $data['remain']]);
+
+            /////////////
+            $log_table = 'company_'.$accountType.'_log';
+
+            $rs2_id = Db::name($log_table)->insertGetId($data);
+
+            if($rs1 === false || $rs2_id === false){
+                $result['msg'] = '更新财务记录失败!';
+                return $result;
+            }
+
+            if( $rs1 !== false && $rs2_id !== false )
+            {
+                $result['status'] = true;
+                $result['msg'] = '账户余额已更新!';
+                $result['log_table'] = $accountType.'_log';
+                $result['log_id'] = $rs2_id;
+
+                return $result;
+            }
+            else
+            {
+                $result['msg'] = '更新财务记录失败!';
+                return $result;
+            }
+        } else {
+            $result['msg'] = '金额不足0.01';
+            return $result;
+        }
+
+    }
+
+
+
+}