Ver código fonte

Merge branch 'redesign‌-260706' into dev

ouyang 1 dia atrás
pai
commit
4b8c556bfe

+ 1 - 1
app-ghs/controllers/AuthController.php

@@ -919,7 +919,7 @@ class AuthController extends PublicController
     {
         $version = getenv('GHS_NEW_APK_VERSION') == false ? '100' : getenv('GHS_NEW_APK_VERSION');
         $mustUpdate = getenv('GHS_NEW_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('GHS_NEW_APK_VERSION_MUST_UPDATE');
-        $updateText = '零售系统上线升级';
+        $updateText = '挂账结清后,支持售后了';
         util::success(['version' => $version, 'mustUpdate' => $mustUpdate, 'updateText' => $updateText]);
     }
 

+ 3 - 3
app-ghs/controllers/ConsoleController.php

@@ -182,7 +182,7 @@ class ConsoleController extends BaseController
         //$notice[] = ['title' => '如果你发现一个问题很重要,一直没给你处理,在小群多反应几次,用反应次数强调重要性,目前批发店多反应问题多,都在排队。', 'action' => '', 'page' => ''];
         //$notice[] = ['title' => '新功能:客户端和后台使用跑腿的流程', 'action' => '', 'page' => '/admin/book/detail?id=use_pt'];
         //$notice[] = ['title' => '明年1月1号起,所有人介绍新批发店的分红政策,将会统一调整,请知悉', 'action' => '', 'page' => ''];
-        $notice[] = ['title' => '有急事请连续打二次电话 15280215347', 'action' => '', 'page' => ''];
+        //$notice[] = ['title' => '有急事请连续打二次电话 15280215347', 'action' => '', 'page' => ''];
 
         $mainId = $this->mainId;
         // 概况仍用 profile(订单数/支出等);收入数字与 kdIncome 对齐,见 index_show_income
@@ -322,8 +322,8 @@ class ConsoleController extends BaseController
 
         $warning = '';
         $warningUrl = '';
-        //$warning = '本页右上方,暂不显示昨天收入金额';
-        //$warningUrl = '/admin/notice/warning';
+        $warning = '挂账结清,支持售后了(重大更新,必看)';
+        $warningUrl = '/admin/notice/warning';
 
         util::success([
             'asset' => $this->main,

+ 24 - 0
app-mall/controllers/UserAddressController.php

@@ -2,14 +2,32 @@
 
 namespace mall\controllers;
 
+use bizMall\custom\classes\CustomClass;
 use common\components\util;
 use common\models\xhUserAddress;
 use Yii;
 
+/**
+ * 商城用户收货地址(xhUserAddress)
+ * 设为默认时同步回写同一 userId 下全部 xhCustom,保证各门店客户档案地址一致。
+ */
 class UserAddressController extends BaseController
 {
     public $guestAccess = [];
 
+    /**
+     * 默认地址落库后:按 userId 批量同步到 xhCustom
+     * @param int $userId 当前登录用户 id
+     * @param xhUserAddress $address 已保存的默认地址
+     */
+    private function syncCustomWhenDefault($userId, xhUserAddress $address)
+    {
+        if ((int)($address->default ?? 0) !== 1) {
+            return;
+        }
+        CustomClass::syncFromUserDefaultAddress($userId, $address);
+    }
+
     // 获取地址列表
     public function actionList()
     {
@@ -90,6 +108,8 @@ class UserAddressController extends BaseController
         }
 
         if ($model->save()) {
+            // 新建并勾选默认:同步到该用户全部门店客户档案
+            $this->syncCustomWhenDefault($user->id, $model);
             util::complete();
         } else {
             util::fail('保存失败');
@@ -131,6 +151,8 @@ class UserAddressController extends BaseController
         }
 
         if ($model->save()) {
+            // 保存为默认(含编辑默认地址内容):同步到该用户全部门店客户档案
+            $this->syncCustomWhenDefault($user->id, $model);
             util::complete();
         } else {
             util::fail('保存失败');
@@ -180,6 +202,8 @@ class UserAddressController extends BaseController
         $model->default = 1;
         
         if ($model->save()) {
+            // 列表「设为默认」:同步到该用户全部门店客户档案
+            $this->syncCustomWhenDefault($user->id, $model);
             util::complete();
         } else {
             util::fail('设置失败');

+ 1 - 1
biz-ghs/stat/classes/StatSaleClass.php

@@ -463,7 +463,7 @@ class StatSaleClass extends BaseClass
             ['name' => '零售', 'id' => 'ls', 'amount' => floatval($lsIncome)],
             ['name' => '调拨出库', 'id' => 'allot', 'amount' => floatval($stockOut)],
             // 采购隔天售后冲回(含退货并退款、仅退款);后续若细分再拆行
-            ['name' => '采购隔天退款', 'id' => 'cgNextDay', 'amount' => floatval($cgNextDayRefund)],
+            ['name' => '采购退款', 'id' => 'cgNextDay', 'amount' => floatval($cgNextDayRefund)],
         ];
         $expend = [
             ['name' => '批发运费', 'id' => 'pfSendCost', 'amount' => floatval($pfSendCost)],

+ 54 - 0
biz-mall/custom/classes/CustomClass.php

@@ -4,7 +4,61 @@ namespace bizMall\custom\classes;
 
 use bizMall\base\classes\BaseClass;
 
+/**
+ * 商城侧客户(xhCustom)业务类
+ * 用途:按 userId 维护多门店客户档案;默认收货地址回写等共用能力放这里。
+ */
 class CustomClass extends BaseClass
 {
     public static $baseFile = '\bizMall\custom\models\Custom';
+
+    /**
+     * 将商城默认收货地址同步到同一 userId 下全部 xhCustom
+     * 解决:用户在地址簿设默认后,各门店客户档案仍是旧地址,开单取不到最新收货信息。
+     *
+     * @param int $userId 用户 id(xhUser.id / xhCustom.userId)
+     * @param array|object $address 地址数据;phone 映射为 custom.mobile
+     * @return int 受影响行数(updateByCondition 返回值)
+     */
+    public static function syncFromUserDefaultAddress($userId, $address)
+    {
+        $userId = (int)$userId;
+        if ($userId <= 0 || empty($address)) {
+            return 0;
+        }
+        // 兼容 AR 模型与数组入参
+        $get = function ($key, $default = '') use ($address) {
+            if (is_array($address)) {
+                return $address[$key] ?? $default;
+            }
+            return isset($address->$key) ? $address->$key : $default;
+        };
+
+        $province = (string)$get('province', '');
+        $city = (string)$get('city', '');
+        $dist = (string)$get('dist', '');
+        $addr = (string)$get('address', '');
+        $floor = (string)$get('floor', '');
+        $fullAddress = (string)$get('fullAddress', '');
+        // 缺完整地址时按省市区+街道+门牌拼接,保证 xhCustom.fullAddress 可用
+        if ($fullAddress === '') {
+            $fullAddress = $province . $city . $dist . $addr . $floor;
+        }
+
+        $data = [
+            'name' => (string)$get('name', ''),
+            'mobile' => (string)$get('phone', $get('mobile', '')),
+            'province' => $province,
+            'city' => $city,
+            'dist' => $dist,
+            'address' => $addr,
+            'floor' => $floor,
+            'fullAddress' => $fullAddress,
+            'showAddress' => (string)$get('showAddress', ''),
+            'lat' => (string)$get('lat', ''),
+            'long' => (string)$get('long', ''),
+        ];
+
+        return self::updateByCondition(['userId' => $userId], $data);
+    }
 }

+ 24 - 0
sql/20260706_redesign.sql

@@ -454,3 +454,27 @@ WHERE t.ptStyle = 1
     SELECT 1 FROM xhCategorySetting cs
     WHERE cs.mainId = t.mainId AND cs.shopId = t.id
 );
+
+-- 原有收货地址同步到新收货地址
+START TRANSACTION;
+INSERT INTO xhUserAddress ( `userId`, `name`, `phone`, `lat`, `long`, `province`, `city`, `dist`, `address`, `floor`, `fullAddress`, `showAddress`, `default`, `tag`, `addTime`, `updateTime`)
+SELECT
+    c.userId, IFNULL(c.name, ''), IFNULL(c.mobile, ''), IFNULL(c.lat, ''), IFNULL(c.`long`, ''), IFNULL(c.province, ''), IFNULL(c.city, ''), IFNULL(c.dist, ''), IFNULL(c.address, ''), IFNULL(c.floor, ''), IFNULL(c.fullAddress, ''), IFNULL(c.showAddress, ''), 1 AS `default`, NULL AS tag, NOW() AS addTime, NOW() AS updateTime
+FROM xhCustom c INNER JOIN (
+    SELECTuserId, SUBSTRING_INDEX( GROUP_CONCAT( id ORDER BY
+          CASE
+            WHEN IFNULL(fullAddress, '') <> '' THEN 0
+            WHEN IFNULL(address, '') <> '' THEN 1
+            WHEN IFNULL(showAddress, '') <> '' THEN 2
+            ELSE 3
+          END, id ASC
+        SEPARATOR ',' ), ',', 1 ) + 0 AS pickId
+    FROM xhCustom
+    WHERE userId > 0
+      AND ( IFNULL(fullAddress, '') <> '' OR IFNULL(address, '') <> '' OR IFNULL(showAddress, '') <> '' )
+    GROUP BY userId
+) t ON c.id = t.pickId
+WHERE NOT EXISTS (
+    SELECT 1 FROM xhUserAddress a WHERE a.userId = c.userId
+);
+COMMIT;