Browse Source

订单收益又修改,订单支付时间临时改为10日前

lizhen_gitee 1 year ago
parent
commit
9e20036a68

+ 37 - 2
addons/unishop/behavior/Order.php

@@ -171,7 +171,12 @@ class Order
                 throw new Exception(__('Insufficient inventory,%s pieces left', $productInfo['stock']));
             }
             $orderPrice = bcadd($orderPrice, bcmul($productInfo['sales_price'], $numbers[$key], 2), 2);
-            $ordershouyi= bcadd($ordershouyi, bcmul($productInfo['pifa_shouyi'], $numbers[$key], 2), 2);
+//            $ordershouyi= bcadd($ordershouyi, bcmul($productInfo['pifa_shouyi'], $numbers[$key], 2), 2);
+
+            $shouyi = $productInfo['sales_price']-($productInfo['pifa_price']*$productInfo['pifa_number'])+$productInfo['pifa_shouyi'];
+            $ordershouyi= bcadd($ordershouyi, bcmul($shouyi, $numbers[$key], 2), 2);
+
+
             $baseProductInfo[] = $productInfo;
         }
 
@@ -218,7 +223,7 @@ class Order
      */
     public function paidSuccess(&$params, $extra)
     {
-        $nowtime = time();
+        $nowtime = time()+$this->jiesuan_tendays_ago();
         $order = &$params;
         $order->have_paid = $nowtime;// 更新支付时间为当前时间
         $order->pay_type = $extra['pay_type'];
@@ -242,6 +247,36 @@ class Order
         Db::name('user')->where('id',$order->user_id)->update(['last_paytime'=>$nowtime]);
     }
 
+    //结算要按10天算
+    private function jiesuan_tendays_ago(){
+
+        $nowtime = time();
+
+        /*if(input('date','')){
+            $nowtime = strtotime(input('date',''));
+        }*/
+
+        $today   = strtotime(date('Y-m-d',$nowtime));
+
+        $toweek  = date('w',$nowtime);
+
+
+        $enum = [
+            1 => 11,
+            2 => 11,
+            3 => 11,
+            4 => 10,
+            5 => 10,
+            6 => 10,
+            0 => 10, //这一天没人结算
+        ];
+
+        $rs = $today - ($enum[$toweek] * 86400);
+//        dump(date('Y-m-d',$rs));
+
+        return $rs;
+    }
+
     /**
      * 支付失败
      * @param $params

+ 6 - 6
application/extra/wallet.php

@@ -5,12 +5,12 @@
 return [
     'logtype' => [
         1  => '邀请奖励',
-        2  => '积分兑换',
-        3  => '直推代理奖励', //支付后立刻获得
-        4  => '间推代理奖励', //支付后立刻获得
-        5  => '下单收益',    //支付后立刻获得
-        6  => '总代奖励',
-        7  => '总代奖励(间推)',
+        2  => '积分兑换', //score -
+        3  => '直推代理奖励', //支付后立刻获得 score +
+        4  => '间推代理奖励', //支付后立刻获得 score +
+        5  => '下单收益',    //订单10日结算 score +
+        6  => '总代奖励',    //订单10日结算 score +
+        7  => '总代奖励(间推)',//订单10日结算 score +
     ],
     'moneyname' => [
         'money'    => '佣金',

+ 15 - 2
application/index/controller/Plantask.php

@@ -110,6 +110,7 @@ class Plantask extends Controller
         return $rs;
     }
 
+    //推荐奖励
     //订单支付回调之后的任务,每分钟运行
     //烧伤
     public function auto_order_paid(){
@@ -131,14 +132,14 @@ class Plantask extends Controller
         foreach($order_list as $key => $order){
 
             //买家立刻得到积分
-            if($order['order_shouyi'] > 0){
+            /*if($order['order_shouyi'] > 0){
                 $rs_wallet = $walletmodel->lockChangeAccountRemain($order['user_id'],'score',$order['order_shouyi'],5,'下单收益','unishop_order',$order['id'],$order['user_id']);
                 if($rs_wallet['status'] === false){
                     echo $rs_wallet['msg'];
                     Db::rollback();
                     exit;
                 }
-            }
+            }*/
 
 
 
@@ -215,6 +216,7 @@ class Plantask extends Controller
         echo '成功'.count($order_list);
     }
 
+    //总代奖励
     //自动结算10日前订单,每分钟运行
     public function auto_jiesuan_order(){
         $nowtime = time();
@@ -242,6 +244,17 @@ class Plantask extends Controller
         }
 //        dump($order);
 
+        //买家得到收益
+        if($order['order_shouyi'] > 0){
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($order['user_id'],'score',$order['order_shouyi'],5,'下单收益','unishop_order',$order['id'],$order['user_id']);
+            if($rs_wallet['status'] === false){
+                echo $rs_wallet['msg'];
+                Db::rollback();
+                exit;
+            }
+        }
+
+
         //为上级做贡献,找到上级
         $intro_uid = Db::name('user')->where('id',$order['user_id'])->value('intro_uid');
         if(empty($intro_uid)){