afa 11 сар өмнө
parent
commit
9cd2731da2

+ 1 - 1
application/admin/lang/zh-cn/general/config.php

@@ -80,7 +80,7 @@ return [
     'This is a test mail'                  => '这是一封来自%s的邮件',
     'Please input your email'              => '请输入测试接收者邮箱',
     'Please input correct email'           => '请输入正确的邮箱地址',
-    'Recharge address'                     => '充值地址',
+    'Recharge txt'                         => '充值描述',
     'Transfer fee'                         => '转让手续费',
     'Chabao rate'                          => '茶宝汇率',
     'Withdrawal fee'                       => '提现手续费',

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

@@ -14,7 +14,7 @@ use app\common\model\LedgerWalletModel;
 use app\common\model\OfflineWithdrawRecordModel;
 use fast\Action;
 use think\Log;
-use think\Model;
+use think\Env;
 
 /**
  * 首页接口
@@ -341,7 +341,7 @@ class Ledger extends Api
 
     // 获取充值地址
     public function getAddress()
-    {
-        return $this->success('', getConfig('recharge_address'));
+    {   
+        return $this->success('', ['value'=> Env::get('rental.pay_address'), 'name'=>getConfig('recharge_txt')]);
     }
 }

+ 0 - 4
application/api/controller/Member.php

@@ -76,11 +76,7 @@ class Member extends Api
                 //推荐人奖励
                 $this->model::updateParentData($parentID, $newUserID);
             }
-
-          
         }
-       
-
     }
 
     /**

+ 37 - 1
application/api/controller/Order.php

@@ -11,7 +11,7 @@ use app\common\model\LedgerWalletModel;
 use app\common\model\UserBalanceLog;
 use app\common\model\UserArea;
 use app\common\model\UserModel;
-use app\common\model\UserPathModel;
+use app\common\model\OfflineRechargeRecordModel;
 use Exception;
 use fast\MembershipLevel;
 use think\Db;
@@ -231,5 +231,41 @@ class Order extends Api
         }
         $this->success('订单创建成功');
     }
+
+
+    /**
+     * 更新订单hash
+     * @return void
+     */
+    public function updateOrder()
+    {
+       
+        $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不能为空');
+        
+        //用户id、用户地址、hash、金额、状态、时间  address
+        Db::startTrans();
+        try {
+            //更新订单支付状态为 待确认
+            $order_update = OfflineRechargeRecordModel::create([
+                'user_id'       => $this->auth->id,
+                'amount'        => $amount,
+                'status'        => OfflineRechargeRecordModel::StatusConfirm,
+                'tx_hash'       => $tx_hash,
+                'from_address'  => $this->auth->address,
+                'to_address'    => Env::get('rental.pay_address')
+            ]);
+            // 提交事务
+            Db::commit();
+        } catch (Exception $e) {
+            // 回滚事务
+            Db::rollback();
+            $this->error('提交失败:' . $e->getMessage());
+        }
+        $this->success('订单支付成功');
+
+    }
 }
 

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

@@ -18,7 +18,6 @@ use fast\Random;
 use think\Config;
 use think\Db;
 use think\Exception;
-
 /**
  * 会员接口
  */

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

@@ -5,4 +5,6 @@ return [
       '订单不存在'            => 'Order does not exist',
       '参数有误,无可用产品'   => 'Parameter error, no available products',
       '抢购已结束'            => 'The sale has ended',
+      '交易金额不能为空'       => 'The transaction amount cannot be empty. The',
+      '交易Hash不能为空'       => 'transaction hash cannot be empty.',
 ];

+ 4 - 0
application/api/lang/zh-cn/order.php

@@ -5,4 +5,8 @@ return [
       '订单不存在'            => '订单不存在',
       '参数有误,无可用产品'   => '参数有误,无可用产品',
       '抢购已结束'            => '抢购已结束',
+
+      '交易金额不能为空'       => '交易金额不能为空',
+      '交易Hash不能为空'       => '交易Hash不能为空',
+      
 ];

+ 14 - 0
application/common/model/OfflineRechargeRecordModel.php

@@ -33,6 +33,20 @@ class OfflineRechargeRecordModel extends Model
         self::StatusCancel    => '取消'
     ];
 
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'create_time_text',
+        'update_time_text'
+    ];
+
     public function userInfo()
     {
         return $this->hasOne(UserModel::class, 'id', 'user_id');