|
|
@@ -97,13 +97,83 @@ class ShopController extends BaseController
|
|
|
util::complete();
|
|
|
}
|
|
|
|
|
|
+ //修改/批量修改门店终端号、到期时间、续费状态等信息
|
|
|
+ public function actionUpdate()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $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');
|
|
|
+ }
|
|
|
+
|
|
|
+ $shops = ShopClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
|
|
|
+ if (empty($shops)) {
|
|
|
+ util::fail('没有找到对应门店');
|
|
|
+ }
|
|
|
+
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ util::complete('修改成功');
|
|
|
+ }
|
|
|
+
|
|
|
//门店列表 ssh 20210730
|
|
|
public function actionList()
|
|
|
{
|
|
|
$where = [];
|
|
|
$name = Yii::$app->request->get('name', '');
|
|
|
if (!empty($name)) {
|
|
|
- if (stringUtil::isLetter($name)) {
|
|
|
+ if (is_numeric($name)) {
|
|
|
+ $where['mobile'] = ['like', $name];
|
|
|
+ } elseif (stringUtil::isLetter($name)) {
|
|
|
$where['py'] = ['like', $name];
|
|
|
} else {
|
|
|
$where['merchantName'] = ['like', $name];
|