public function actionCount($id)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$count = (int) Yii::$app->request->post('value', 1);
$model = Purchase::findOne(['id' => $id, 'store_id' => Yii::$app->user->identity->store_id]);
if (!$model || $count < 1 || $count > 500) {
throw new BadRequestHttpException('参数错误。');
}
$model->count = $count;
if ($model->save(false)) {
return ['status' => 'ok'];
} else {
return ['status' => 'no', 'msg' => '设置错误。'];
}
}