quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
 
namespace app\operations\model\settings;
 
use app\common\model\settings\DeliveryRule as DeliveryRuleModel;
 
/**
 * 配送模板区域及运费模型
 */
class DeliveryRule extends DeliveryRuleModel
{
//    protected $append = ['region_content'];
//
//    static $regionAll;
//    static $regionTree;
//
//    /**
//     * 可配送区域
//     */
//    public function getRegionContentAttr($value, $data)
//    {
//        // 当前区域记录转换为数组
//        $regionIds = explode(',', $data['region']);
//
//        if (count($regionIds) === 373) return '全国';
//
//        // 所有地区
//        if (empty(self::$regionAll)) {
//            self::$regionAll = Region::getCacheAll();
//            self::$regionTree = Region::getCacheTree();
//        }
//        // 将当前可配送区域格式化为树状结构
//        $alreadyTree = [];
//        foreach ($regionIds as $regionId)
//            $alreadyTree[self::$regionAll[$regionId]['pid']][] = $regionId;
//        $str = '';
//        foreach ($alreadyTree as $provinceId => $citys) {
//            $str .= self::$regionTree[$provinceId]['name'];
//            if (count($citys) !== count(self::$regionTree[$provinceId]['city'])) {
//                $cityStr = '';
//                foreach ($citys as $cityId)
//                    $cityStr .= self::$regionTree[$provinceId]['city'][$cityId]['name'];
//                $str .= ' (<span class="am-link-muted">' . mb_substr($cityStr, 0, -1, 'utf-8') . '</span>)';
//            }
//            $str .= '、';
//        }
//        return mb_substr($str, 0, -1, 'utf-8');
//    }
 
}