Просмотр исходного кода

Merge branch 'redesign‌-260706' of git.huaml.com:zhh/huahuibao into redesign‌-260706

shizhongqi 2 дней назад
Родитель
Сommit
0df7b6e90e

+ 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]);
     }
 

+ 5 - 0
app-ghs/controllers/CgRefundController.php

@@ -111,6 +111,11 @@ class CgRefundController extends BaseController
         if ($status > -1) {
             $where['status'] = $status;
         }
+        // sameDay:-1全部 1当天售后 0隔天售后(与销售售后列表对齐)
+        $sameDay = isset($get['sameDay']) ? intval($get['sameDay']) : -1;
+        if ($sameDay === 0 || $sameDay === 1) {
+            $where['sameDay'] = $sameDay;
+        }
 
         $export = $get['export'] ?? 0;
         if ($export == 1) {

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

@@ -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,

+ 10 - 5
app-ghs/controllers/PurchaseClearController.php

@@ -37,7 +37,7 @@ class PurchaseClearController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
             if (in_array($this->mainId, [23390, 24516])) {
-                if (!in_array($this->adminId, [24655,77951])) {
+                if (!in_array($this->adminId, [24655, 77951])) {
                     util::fail('不能操作哈');
                 }
             }
@@ -55,7 +55,7 @@ class PurchaseClearController extends BaseController
             }
             //淘花里小榄店 thl_xl_clear
             if (in_array($this->shopId, [72366])) {
-                if (!in_array($this->adminId, [69792,55445,55707,69792])) {
+                if (!in_array($this->adminId, [69792, 55445, 55707, 69792])) {
                     util::fail('你不能销单那。。。');
                 }
             }
@@ -67,12 +67,12 @@ class PurchaseClearController extends BaseController
             }
             //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
             if (in_array($this->shopId, [41467, 42946])) {
-                if (!in_array($this->adminId, [40144,42912,42023])) {
+                if (!in_array($this->adminId, [40144, 42912, 42023])) {
                     util::fail('不能操作哈。。');
                 }
             }
             //恋善好多花控制销账权限
-            if (in_array($this->shopId, [55238,56609,56611])) {
+            if (in_array($this->shopId, [55238, 56609, 56611])) {
                 if (!in_array($this->adminId, [43856, 54620])) {
                     util::fail('暂无权限,请联系老板或财务');
                 }
@@ -94,6 +94,11 @@ class PurchaseClearController extends BaseController
         $shopAdminName = $shopAdmin['name'] ?? '';
         $post['customShopAdminName'] = $shopAdminName;
 
+        $apiVersion = $post['apiVersion'] ?? 0;
+        if ($apiVersion < 1) {
+            util::fail('请先升级app或小程序');
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
@@ -107,4 +112,4 @@ class PurchaseClearController extends BaseController
         }
     }
 
-}
+}

+ 2 - 1
app-ghs/controllers/TestController.php

@@ -490,7 +490,8 @@ class TestController extends BaseController
             //['name' => '东莞丰行', 'merchantNo' => '8226020599200RW', 'wx' => [909917474, 909917851], 'zfb' => '2088780774491467'],
             //['name' => '商丘花鲜谷鲜花', 'merchantNo' => '82250605992009Q', 'wx' => [911392567, 911392641], 'zfb' => '2088780883539375'],
             //['name' => '东莞我要花', 'merchantNo' => '8226020599200S3', 'wx' => [913207533, 913206368], 'zfb' => '2088880020992882'],
-            ['name' => '深圳福田天天鲜花', 'merchantNo' => '82258405992022M', 'wx' => [915397806, 915397601], 'zfb' => '2088880200936882'],
+            //['name' => '深圳福田天天鲜花', 'merchantNo' => '82258405992022M', 'wx' => [915397806, 915397601], 'zfb' => '2088880200936882'],
+            ['name' => '昆明藏花林', 'merchantNo' => '82252105992011Z', 'wx' => [917884924, 917883992], 'zfb' => '2088880449061387'],
             //['name' => '中山淘花里小榄店', 'merchantNo' => '8226030599200D5', 'wx' => [911061554, 911061963], 'zfb' => '2088780851935068'],
             //['name' => '重庆大金地', 'merchantNo' => '8226900599201GA', 'wx' => [910648990, 910644127], 'zfb' => '2088780830897617'],
             //['name' => '云南珑松珠海店', 'merchantNo' => '82258505992009Q', 'wx' => [910384498, 910385532], 'zfb' => '2088780804010303'],

+ 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
app-pt/views/main/app.php

@@ -235,7 +235,7 @@
             }
             // 这里可以根据appType跳转到对应的下载链接
             const downloadUrls = {
-                'xiaohuabao': 'https://api.shop.hzghd.com/1320.apk', // 销花宝APP下载链接
+                'xiaohuabao': 'https://api.shop.hzghd.com/1326.apk', // 销花宝APP下载链接
                 'huazhanggui': 'https://api.shop.hzghd.com/246.apk', // 花掌柜APP下载链接
                 'huazhanggui_cashier': 'https://api.shop.hzghd.com/220.apk', // 花掌柜收银下载链接
                 'xiaohuabao_cashier': 'https://api.shop.hzghd.com/178.apk' // 销花宝收银下载链接

+ 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);
+    }
 }

+ 43 - 2
biz-mall/order/classes/OrderGoodsClass.php

@@ -3,6 +3,7 @@
 namespace bizMall\order\classes;
 
 use common\components\business;
+use common\components\imgUtil;
 use common\components\util;
 use Yii;
 use bizMall\base\classes\BaseClass;
@@ -100,19 +101,59 @@ class OrderGoodsClass extends BaseClass
     }
 
     //批量取订单 ssh 2020.1.2
+    /**
+     * 按订单号批量取花束明细,供订单列表组装 goodsInfoList
+     * @param array $sns 订单号列表
+     * @return array [orderSn => [goods...]]
+     */
     public static function getGoodsListByOrderSns($sns)
     {
+        $sns = array_values(array_filter(array_unique((array)$sns)));
+        if (empty($sns)) {
+            return [];
+        }
         $arr = self::getAllByCondition(['orderSn' => ['in', $sns]], null, '*');
         if (empty($arr)) {
             return [];
         }
         $data = [];
         foreach ($arr as $info) {
-            $orderSn = $info['orderSn'];
-            $info = business::formatOrderGoodsCover($info);
+            $orderSn = $info['orderSn'] ?? '';
+            if ($orderSn === '' || $orderSn === null) {
+                continue;
+            }
+            // 封面字段与花材明细、列表组件对齐(smallCoverUrl / cover / coverUrl)
+            $info = self::formatGoodsCover($info);
             $data[$orderSn][] = $info;
         }
         return $data;
     }
 
+    /**
+     * 处理花束订单明细封面,兼容列表与详情展示字段
+     * @param array $info 明细行
+     * @return array
+     */
+    private static function formatGoodsCover($info)
+    {
+        $info = business::formatOrderGoodsCover($info);
+        $shortCover = !empty($info['cover']) ? $info['cover'] : (!empty($info['shortCover']) ? $info['shortCover'] : 'hhb_small.png');
+        // formatOrderGoodsCover 可能已把 coverUrl 填好,但 cover 仍是短路径;列表优先读 smallCoverUrl/cover
+        if (!empty($info['coverUrl'])) {
+            $info['shortCover'] = $shortCover;
+            $info['cover'] = $info['coverUrl'];
+            if (empty($info['smallCoverUrl'])) {
+                $info['smallCoverUrl'] = $info['coverUrl'] . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+            }
+            $info['smallCover'] = $info['smallCoverUrl'];
+            return $info;
+        }
+        $info['shortCover'] = $shortCover;
+        $info['cover'] = imgUtil::groupImg($shortCover);
+        $info['smallCover'] = $info['cover'] . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+        $info['coverUrl'] = $info['cover'];
+        $info['smallCoverUrl'] = $info['smallCover'];
+        return $info;
+    }
+
 }

+ 6 - 13
biz-mall/order/services/OrderService.php

@@ -240,28 +240,21 @@ class OrderService extends BaseService
             $hdMap = HdClass::getByIds($hdIds, null, 'id');
         }
         $orderSns = array_values(array_filter(array_unique(array_column($list, 'orderSn'))));
-        // 花束订单明细在 xhOrderGoods,花材订单明细在 xhOrderItem,orderType=3 时两者都有
+        // 花束明细在 xhOrderGoods,花材明细在 xhOrderItem;列表按实际明细合并,避免 orderType=0/错标导致空列表
         $goodsListMap = OrderGoodsService::getGoodsListByOrderSns($orderSns);
         $itemListMap = OrderItemService::getItemListByOrderSns($orderSns);
         $periodData = [0 => '上午', 1 => '下午', 2 => '晚上'];
         foreach ($data['list'] as $key => $val) {
             $orderSn = $val['orderSn'] ?? '';
-            $orderType = intval($val['orderType'] ?? 1);
             $hdId = intval($val['hdId'] ?? 0);
             $orderStatus = intval($val['status'] ?? 0);
             $data['list'][$key]['hdName'] = $hdMap[$hdId]['name'] ?? '';
             $data['list'][$key]['statusDesc'] = OrderStatusUtil::getSystemStatusDesc($orderStatus);
-            $goodsInfoList = [];
-            if (!empty($orderSn)) {
-                if ($orderType == 1) {
-                    $goodsInfoList = $goodsListMap[$orderSn] ?? [];
-                } elseif ($orderType == 2) {
-                    $goodsInfoList = $itemListMap[$orderSn] ?? [];
-                } elseif ($orderType == 3) {
-                    $goodsInfoList = array_merge($goodsListMap[$orderSn] ?? [], $itemListMap[$orderSn] ?? []);
-                }
-            }
-            if(isset($val['goodsNum']) && $val['goodsNum'] == 0) {
+            $fromGoods = (!empty($orderSn) && isset($goodsListMap[$orderSn])) ? $goodsListMap[$orderSn] : [];
+            $fromItems = (!empty($orderSn) && isset($itemListMap[$orderSn])) ? $itemListMap[$orderSn] : [];
+            // 有啥展示啥:纯花束/纯花材/混合都能出图;orderType 仅作业务标记,不作为列表组装门槛
+            $goodsInfoList = array_merge($fromGoods, $fromItems);
+            if (isset($val['goodsNum']) && $val['goodsNum'] == 0) {
                 $data['list'][$key]['goodsNum'] = count($goodsInfoList);
             }
             $data['list'][$key]['goodsInfoList'] = $goodsInfoList;

+ 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;