|
|
@@ -97,43 +97,72 @@ class ShopController extends BaseController
|
|
|
util::complete();
|
|
|
}
|
|
|
|
|
|
- //修改门店终端号、到期时间、续费状态等信息
|
|
|
+ //修改/批量修改门店终端号、到期时间、续费状态等信息
|
|
|
public function actionUpdate()
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
- $id = $post['id'] ?? 0;
|
|
|
- if (empty($id)) {
|
|
|
+ $isBatch = $post['isBatch'] ?? 0;
|
|
|
+ $ids = $post['ids'] ?? $post['id'] ?? [];
|
|
|
+ if (is_string($ids)) {
|
|
|
+ $ids = array_filter(array_map('trim', explode(',', $ids)));
|
|
|
+ } elseif (is_numeric($ids)) {
|
|
|
+ $ids = [(int)$ids];
|
|
|
+ }
|
|
|
+ if (empty($ids)) {
|
|
|
util::fail('缺少门店ID');
|
|
|
}
|
|
|
- $shop = ShopClass::getById($id, true);
|
|
|
- if (empty($shop)) {
|
|
|
+
|
|
|
+ $shops = ShopClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
|
|
|
+ if (empty($shops)) {
|
|
|
util::fail('没有找到对应门店');
|
|
|
}
|
|
|
|
|
|
- if (isset($post['lklSjNo'])) {
|
|
|
- $shop->lklSjNo = trim((string)$post['lklSjNo']);
|
|
|
- }
|
|
|
- if (isset($post['lklB2BTermNo'])) {
|
|
|
- $shop->lklB2BTermNo = trim((string)$post['lklB2BTermNo']);
|
|
|
- }
|
|
|
- if (isset($post['lklScanTermNo'])) {
|
|
|
- $shop->lklScanTermNo = trim((string)$post['lklScanTermNo']);
|
|
|
- }
|
|
|
- if (isset($post['deadline'])) {
|
|
|
- $shop->deadline = !empty($post['deadline']) ? trim((string)$post['deadline']) : null;
|
|
|
- }
|
|
|
- if (isset($post['beforeDeadline'])) {
|
|
|
- $shop->beforeDeadline = !empty($post['beforeDeadline']) ? trim((string)$post['beforeDeadline']) : null;
|
|
|
- }
|
|
|
- if (isset($post['hasRenew'])) {
|
|
|
- $shop->hasRenew = (int)$post['hasRenew'];
|
|
|
+ foreach ($shops as $shop) {
|
|
|
+ if (!empty($isBatch) || count($ids) > 1) {
|
|
|
+ // 批量修改模式:只更新有传且不为空/不为-1的字段
|
|
|
+ if (isset($post['lklSjNo']) && trim((string)$post['lklSjNo']) !== '') {
|
|
|
+ $shop->lklSjNo = trim((string)$post['lklSjNo']);
|
|
|
+ }
|
|
|
+ if (isset($post['lklB2BTermNo']) && trim((string)$post['lklB2BTermNo']) !== '') {
|
|
|
+ $shop->lklB2BTermNo = trim((string)$post['lklB2BTermNo']);
|
|
|
+ }
|
|
|
+ if (isset($post['lklScanTermNo']) && trim((string)$post['lklScanTermNo']) !== '') {
|
|
|
+ $shop->lklScanTermNo = trim((string)$post['lklScanTermNo']);
|
|
|
+ }
|
|
|
+ if (isset($post['deadline']) && trim((string)$post['deadline']) !== '') {
|
|
|
+ $shop->deadline = trim((string)$post['deadline']);
|
|
|
+ }
|
|
|
+ if (isset($post['beforeDeadline']) && trim((string)$post['beforeDeadline']) !== '') {
|
|
|
+ $shop->beforeDeadline = trim((string)$post['beforeDeadline']);
|
|
|
+ }
|
|
|
+ if (isset($post['hasRenew']) && $post['hasRenew'] !== '' && (int)$post['hasRenew'] !== -1) {
|
|
|
+ $shop->hasRenew = (int)$post['hasRenew'];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 单个修改模式:全量覆盖提交的字段
|
|
|
+ if (isset($post['lklSjNo'])) {
|
|
|
+ $shop->lklSjNo = trim((string)$post['lklSjNo']);
|
|
|
+ }
|
|
|
+ if (isset($post['lklB2BTermNo'])) {
|
|
|
+ $shop->lklB2BTermNo = trim((string)$post['lklB2BTermNo']);
|
|
|
+ }
|
|
|
+ if (isset($post['lklScanTermNo'])) {
|
|
|
+ $shop->lklScanTermNo = trim((string)$post['lklScanTermNo']);
|
|
|
+ }
|
|
|
+ if (isset($post['deadline'])) {
|
|
|
+ $shop->deadline = !empty($post['deadline']) ? trim((string)$post['deadline']) : null;
|
|
|
+ }
|
|
|
+ if (isset($post['beforeDeadline'])) {
|
|
|
+ $shop->beforeDeadline = !empty($post['beforeDeadline']) ? trim((string)$post['beforeDeadline']) : null;
|
|
|
+ }
|
|
|
+ if (isset($post['hasRenew'])) {
|
|
|
+ $shop->hasRenew = (int)$post['hasRenew'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $shop->save();
|
|
|
}
|
|
|
|
|
|
- if ($shop->save()) {
|
|
|
- util::complete('修改成功');
|
|
|
- } else {
|
|
|
- util::fail('修改失败');
|
|
|
- }
|
|
|
+ util::complete('修改成功');
|
|
|
}
|
|
|
|
|
|
//门店列表 ssh 20210730
|