예제 #1
0
 public function actionDelete()
 {
     $ids = explode(',', trim(Yii::$app->request->getBodyParam('ids'), ','));
     if (empty($ids)) {
         echo '请选择数据!';
         Yii::$app->end();
     }
     $idsCount = count($ids);
     $models = StoreOutstore::find()->where(['status' => 'wait', 'id' => $ids])->all();
     $orderIds = [];
     foreach ($models as $value) {
         if ($value->status != 'succ') {
             $orderIds[] = $value->order_id;
         }
     }
     $flag = StoreStoreDetail::deleteAll(['in', 'order_id', $orderIds]);
     $rowsCount = StoreOutstore::deleteAll(['in', 'order_id', $orderIds]);
     if ($rowsCount == 0) {
         $this->ajax_return();
     } else {
         $this->ajax_return(true, '共删除' . $rowsCount . '张订单!');
     }
 }