afa 7 месяцев назад
Родитель
Сommit
4f6743e002

+ 10 - 5
application/api/controller/Synthesis.php

@@ -8,8 +8,8 @@ use app\common\model\ProductLists;
 use app\common\model\ProductOrder;
 use app\common\model\Synthesis as SynthesisModel;
 use Exception;
-use fast\Asset;
-use fast\Http;
+use app\api\logic\WelfareLoginc;
+use app\common\model\UserModel;
 use think\Db;
 use think\Log;
 
@@ -67,7 +67,7 @@ class Synthesis extends Api
     /*
      * 合成
      */
-    public function create( ProductOrder $productOrder)
+    public function create( ProductOrder $productOrder, UserModel $userModel)
     {
         $id         = $this->request->post('id', 0, 'intval');
         $num        = $this->request->post('num', 0, 'intval');
@@ -88,8 +88,13 @@ class Synthesis extends Api
             $productOrder->setSynthesisOrder($synthesis, $productList, $num, $this->auth->id);
 
             // 添加新订单
-            dump( 11);die;
-          
+            $result = WelfareLoginc::setUserWelfareLos($this->auth->id, $synthesis->product_id, $num, time(), $this->lan, $productOrder::Synthesi);
+
+            //添加茶数量
+            if($result['price'] > config('min_rwa_price')) $userModel::updateForRwaNum($this->auth->id, $this->auth->parent_id, $num, '+');
+
+            $synthesis->num += $num;
+            $synthesis->save();
             // 提交事务
             Db::commit();
         } catch (Exception $e) {

+ 1 - 1
application/common/model/ProductOrder.php

@@ -131,7 +131,7 @@ class ProductOrder extends Model
 
     //获取持有产品数量
     public static function getByOrderProductNum($productId, $num, $uid){
-        if(empty($productId)) return 0;
+        if(empty($productId)) return [];
         foreach ($productId as &$item) {
             $item['num'] = $num;
             $count = self::getUserOrderNum($uid, $item['id']);