瀏覽代碼

算奖金

lizhen_gitee 1 年之前
父節點
當前提交
2efc7eae4a
共有 3 個文件被更改,包括 8 次插入9 次删除
  1. 1 1
      addons/unishop/controller/Product.php
  2. 2 2
      addons/unishop/model/Order.php
  3. 5 6
      application/api/controller/Demo.php

+ 1 - 1
addons/unishop/controller/Product.php

@@ -84,7 +84,7 @@ class Product extends Base
 
         // 评价
         $data['evaluate_data'] = (new Evaluate)->where(['product_id' => $productId])
-        ->field('COUNT(*) as count, IFNULL(CEIL(AVG(rate)/5*100),0) as avg')
+        ->field('COUNT(*) as count, IFNULL(AVG(rate),0) as avg')
         ->cache(10)->find();
 
 

+ 2 - 2
addons/unishop/model/Order.php

@@ -285,12 +285,12 @@ class Order extends Model
                 'flash_id' => $data['flash_id'] ?? 0, // 秒杀id
 
                 //追加
-                'user_product'=> $userId.'_'.$product['id'],
+                'user_product'=> $userId.'_'.$product['id'],//为了提高group速度,合二为一
                 'pifa_number' => $product['pifa_number'],
                 'pifa_price'  => $product['pifa_price'],
                 'pifa_shouyi' => $product['pifa_shouyi'],
                 'pifa_stock'  => bcmul($product['pifa_number'],$numbers[$key],0),
-
+                'pifa_status' => 0,//批发状态:0=在售,1=售出
             ];
 
             if (!empty($specs[$key])) {

+ 5 - 6
application/api/controller/Demo.php

@@ -70,16 +70,15 @@ class Demo extends Api
         $this->success('返回成功', ['action' => 'test3']);
     }
 
+    //支付回调后的逻辑,或者计划任务的逻辑
     public function test4(){
         $order_id = 488359520289034240;
-        $order_info = Db::name('unishop_order')->where('id',1)->find();
 
-        $product_list = Db::name('unishop_order_product')->where('order_id',$order_id)->select();
+        $product_list = Db::name('unishop_order_product')->where('order_id',$order_id)->select();//已支付
         foreach($product_list as $key => $product){
-            for($i=1;$i<=$product['number'];$i++){
-                //echo $i;
-                //追加到批发
-            }
+            //收益
+            $shouyi = bcmul($product['number'],$product['pifa_shouyi'],0);
+
         }
     }