Browse Source

地区搜索

afa 9 months ago
parent
commit
360c0c283c

+ 6 - 3
application/api/controller/Order.php

@@ -253,7 +253,7 @@ class Order extends Api
 
 
     //取消转让 
-    public function cancel(ProductOrder $productOrder, ProductTransfer $productTransfer, UserModel $userModel)
+    public function cancel(ProductOrder $productOrder, ProductTransfer $productTransfer)
     {
         $params = $this->request->post();
         $validate = \think\Loader::validate('Order');
@@ -268,9 +268,12 @@ class Order extends Api
             //转让列表取消
             $productTransfer::where('order_id',$params['order_id'])->setField('status', $productTransfer::STOP);
 
+            //新增记录
+            $productOrder::setCreateOrder($order_info['order_id'], $order_info, $productOrder::Popular, $order_info['user_id'], $order_info['from_user'], getOrderSN('R'), 0);
+
             //修改:类型状态
-            $order_info->type_id= $productOrder::Popular; 
-            $order_info->status = $productOrder::Paid; 
+            $order_info->type_id= $productOrder::Transfer; 
+            $order_info->status = $productOrder::Cancelled;
             $order_info->save();
             // 提交事务
             Db::commit();

+ 53 - 281
application/api/controller/User.php

@@ -15,6 +15,7 @@ use app\common\model\ParametersModel;
 use fast\Action;
 use fast\Asset;
 use fast\Random;
+use Google\Service\Storage\Resource\Objects;
 use think\Config;
 use think\Db;
 use think\Exception;
@@ -66,28 +67,8 @@ class User extends Api
      */
     public function getNftList(ProductOrder $productOrder)
     {
-        $where = [];
         $typeId = $this->request->post('type_id/d', 0);
-        switch ($typeId) {
-            case 0:
-                $where['a.status'] = ['<' , $productOrder::Shipped];
-                break;
-            case 1:
-                $where = ['a.type_id' => $productOrder::Transfer, 'a.status' => $productOrder::Transferred];
-                break;
-            case 2:
-                $where = ['a.type_id' => $productOrder::Transfer, 'a.status' => $productOrder::Closure];
-                break;
-            case 3:
-                $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Cancelled];
-                break;
-            case 4:
-                $where = ['a.type_id' => $productOrder::Giveaway, 'a.status' => $productOrder::Closure];
-                break;
-            case 5:
-                $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Shipped];
-                break;
-        }
+        $where = self::getNftWhere($typeId, $productOrder);
         $list = $productOrder->alias('a')
               ->join("product_list b", "b.id = a.product_id", "left")
               ->join("products c", "c.id = b.type_id", "left")
@@ -138,10 +119,8 @@ class User extends Api
      */
     public function getChaList(UserModel $userModel)
     {
-       
         // 总推荐数
         $list['total'] = $userModel::where('parent_id', $this->auth->id)->count();
-
         // 直推列表 
         $list['data'] = $userModel::where('parent_id', $this->auth->id)
                     ->field("address,create_time,nickname, REPLACE(phone, SUBSTRING(phone, 4, 4), '****') as phone")
@@ -178,12 +157,18 @@ class User extends Api
      * @return void
      */
     public function getOperateLog(ProductOrder $productOrder)
-    {
+    {   
+
+        $typeId = $this->request->post('type_id/d', 0);
+        $status = $this->request->post('status/d', 0);
+        $areaId = $this->request->post('area_id/s', 0);
+        $where = self::getOperateWhere($typeId, $status, $areaId);
         $list['data'] = $productOrder->alias('a')
                 ->join("product_list b", "b.id = a.product_id", "left")
                 ->join("product_area d", "d.id = a.area_id", "left") //地区
                 ->field('a.id as order_id,a.product_id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,a.price,a.status,a.type_id,a.create_time,d.province,d.city,d.area,d.county')
                 ->where('a.user_id', $this->auth->id)
+                ->where($where)
                 ->order('a.id DESC')
                 ->paginate($this->pageSize);
         foreach ($list['data'] as &$item) {
@@ -197,274 +182,61 @@ class User extends Api
         $this->success('', $list);
     }
 
-
-
-
-
-    /**
-     * 提交出款信息
-     * @return void
-     */
-    public function smhSubmit()
-    {
-        $amount = $this->request->post('amount'); // 金额
-        $sign = $this->request->post('sign'); // 签名信
-        $address = $this->request->post('address'); // 提现地址
-        if(empty($sign)){
-            $this->error('参数错误');
-        }
-        $real   = $amount; // 实际到账
-        $min    = (new ParametersModel)->getValue('smhMinAmount') ?? '0';
-        if ($amount <= 0) {
-            $this->error('提现金额必须大于0');
-        } else if ($amount < $min) {
-            $this->error('提现金额不能小于' . $min);
-        }
-        $uid = $this->auth->getTokenUserID();
-        // 用户信息
-        $user = (new UserModel())->getById($uid);
-        if (empty($user)) {
-            $this->error('用户不存在');
-        }
-
-        $wallet = (new LedgerWalletModel())->getWallet($user['id']);
-        if (empty($wallet)) {
-            $this->error('用户不存在');
-        }
-        if($amount > $wallet['smh']){
-            $this->error('SMH余额不足');
-        }
-        $rate   = (new ParametersModel)->getValue('smhFeeRate') ?? '0';
-        // 扣除手续费后
-        if ($rate >= 0 && $rate < 1) { // 比例范围只在0-1之间
-            $real = bcmul($amount, bcsub(1, $rate, 6), 6);
-        }else{
-            $this->error('手续费设置错误:' . $rate);
-        }
-        // 验签
-        $signMsg = "EtcWithdraw"; // 与前端约定的固定值
-        if (!checkSign($signMsg, $sign, $user['address'])) {
-            $this->error('签名校验失败');
-        }
-
-        //有过出款记录,则不能修改出款钱包地址
-        $wallet = (new OfflineWithdrawRecordModel())
-            ->where('user_id', $user['id'])
-            ->where('symbol', 'smh')
-            ->where('status', OfflineWithdrawRecordModel::StatusSuccess)
-            ->find();
-        if (!empty($wallet)) {
-            $address = $wallet['to_address'];
-        }
-
-        // 启动事务
-        Db::startTrans();
-        try {
-            // 更新USDT和账变
-            (new LedgerWalletModel())->changeWalletAccount($uid, Asset::SMH, -$amount, LedgerSmhChangeModel::WithdrawCash);
-
-            // 创建提现记录
-            $txHash = Random::uuid();
-            (new OfflineWithdrawRecordModel())->createWithdraw($txHash, $uid, $amount, $real, $address, 'smh');
-
-            // 提交事务
-            Db::commit();
-        } catch (Exception $e) {
-            // 回滚事务
-            Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
-        }
-
-        $this->success('提现申请已提交');
-    }
-
     /**
-     * 提交出款信息
-     * @return void
+     * Nft搜索条件
+     * @return array
      */
-    public function smhExchange()
-    {
-        $amount = $this->request->post('amount'); // 金额
-
-        if($amount < 0.01){
-            $this->error('兑换数量太少');
-        }
-
-        $uid = $this->auth->getTokenUserID();
-
-        // 用户信息
-        $user = (new UserModel())->getById($uid);
-        if (empty($user)) {
-            $this->error('用户不存在');
-        }
-
-        $wallet = (new LedgerWalletModel())->getWallet($user['id']);
-        if (empty($wallet)) {
-            $this->error('用户不存在');
-        }
-
-        if($amount > $wallet['smh']){
-            $this->error('SMH余额不足');
-        }
-
-        $etc_ratio = (new ParametersModel())->getValue('smhExchangeRatio');//兑换手续费
-        $etc_price = (new SmhWithdrawRecordModel())->getEtcPrice(); //ETC价格
-
-        if($etc_ratio > 0.9){
-            $this->error('兑换手续费异常');
-        }
-
-        $usdt_amount = $amount * $etc_price * (1 - $etc_ratio);
-
-        // 启动事务
-        Db::startTrans();
-        try {
-            // 更新ETC和账变
-            (new LedgerWalletModel())->changeWalletAccount($uid, Asset::SMH, -$amount, LedgerSmhChangeModel::Exchange);
-
-            // 更新USDT和账变
-            (new LedgerWalletModel())->changeWalletAccount($uid, Asset::USDT, $usdt_amount, Action::EtcExchange);
-
-            // 提交事务
-            Db::commit();
-        } catch (Exception $e) {
-            // 回滚事务
-            Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
+    private static function getNftWhere(int $typeId, object  $productOrder): array
+    {   
+        $where = [];
+        switch ($typeId) {
+            case 0:
+                $where['a.status'] = ['<' , $productOrder::Shipped];
+                break;
+            case 1:
+                $where = ['a.type_id' => $productOrder::Transfer, 'a.status' => $productOrder::Transferred];
+                break;
+            case 2:
+                $where = ['a.type_id' => $productOrder::Transfer, 'a.status' => $productOrder::Closure];
+                break;
+            case 3:
+                $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Cancelled];
+                break;
+            case 4:
+                $where = ['a.type_id' => $productOrder::Giveaway, 'a.status' => $productOrder::Closure];
+                break;
+            case 5:
+                $where = ['a.type_id' => $productOrder::Popular, 'a.status' => $productOrder::Shipped];
+                break;
         }
-
-        $this->success('提现申请已提交');
+        return $where;
     }
 
-
     /**
-     * 获取aleo出款信息
-     * @return void
+     * 操作记录搜索条件
+     * @return array
      */
-    public function aleoInfo()
+    private static function getOperateWhere(int $typeId, int $status, string $areaId)
     {
-        $user = $this->auth->getUser();
-        if (empty($user)) {
-            $this->error('用户信息不存在');
-        }
-
-        $resp = [
-            'aleo'          => '0', // 平台币余额
-            'aleo_min_amount' => 0, // 最低提现U数量
-            'tips'           => "", //提现提示信息
-            'address'        => "", // 出款地址,此地址有值时,前台不允许重新输入
-            //'smh_price'      => (new SmhWithdrawRecordModel())->getEtcPrice(), //smh价格
-            //'smh_exchange_ratio' => (new ParametersModel())->getValue('smhExchangeRatio'), // smh兑换USDT手续费
-            'aleo_fee_rate'   => (new ParametersModel())->getValue('aleoFeeRate'), // smh提现手续费
-        ];
-
-        $wallet = (new LedgerWalletModel())->getWallet($user['id']);
-        if (!empty($wallet)) {
-            $resp['aleo'] = $wallet['token'];
-        }
-
-        $config = (new ParametersModel)
-            ->where('name', '=', 'aleoMinAmount')
-            ->find();
-        if(empty($config)){
-            $this->error('未配置Aleo出款参数');
-        }
-        $resp['aleo_min_amount'] = $config['value'];
-        $resp['tips'] = $config['tip'];
-
-        $wallet = (new OfflineWithdrawRecordModel())
-            ->where('user_id', $user['id'])
-            ->where('symbol', 'aleo')
-            ->where('status', OfflineWithdrawRecordModel::StatusSuccess)
-            ->find();
-        if (!empty($wallet)) {
-            $resp['address'] = $wallet['to_address'];
-        }
-
-        $this->success('', $resp);
+        $where = [];
+        //类型
+        if($typeId > 0 || $status > 0) $where = ['a.type_id' => $typeId, 'a.status' => $status];
+        //编号Id
+        if(!empty($areaId)){
+            $arr = explode('-', $areaId);
+            if(count($arr) > 0) {
+                if(isset($arr[0])) $where['d.province'] = [ '=' , $arr[0]];
+                if(isset($arr[1])) $where['d.city']     = ['=', $arr[1]];
+                if(isset($arr[2])) $where['d.area']     = ['=', $arr[2]];
+                if(isset($arr[3])) $where['d.county']   = ['=', $arr[3]];
+            }
+        }
+        return $where;
     }
-    /**
-     * 提交出款信息
-     * @return void
-     */
-    public function aleoSubmit()
-    {
-        $amount = $this->request->post('amount'); // 金额
-        $sign = $this->request->post('sign'); // 签名信
-        $address = $this->request->post('address'); // 提现地址
-//        $sign = 'test';
-        if(empty($sign)){
-            $this->error('参数错误');
-        }
-
-        $real   = $amount; // 实际到账
-        $min    = (new ParametersModel)->getValue('aleoMinAmount') ?? '0';
-        if ($amount <= 0) {
-            $this->error('提现金额必须大于0');
-        } else if ($amount < $min) {
-            $this->error('提现金额不能小于' . $min);
-        }
-
-        $uid = $this->auth->getTokenUserID();
-
-        // 用户信息
-        $user = (new UserModel())->getById($uid);
-        if (empty($user)) {
-            $this->error('用户不存在');
-        }
-
-        $wallet = (new LedgerWalletModel())->getWallet($user['id']);
-        if (empty($wallet)) {
-            $this->error('用户不存在');
-        }
 
-        if($amount > $wallet['token']){
-            $this->error('Aleo余额不足');
-        }
-
-        $rate   = (new ParametersModel)->getValue('aleoFeeRate') ?? '0';
-
-        // 扣除手续费后
-        if ($rate >= 0 && $rate < 1) { // 比例范围只在0-1之间
-            $real = bcmul($amount, bcsub(1, $rate, 6), 6);
-        }else{
-            $this->error('手续费设置错误:' . $rate);
-        }
-
-        // 验签
-        $signMsg = "EtcWithdraw"; // 与前端约定的固定值
-        if (!checkSign($signMsg, $sign, $user['address'])) {
-            $this->error('签名校验失败');
-        }
 
-        //有过出款记录,则不能修改出款钱包地址
-        $wallet = (new OfflineWithdrawRecordModel())
-            ->where('user_id', $user['id'])
-            ->where('symbol', 'aleo')
-            ->where('status', OfflineWithdrawRecordModel::StatusSuccess)
-            ->find();
-        if (!empty($wallet)) {
-            $address = $wallet['to_address'];
-        }
 
-        // 启动事务
-        Db::startTrans();
-        try {
-            // 更新USDT和账变
-            (new LedgerWalletModel())->changeWalletAccount($uid, Asset::TOKEN, -$amount, LedgerTokenChangeModel::WithdrawCash);
 
-            // 创建提现记录
-            $txHash = Random::uuid();
-            (new OfflineWithdrawRecordModel())->createWithdraw($txHash, $uid, $amount, $real, $address, 'aleo');
-
-            // 提交事务
-            Db::commit();
-        } catch (Exception $e) {
-            // 回滚事务
-            Db::rollback();
-            $this->error('提交失败:' . $e->getMessage());
-        }
-
-        $this->success('提现申请已提交');
-    }
+    
+     
 }

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

@@ -32,4 +32,5 @@ return [
     '已赠送'                                                                        => 'Gifted',
     '已转让'                                                                        => 'Transferred',
     '已提货'                                                                        => 'Gifted',
+    '已取消'                                                                        => 'Cancelled'   
 ]; 

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

@@ -121,6 +121,7 @@ return [
     '已赠送'                                                                        => '已赠送',
     '已转让'                                                                        => '已转让',
     '已提货'                                                                        => '已提货',
+    '已取消'                                                                        => '已取消'  
 
 
 ];

+ 8 - 2
application/common/model/ProductOrder.php

@@ -76,7 +76,6 @@ class ProductOrder extends Model
     }
 
 
-
     public static function getStatusList()
     {
         return [self::Ordered => __('已下单'), self::Paid  => __('已付款'), self::Transferred => __('已转让'), 
@@ -86,7 +85,14 @@ class ProductOrder extends Model
     //全部类型: 
     public static function getStatusAll()
     {
-        return [0 => __('已购买'), 1 => __('转让中'), 2 => __('已赠送'), 3 => __('已转让'), 4 => __('已提货')];
+        return [
+            ['type_id'=>self::Popular,  'status'=> self::Paid,     'text' => __('已购买')],
+            ['type_id'=>self::Transfer, 'status'=> self::Transferred,'text' => __('转让中')],
+            ['type_id'=>self::Giveaway, 'status'=> self::Closure, 'text' => __('已赠送')],
+            ['type_id'=>self::Transfer, 'status'=> self::Closure, 'text' => __('已转让')], 
+            ['type_id'=>self::Popular, 'status' => self::Shipped, 'text' => __('已提货')],
+            ['type_id'=>self::Transfer, 'status'=> self::Cancelled,'text' => __('已取消')]
+        ];
     }
 
     //产品