Browse Source

Merge branch 'master' of https://git.hxiaoju.top/Teapay/RWACha-API

* 'master' of https://git.hxiaoju.top/Teapay/RWACha-API:
  去掉重复订单
  去掉重复订单
jason 6 months ago
parent
commit
bc71ed64b6
1 changed files with 27 additions and 17 deletions
  1. 27 17
      application/api/controller/Index.php

+ 27 - 17
application/api/controller/Index.php

@@ -8,7 +8,7 @@ use fast\Asset;
 use app\common\model\LedgerTeacChangeModel;
 use app\common\model\LedgerWalletModel;
 use app\common\model\UserPledge;
-use fast\Random;
+use think\Db;
 
 /**
  * 首页接口
@@ -35,21 +35,6 @@ class Index extends Api
             $day   = 86400;
             foreach ($list as $item) {
                
-                if($item->status == 1) {
-                    //未接触收益
-                    $reta  = bcdiv($item->day_num, $day, 6); //天数
-                    $inter = ($item->last_time == 0) ? $time - $item->create_time: $time - $item->last_time; //最后收取时间
-                    $total_inco = bcmul($reta, $inter, 6) * $item->num; //累计收益
-                    $item->last_time = $time; //收取时间
-                    $item->total_self= bcadd($total_inco, $item->total_self, 2); //累计收益
-                    $total = $total_inco; //累计收益
-                    
-                }
-           
-                if($total > 0){
-                    //更新用户资产
-                    $ledgerWalletModel->changeWalletAccount($item->user_id, Asset::TEAC, $total, LedgerTeacChangeModel::Pledge, 0);
-                }
 
                 //修改详情订单状态
                 $detail = json_decode($item['details'], true);
@@ -79,7 +64,32 @@ class Index extends Api
 
     }
 
-  
+    //去掉重复订单
+    public function removeOrder(ProductOrder $productOrder) {
+
+ 
+        $i = 0;
+        $rows = Db::name('product_order')->field('id,order_no,count(*) as count')->group('order_no')->having('count > 1')->limit(500)->select();
+        
+     
+        foreach ($rows as $row) {
+
+            $order = $productOrder::where('id', $row['id'])->order('id asc')->select();
+            foreach ($order as $key => $vv) {
+                if($key > 0){
+                    $vv->order_no = $row['order_no']. $key;
+                    $vv->save();
+                    $i++;
+                }
+            }
+         
+            
+        }
+            // 如果需要,可以在这里进行一些批量操作
+       
+        $this->success('ok:'. $i);
+    }
+