afa 7 сар өмнө
parent
commit
445bc424ca

+ 3 - 9
application/api/controller/Product.php

@@ -29,7 +29,7 @@ class Product extends Api
      */
     public function getPopularList(ProductsModel $productsModel, ProductPopular $productPopular, ProductLists $productLists)
     {
-        $item = $productsModel::getProductTypeById($this->lan);
+        $item = $productsModel::getProductTypeAll($this->lan);
         $resp = array();
         foreach ($item as $kk =>$val) {
             $list=  $productLists->where('type_id', $kk)->field('id,thum as img_url,'.$this->lan.'_name as name')->select();
@@ -96,8 +96,6 @@ class Product extends Api
     public function getTransferDetail(ProductMarket $productMarket, OrderLogic $orderLogic, ProductOrder $productOrder)
     {
         $sort    = $this->request->post('sort/d', '');
-        $type_id = $this->request->post('type_id/s', '');
-        $key_val = $this->request->post('key_val/s', '');
         $order = 'a.price ASC';
         if($sort == 1) $order = 'a.price DESC';
         $map['a.status'] = $productMarket::Normal;
@@ -109,12 +107,8 @@ class Product extends Api
             ->where('a.status', $productMarket::Normal)
             ->where($map)
             ->order($order)
-            ->paginate($this->pageSize);
-
-        foreach ($list as &$item) {
-            $item['issue']       = $orderLogic::getProductIssue($item->product_id);  //发行: 是产品的库存总量(卖出和没卖出的都算,最保险的计算方式是剩余库存量+所有用户的持有量;因为空投产品不是从库存出去的   
-            $item['circulation'] = $productOrder::where('status', $productOrder::Paid)->count();  //流通: 所有用户的持有量    
-        }
+            ->find();
+   
         $this->success('', $list);
     }
  

+ 9 - 5
application/api/logic/MarketLogic.php

@@ -58,23 +58,27 @@ class MarketLogic
       {
             //市场
             $market = ProductMarket::where('product_id', $orderInfo['product_id'])->find();
-
+            $isUpdate = false;
             //是否全部取消
-            $rows = ProductTransfer::where('product_id', $orderInfo['product_id'])->where('status', ProductTransfer::Normal)->count();
-            if($rows == 1){
+            $rows  = ProductTransfer::where('order_id', $orderId)->find();
+            $count = ProductTransfer::where('product_id', $orderInfo['product_id'])->where('status', ProductTransfer::Normal)->count();
+            if($count == 1){
+                  $isUpdate = true;
                   $market->status = ProductMarket::Hidden;
             }else{
                   //取消最小价格
                   if($rows->price < $market->price){
+                        $isUpdate = true;
                         $market->price = ProductTransfer::getTransferMinPriceByProduct($orderInfo['product_id'], $rows->price);
                   }
             }
 
             //市场状态
-            $market->save();
+            if($isUpdate) $market->save();
 
             //转让列表取消
-            ProductTransfer::where('order_id',$orderId)->setField('status', ProductTransfer::Stop);
+            $rows->status = ProductTransfer::Stop;
+            $rows->save();
 
             //新增记录
             return ProductOrder::setCreateOrder($orderId, $orderInfo, ProductOrder::Popular, $userId, $orderInfo['from_user'], getOrderSN('R'.$orderInfo['order_id']), 0, $orderInfo->popular_price);

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

@@ -40,7 +40,7 @@ class ProductMarket extends Model
     }
 
 
-    //产品
+    //寄售
     public function productlists()
     {
         return $this->hasOne('ProductLists', 'id', 'product_id', [], 'LEFT')->setEagerlyType(0);

+ 9 - 2
application/common/model/ProductsModel.php

@@ -26,9 +26,16 @@ class ProductsModel  extends Model
     }
 
     //分类
-    public static function getProductTypeById(string $lan)
+    public static function getProductTypeAll(string $lan)
     {
-        return self::where('status', self::Normal)->column('id,'.$lan.'_title as title');
+        return self::where('status', self::Normal)->order('sort desc')->column('id,'.$lan.'_title as title');
+    }
+
+    //分类
+    public static function getProductTypeById(string $lan)
+    {   
+        $result = self::where('status', self::Normal)->order('sort desc')->field('id,'.$lan.'_title as title')->select();
+        return array_merge([0=>['id'=>0, 'title'=>'全部']], $result);
     }
 
 }