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 . '张订单!'); } }
public function genOrderId() { $orderId = 'OUT' . date('Ymd'); $count = StoreOutstore::find()->where(['between', 'date', date('Y-m-d 00:00:00'), date('Y-m-d 23:59:59')])->count(); return $orderId . str_pad($count + 1, 5, 0, STR_PAD_LEFT); }