afa 10 сар өмнө
parent
commit
14fa672277

+ 5 - 5
application/api/controller/Home.php

@@ -35,15 +35,15 @@ class Home extends Api
     public function base(AnnouncementModel $announcement, ProductsModel $productsModel)
     {
         $resp = [
-            'system_name' => '茶付宝',
+            'system_name' => __("System name"), 
             'banner_list' => [],
             'notice_list' => []
         ];
         // banner
         $resp['banner_list'] = $announcement
             ->field('id,'.$this->lan.'_title,img_url,createtime')
-            ->where('type_id', 2)
-            ->where('status', 1)
+            ->where('type_id', $announcement::Banner)
+            ->where('status', $announcement::NORMAL)
             ->limit(0,10)
             ->order('id DESC,weigh desc')
             ->select();
@@ -51,8 +51,8 @@ class Home extends Api
         // 最新公告
         $resp['notice_list'] = $announcement
             ->field('id,'.$this->lan.'_title,img_url,createtime')
-            ->where('type_id', 1)
-            ->where('status', 1)
+            ->where('type_id', $announcement::Announ)
+            ->where('status', $announcement::NORMAL)
             ->limit(0,10)
             ->order('id DESC,weigh desc')
             ->select();

+ 3 - 3
application/api/controller/Ledger.php

@@ -29,7 +29,7 @@ class Ledger extends Api
     public function assets()
     {
         
-        $chabao = LedgerWalletModel::getWalletChaBao(1008);
+        $chabao = LedgerWalletModel::getWalletChaBao($this->auth->id);
         $res['assets']       = $chabao;
         $res['chabao_rate']  = getConfig('chabao_rate'); //茶宝汇率
         $res['withdrawal_fee']= getConfig('withdrawal_fee'); //提现收费
@@ -85,7 +85,7 @@ class Ledger extends Api
                 $paginator = (new LedgerQubicChangeModel());
                 break;
             default:
-                $this->error("参数有误");
+                $this->error(__('Invalid parameters'));
                 break;
         }
 
@@ -166,7 +166,7 @@ class Ledger extends Api
                 ];
                 break;
             default:
-                $this->error('资产类型错误');
+                $this->error(__('Invalid parameters'));
                 break;
         }
         $this->success('', $resp);

+ 5 - 5
application/api/controller/Member.php

@@ -90,7 +90,7 @@ class Member extends Api
         $inviteCode = $this->request->post('inviteCode'); // 邀请码
         $sign = 'register';
         if (empty($address) || empty($sign)) {
-            $this->error('参数错误');
+            $this->error(__('Invalid parameters'));
         }
         $address    = strtolower($address); // 转小写
         $inviteCode = strtolower($inviteCode); // 转小写
@@ -106,13 +106,13 @@ class Member extends Api
             // 尝试绑定上级
             if (empty($user['parent_id'])) { // 未绑定时
                 if (empty($inviteCode)) {
-                    $msg = '请先绑定上级';
+                    $msg = __('Please bind your superior first');
                 } else if ($inviteCode == $address) {
-                    $msg = '推荐人不能为自己,请重新绑定上级';
+                    $msg = __('The recommender cannot be yourself please re-bind to your superior');
                 } else {
                     $parent = (new UserModel())->getByAddress($inviteCode);
                     if (empty($parent)) { // 邀请码有效时
-                        $msg = '邀请码无效,请手动绑定上级';
+                        $msg = __('The invitation code is invalid, please manually bind your superior');
                     } else {
                         $this->insertOrUpdateData($address, $parent['id']);
                         $user = (new UserModel())->getByAddress($address);
@@ -120,7 +120,7 @@ class Member extends Api
                 }
             }
             if($user['is_login']){
-                throw new Exception('您的账号被锁定,请联系客服。');
+                throw new Exception(__('Your account has been locked please contact customer service'));
             }
             Token::marshal($user['id'], $user['address']);
             $user['token'] = Token::getEncryptedToken($user['id']);

+ 7 - 13
application/api/controller/Offline.php

@@ -48,17 +48,16 @@ class Offline extends Api
         $sign = $this->request->post('sign'); // 签名信
         $address = $this->request->post('to_address'); // 地址
         if(empty($sign)  || empty($address)){
-            $this->error('参数错误');
+            $this->error(__('Invalid parameters'));
         }
         $real   = bcdiv($amount, getConfig('convert_rate'), 6); // 折合转换 U = 1
         $min    = getConfig('withdraw_min_amount');
         $rate   = getConfig('withdrawal_fee');
         if ($amount <= 0) {
-            $this->error('提现金额必须大于0');
+            $this->error(__('The withdrawal amount must be greater than 0'));
         } else if ($amount < $min) {
-            $this->error('提现金额不能小于' . $min);
+            $this->error(__('The withdrawal amount cannot be less than') . $min);
         }
-        
         // 扣除手续费后
         if ($rate > 0 && $rate < 1) { // 比例范围只在0-1之间
             $real = bcmul($real, bcsub(1, $rate, 6), 6);
@@ -67,20 +66,15 @@ class Offline extends Api
 
         // 用户信息
         $user = (new UserModel())->getById($uid);
-        if (empty($user)) {
-            $this->error('用户不存在');
-        }
-
         if($user['is_withdraw']){
-            $this->error('提现失败,请联系客服。');
+            $this->error(__('Withdrawal failed, please contact customer service.'));
         }
 
         // 验签
         $signMsg = "withdraw"; // 与前端约定的固定值
         if (!checkSign($signMsg, $sign, $address)) {
-            $this->error('签名校验失败');
+            $this->error(__('Signature verification failed'));
         }
-
         // 启动事务
         Db::startTrans();
         try {
@@ -96,10 +90,10 @@ class Offline extends Api
         } catch (Exception $e) {
             // 回滚事务
             Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
+            $this->error( $e->getMessage());
         }
 
-        $this->success('提现申请已提交');
+        $this->success('ok');
     }
 
     /**

+ 9 - 9
application/api/controller/Order.php

@@ -70,7 +70,7 @@ class Order extends Api
             Db::rollback();
             $this->error( $e->getMessage());
         }
-        $this->success('订单创建成功');
+        $this->success('ok');
     }
 
     
@@ -104,7 +104,7 @@ class Order extends Api
             Db::rollback();
             $this->error( $e->getMessage());
         }
-        $this->success('订单创建成功');
+        $this->success('ok');
     }
 
 
@@ -144,7 +144,7 @@ class Order extends Api
             Db::rollback();
             $this->error('提交失败:' . $e->getMessage());
         }
-        $this->success('订单创建成功');
+        $this->success('ok');
     }
 
     /**
@@ -195,7 +195,7 @@ class Order extends Api
             Db::rollback();
             $this->error($e->getMessage());
         }
-        $this->success('订单创建成功');
+        $this->success('ok');
     }
 
     //取消转让 
@@ -222,7 +222,7 @@ class Order extends Api
             Db::rollback();
             $this->error( $e->getMessage());
         }
-        $this->success('订单创建成功');
+        $this->success('ok');
     }
 
 
@@ -235,8 +235,8 @@ class Order extends Api
        
         $amount    = $this->request->post('amount'); // 支付金额
         $tx_hash   = $this->request->post('tx_hash'); // 交易hash
-        if (empty($amount)) $this->error('交易金额不能为空');
-        if (empty($tx_hash)) $this->error('交易Hash不能为空');
+        if (empty($amount)) $this->error(__('交易金额不能为空'));
+        if (empty($tx_hash)) $this->error(__('交易Hash不能为空'));
         
         //用户id、用户地址、hash、金额、状态、时间  address
         Db::startTrans();
@@ -255,9 +255,9 @@ class Order extends Api
         } catch (Exception $e) {
             // 回滚事务
             Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
+            $this->error( $e->getMessage());
         }
-        $this->success('订单支付成功');
+        $this->success('ok');
 
     }
 }

+ 13 - 0
application/api/lang/en.php

@@ -0,0 +1,13 @@
+<?php
+
+return [
+    'Invalid parameters'                             => 'Invalid parameters',
+    'Please bind your superior first'                => 'Please bind your superior first',
+    'The recommender cannot be yourself please re-bind to your superior'         => 'The recommender cannot be yourself please re-bind to your superior',
+    'The invitation code is invalid, please manually bind your superior'         => 'he invitation code is invalid, please manually bind your superior',
+    'Your account has been locked please contact customer service'               => 'Your account has been locked please contact customer service。',
+    'The withdrawal amount must be greater than 0'                               => 'The withdrawal amount must be greater than 0',
+    'The withdrawal amount cannot be less than'                                  => 'The withdrawal amount cannot be less than',
+    'Withdrawal failed, please contact customer service.'                        => 'Withdrawal failed, please contact customer service.',
+    'Signature verification failed'                                              => 'ignature verification failed',
+]; 

+ 2 - 1
application/api/lang/en/home.php

@@ -7,5 +7,6 @@ return [
       'User_id'               => 'User ID',
       'Symbol'                => 'Symbol',
       'Amount'                => 'Amount',
-      'Status'                => 'Status'
+      'Status'                => 'Status',
+      'System name'           => 'Tea Pay'
 ];

+ 4 - 0
application/api/lang/en/order.php

@@ -13,4 +13,8 @@ return [
       '已发货'                                => 'Shipped',
       '已取消'                                => 'Cancelled',
       '已完成'                                => 'Completed',
+
+
+
+      
 ];

+ 8 - 0
application/api/lang/zh-cn.php

@@ -99,4 +99,12 @@ return [
     'You have no permission'                         => '你没有权限访问',
     'An unexpected error occurred'                   => '发生了一个意外错误,程序猿正在紧急处理中',
     'This page will be re-directed in %s seconds'    => '页面将在 %s 秒后自动跳转',
+    'Please bind your superior first'                => '请先绑定上级',
+    'The recommender cannot be yourself please re-bind to your superior'         => '推荐人不能为自己,请重新绑定上级',
+    'The invitation code is invalid, please manually bind your superior'         => '邀请码无效,请手动绑定上级',
+    'Your account has been locked please contact customer service'               => '您的账号被锁定,请联系客服。',
+    'The withdrawal amount must be greater than 0'                               => '提现金额必须大于0',
+    'The withdrawal amount cannot be less than'                                  => '提现金额不能小于',
+    'Withdrawal failed, please contact customer service.'                        => '提现失败,请联系客服。',
+    'Signature verification failed'                                              => '签名校验失败',
 ];

+ 1 - 0
application/api/lang/zh-cn/home.php

@@ -1,5 +1,6 @@
 <?php
 
 return [
+      'System name'           => '茶付宝',
       'Parameter error'       => '参数有误',
 ];

+ 17 - 3
application/common/model/AnnouncementModel.php

@@ -10,9 +10,23 @@ class AnnouncementModel  extends Model
     protected $name = "announcement";
 
     // 开启自动写入时间戳字段
-//    protected $autoWriteTimestamp = 'int';
+    //protected $autoWriteTimestamp = 'int';
     // 定义时间戳字段名
-//    protected $createTime = 'createtime';
-//    protected $updateTime = 'updatetime';
+    //    protected $createTime = 'createtime';
+    //    protected $updateTime = 'updatetime';
+ 
+    const Announ         = 1;
+    const Banner         = 2;
+
+    const STOP           = 2;
+    const NORMAL         = 1;
+    
+    //状态
+    public $status_list = [
+        '-1'                    => '全部',
+        self::Announ            => '公告',
+        self::Banner            => '轮播图'
+    ];
+
 
 }