shish 1 ano atrás
pai
commit
3105765dda

+ 28 - 20
app-ghs/controllers/LiveOrderController.php

@@ -10,52 +10,60 @@ use Yii;
 class LiveOrderController extends BaseController
 {
 
+    //走播单列表 ssh 20241003
+    public function actionList()
+    {
+        $where['mainId'] = $this->mainId;
+        $respond = LiveOrderClass::getOrderList($where);
+        util::success($respond);
+    }
+
     //添加订单 ssh 20241003
     public function actionAddOrder()
     {
         $post = Yii::$app->request->post();
         $itemId = $post['itemId'] ?? 0;
-        if(empty($itemId)){
+        if (empty($itemId)) {
             util::fail('请选花材');
         }
-        $product = ProductClass::getById($itemId,true);
-        if(empty($product)){
+        $product = ProductClass::getById($itemId, true);
+        if (empty($product)) {
             util::fail('没有找到花材');
         }
-        if($product->mainId != $this->mainId){
+        if ($product->mainId != $this->mainId) {
             util::fail('不是你的花材');
         }
-        $selectCustom = $post['selectCustom']??'';
-        if(empty($selectCustom)){
+        $selectCustom = $post['selectCustom'] ?? '';
+        if (empty($selectCustom)) {
             util::fail('没有客户');
         }
-        $arr = json_decode($selectCustom,true);
-        if(empty($arr) || is_array($arr) == false){
+        $arr = json_decode($selectCustom, true);
+        if (empty($arr) || is_array($arr) == false) {
             util::fail('没有客户信息');
         }
         $mainId = $this->mainId;
-        $hasItem = LiveOrderClass::getByCondition(['mainId'=>$mainId,'itemId'=>$itemId,'switch'=>0],true);
-        if(!empty($hasItem)){
+        $hasItem = LiveOrderClass::getByCondition(['mainId' => $mainId, 'itemId' => $itemId, 'switch' => 0], true);
+        if (!empty($hasItem)) {
             util::fail('这个花材已添加过');
         }
         $has = [];
         $customList = [];
-        foreach($arr as $key => $info){
-            $customId = $info['customId']??0;
-            if(isset($has[$customId])){
+        foreach ($arr as $key => $info) {
+            $customId = $info['customId'] ?? 0;
+            if (isset($has[$customId])) {
                 util::fail('重复的客户');
             }
-            $has[$customId] =1;
-            $customName = $info['customName']??'';
-            $num = $info['num']??0;
-            $price = $info['price']??0;
-            $customList[] = ['customId'=>$customId,'customName'=>$customName,'num'=>$num,'price'=>$price];
+            $has[$customId] = 1;
+            $customName = $info['customName'] ?? '';
+            $num = $info['num'] ?? 0;
+            $price = $info['price'] ?? 0;
+            $customList[] = ['customId' => $customId, 'customName' => $customName, 'num' => $num, 'price' => $price];
         }
-        $params = ['product'=>$product,'customList'=>$customList];
+        $params = ['product' => $product, 'customList' => $customList];
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            LiveOrderClass::addOrder($params,$mainId);
+            LiveOrderClass::addOrder($params, $mainId);
             $transaction->commit();
             util::complete('创建成功');
         } catch (\Exception $e) {

+ 6 - 0
biz-ghs/live/classes/LiveOrderClass.php

@@ -12,6 +12,12 @@ class LiveOrderClass extends BaseClass
 
     public static $baseFile = '\bizGhs\live\models\LiveOrder';
 
+    public static function getOrderList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        return $data;
+    }
+
     public static function addOrder($params,$mainId){
         $product  = $params['product'];
         $itemId = $product->id??0;