| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687 |
- <?php
- namespace app\common\modules\shop;
- use app\frontend\modules\order\dispatch\ExpressOrderDispatchTypeMenu;
- class ShopConfig
- {
- /**
- * @var self
- */
- static $current;
- protected $items;
- /**
- * constructor.
- */
- public function __construct()
- {
- self::$current = $this;
- }
- static public function current()
- {
- if (!isset(self::$current)) {
- return new static();
- }
- return self::$current;
- }
- protected function _getItems()
- {
- $result = [
- 'plugin' => [
- [
- 'id' => 31,
- 'name' => 'cashier'
- ],
- [
- 'id' => 32,
- 'name' => 'store'
- ],
- [
- 'id' => 33,
- 'name' => 'hotel'
- ],
- [
- 'id' => 36,
- 'name' => 'hotel-cashier'
- ],
- [
- 'id' => 51,
- 'name' => 'provider-platform'
- ],
- [
- 'id' => 53,
- 'name' => 'tripartite-provider'
- ],
- [
- 'id' => 92,
- 'name' => 'supplier'
- ],
- [
- 'id' => 41,
- 'name' => 'net-car'
- ],
- [
- 'id' => 44,
- 'name' => 'jd-supply'
- ],
- [
- 'id' => 57,
- 'name' => 'product-market'
- ],
- [
- 'id' => 58,
- 'name' => 'market-sub'
- ],
- [
- 'id' => 60,
- 'name' => 'son-provider-platform'
- ],
- [
- 'id' => 61,
- 'name' => 'ys-system'
- ],
- [
- 'id' => 107,
- 'name' => 'blind-box'
- ],
- [
- 'id' => 71,
- 'name' => 'aggregation-cps'
- ],
- [
- 'id' => 113,
- 'name' => 'store-projects'
- ],
- [
- 'id' => 120,
- 'name' => 'yz-supply'
- ],
- [
- 'id' => 144,
- 'name' => 'coupon-store'
- ],
- ],
- 'observer' => [
- 'goods' => [
- 'sale' => [
- 'class' => 'app\backend\modules\goods\models\Sale',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'notice' => [
- 'class' => 'app\backend\modules\goods\models\Notice',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'share' => [
- 'class' => 'app\backend\modules\goods\models\Share',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'privilege' => [
- 'class' => 'app\backend\modules\goods\models\Privilege',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'discount' => [
- 'class' => 'app\backend\modules\goods\models\Discount',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'dispatch' => [
- 'class' => 'app\backend\modules\goods\models\GoodsDispatch',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'coupon' => [
- 'class' => 'app\backend\modules\goods\models\Coupon',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'div_from' => [
- 'class' => 'app\backend\modules\goods\models\DivFrom',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'filtering' => [
- 'class' => 'app\backend\modules\goods\models\GoodsFiltering',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'limitbuy' => [
- 'class' => 'app\backend\modules\goods\models\LimitBuy',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'advertising' => [
- 'class' => 'app\backend\modules\goods\models\Advertising',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'invite_page' => [
- 'class' => 'app\backend\modules\goods\models\InvitePage',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'service' => [
- 'class' => 'app\backend\modules\goods\models\GoodsService',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'video' => [
- 'class' => 'app\backend\modules\goods\models\GoodsVideo',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'spec_info' => [
- 'class' => 'app\backend\modules\goods\models\GoodsSpecInfo',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- 'trade_set' => [
- 'class' => 'app\backend\modules\goods\models\GoodsTradeSet',
- 'function_validator' => 'relationValidator',
- 'function_save' => 'relationSave'
- ],
- ],
- 'order' => [
- //订单操作记录
- 'order_operation_log' => [
- 'class' => 'app\backend\modules\order\models\OrderOperationLog',
- 'function_save' => 'insertOperationLog'
- ]
- ]
- ],
- 'goods' => [
- 'models' => [
- 'home_page' => \app\common\models\Goods::class,
- 'goods_info' => \app\common\models\Goods::class,
- 'goods_list' => \app\common\models\Goods::class,
- 'footprint' => \app\common\models\Goods::class,
- 'collection_page' => \app\common\models\Goods::class,
- 'commodity_classification' => \app\common\models\Goods::class,
- ],
- 'GoodsMemberLevelDiscountCalculator' => [
- 'goods' => \app\common\modules\discount\GoodsMemberLevelDiscountCalculator::class,
- 'shop' => \app\common\modules\discount\ShopGoodsMemberLevelDiscountCalculator::class
- ],
- ],
- 'shop-foundation' => [
- 'goods' => [
- 'dealPrice' => [
- [
- 'key' => 'goodsDealPrice',
- 'class' => function (\app\common\models\Goods $goods, $param = []) {
- return new \app\common\modules\goods\dealPrice\GoodsDealPrice($goods);
- },
- ], [
- 'key' => 'marketDealPrice',
- 'class' => function (\app\common\models\Goods $goods, $param = []) {
- return new \app\common\modules\goods\dealPrice\MarketDealPrice($goods);
- },
- ]
- ],
- //标准商城默认都会显示下面这几种类型的商品
- 'plugin' => [0],
- //下单不会扣除库存的订单类型
- //128 = 圈仓插件
- //56 = 云仓插件
- 'no-deduct-stock' => [56,128],
- ],
- //订单列表类型区分
- 'order-list' => [
- 'type' => [
- [
- 'priority' => 0,
- 'view' => \app\backend\modules\order\services\type\ShopOrderView::class,
- 'class' => function (\app\common\models\Order $order) {
- return new \app\backend\modules\order\services\type\ShopOrder($order);
- },
- ],
- ],
- 'top-row'=> [],
- ],
- 'member-cart' => [
- 'validate' => [], //下单插件验证商品
- 'with' => [],
- 'models' => [
- 'shop' => \app\frontend\models\MemberCart::class,
- ],
- ],
- 'refund' => [
- 'order-type' => [], //申请售后订单类型
- ],
- 'model' => [
- 'PreOrder' => []
- ],
- 'model-expansions' => [\app\frontend\models\Goods::class => [
- \Yunshop\Love\Frontend\Models\Expansions\GoodsExpansions::class,
- \Yunshop\AreaDividend\models\expansions\GoodsExpansions::class,
- \Yunshop\Supplier\common\models\expansions\GoodsExpansions::class
- ]],
- 'order' => ['member_order_operations' => [//todo 配置已移至 app/common/modules/shop/OrderFrontendButtonConfig.php
- 'waitPay' => [
- \app\frontend\modules\order\operations\member\Pay::class,
- \app\frontend\modules\order\operations\member\Close::class,
- ],
- 'waitSend' => [
- \app\frontend\modules\order\operations\member\ApplyRefund::class,
- \app\frontend\modules\order\operations\member\ContactCustomerService::class,
- \app\frontend\modules\order\operations\member\Refunding::class,
- \app\frontend\modules\order\operations\member\Refunded::class,
- \app\frontend\modules\order\operations\member\Coupon::class, //分享优惠卷
- \app\frontend\modules\order\operations\member\ExpeditingDelivery::class, //催发货
- ],
- 'waitReceive' => [
- \app\frontend\modules\order\operations\member\ExpressInfo::class,
- \app\frontend\modules\order\operations\member\Receive::class,
- \app\frontend\modules\order\operations\member\ApplyRefund::class,
- \app\frontend\modules\order\operations\member\ContactCustomerService::class,
- \app\frontend\modules\order\operations\member\Refunding::class,
- \app\frontend\modules\order\operations\member\Refunded::class,
- \app\frontend\modules\order\operations\member\Coupon::class, //分享优惠卷
- ],
- 'complete' => [
- \app\frontend\modules\order\operations\member\ExpressInfo::class,
- \app\frontend\modules\order\operations\member\Delete::class,
- \app\frontend\modules\order\operations\member\ApplyRefund::class,
- \app\frontend\modules\order\operations\member\ContactCustomerService::class,
- \app\frontend\modules\order\operations\member\Refunding::class,
- \app\frontend\modules\order\operations\member\Refunded::class,
- \app\frontend\modules\order\operations\member\CheckInvoice::class,
- \app\frontend\modules\order\operations\member\Coupon::class, //分享优惠卷
- \app\frontend\modules\order\operations\member\ViewEquity::class, //查看卡券
- ],
- 'close' => [
- \app\frontend\modules\order\operations\member\ExpressInfo::class,
- \app\frontend\modules\order\operations\member\Delete::class,
- \app\frontend\modules\order\operations\member\Refunded::class,
- ],
- ], 'status' => [
- 0 => 'waitPay',
- 1 => 'waitSend',
- 2 => 'waitReceive',
- 3 => 'complete',
- -1 => 'close',
- ],
- ],
- 'order-dispatch-save' => [
- 'dispatch' => \app\frontend\modules\order\dispatch\order\ExpressOrderDispatchType::class
- ],
- 'order-dispatch-menu' => [
- 'shop' => [ //标准商城配送方式
- 'dispatch' => ExpressOrderDispatchTypeMenu::class
- ],
- ],
- 'order-fee' => [],
- 'order-service-fee' => [],
- 'order-tax-fee' => [],
- 'goods-tax-fee' => [],
- 'status' => [
- [
- 'key' => 'remittance',
- 'class' => \app\common\modules\payType\remittance\models\status\RemittanceStatus::class,
- ],
- [
- 'key' => 'remittanceAudit',
- 'class' => \app\common\modules\payType\remittance\models\status\RemittanceAuditStatus::class,
- ],
- ],
- 'order-freight' => [
- [
- 'weight' => 1000,
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder, $weight) {
- return new \app\frontend\modules\dispatch\freight\ShopFreight($preOrder, $weight);
- },
- ],
- // [
- // 'weight' => 1000,
- // 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder, $weight) {
- // return new \app\frontend\modules\dispatch\freight\TemplateFreight($preOrder, $weight);
- // },
- // ], [
- // 'weight' => 1010,
- // 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder, $weight) {
- // return new \app\frontend\modules\dispatch\freight\UnifyFreight($preOrder, $weight);
- // },
- // ],
- ],
- 'order-freight-discount' => [
- [
- 'priority' => 0, //优惠项权重
- 'type' => 'enoughReduce',//分组
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\dispatch\discount\EnoughReduce($preOrder);
- }
- ],
- [
- 'priority' => 0,
- 'type' => 'levelFreeFreight',
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\dispatch\discount\LevelFreeFreight($preOrder);
- }
- ],
- ],
- 'goods-discount' => [
- [
- 'weight' => 2000,
- 'class' => function (\app\frontend\modules\orderGoods\models\PreOrderGoods $preOrderGoods) {
- return new \app\frontend\modules\orderGoods\discount\MemberLevel($preOrderGoods);
- },
- ],
- [
- 'weight' => 2010,
- 'class' => function (\app\frontend\modules\orderGoods\models\PreOrderGoods $preOrderGoods) {
- return new \app\frontend\modules\orderGoods\discount\SingleEnoughReduce($preOrderGoods);
- },
- ],
- [
- 'weight' => 2010,
- 'class' => function (\app\frontend\modules\orderGoods\models\PreOrderGoods $preOrderGoods) {
- return new \app\frontend\modules\orderGoods\discount\FullPiece($preOrderGoods);
- },
- ], [
- 'weight' => 2020,
- 'class' => function (\app\frontend\modules\orderGoods\models\PreOrderGoods $preOrderGoods) {
- return new \app\frontend\modules\orderGoods\discount\EnoughReduce($preOrderGoods);
- },
- ], [
- 'weight' => 2100,
- 'class' => function (\app\frontend\modules\orderGoods\models\PreOrderGoods $preOrderGoods) {
- return new \app\frontend\modules\orderGoods\discount\Coupon($preOrderGoods);
- },
- ],
- ],
- 'coin-exchange' => [
- ],
- 'coupon' => [
- 'OrderCoupon' => [
- 'scope' => [
- [
- 'key' => \app\common\models\Coupon::COUPON_GOODS_USE,
- 'class' => function ($coupon) {
- return new \app\frontend\modules\coupon\services\models\UseScope\GoodsScope($coupon);
- },
- ],
- [
- 'key' => \app\common\models\Coupon::COUPON_CATEGORY_USE,
- 'class' => function ($coupon) {
- return new \app\frontend\modules\coupon\services\models\UseScope\CategoryScope($coupon);
- },
- ],
- [
- 'key' => \app\common\models\Coupon::COUPON_SHOP_USE,
- 'class' => function ($coupon) {
- return new \app\frontend\modules\coupon\services\models\UseScope\ShopScope($coupon);
- },
- ],
- [
- 'key' => \app\common\models\Coupon::COUPON_GOODS_AND_STORE_USE,
- 'class' => function ($coupon) {
- return new \app\frontend\modules\coupon\services\models\UseScope\GoodsAndStoreScope($coupon);
- },
- ],
- ]
- ]
- ], 'discount' => [
- 'GoodsMemberLevelDiscountCalculator' => [
- [
- 'priority' => '1000',
- 'key' => 'goods',
- 'class' => function ($goods, $member) {
- $class = \app\common\modules\shop\ShopConfig::current()->get('goods.GoodsMemberLevelDiscountCalculator.goods');
- return new $class($goods, $member);
- }
- ],
- [
- 'priority' => '2000',
- 'key' => 'shop',
- 'class' => function ($goods, $member) {
- $class = \app\common\modules\shop\ShopConfig::current()->get('goods.GoodsMemberLevelDiscountCalculator.shop');
- return new $class($goods, $member);
- }
- ],
- ]
- ], 'goods-option' => [
- 'dealPrice' => [
- [
- 'key' => 'goodsDealPrice',
- 'class' => function (\app\common\models\GoodsOption $goodsOption, $param = []) {
- return new \app\common\modules\goodsOption\dealPrice\GoodsDealPrice($goodsOption);
- },
- ], [
- 'key' => 'marketDealPrice',
- 'class' => function (\app\common\models\GoodsOption $goodsOption, $param = []) {
- return new \app\common\modules\goodsOption\dealPrice\MarketDealPrice($goodsOption);
- },
- ]
- ]
- ], 'order-discount' => [
- [
- 'key' => 'memberLevel',
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\order\discount\MemberLevel($preOrder);
- },
- ],
- [
- 'key' => 'singleEnoughReduce',
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\order\discount\SingleEnoughReduce($preOrder);
- },
- ], [
- 'key' => 'fullPiece',
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\order\discount\FullPiece($preOrder);
- },
- ],[
- 'key' => 'enoughReduce',
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\order\discount\EnoughReduce($preOrder);
- },
- ],
- [
- 'key' => 'couponDiscount',
- 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- return new \app\frontend\modules\order\discount\CouponDiscount($preOrder);
- },
- ],
- // [
- // 'key' => 'singleEnoughReduce',
- // 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- // return new \app\frontend\modules\order\discount\SingleEnoughReduce($preOrder);
- // },
- // ], [
- // 'key' => 'enoughReduce',
- // 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- // return new \app\frontend\modules\order\discount\EnoughReduce($preOrder);
- // },
- // ],
- // [
- // 'key' => 'couponDiscount',
- // 'class' => function (\app\frontend\modules\order\models\PreOrder $preOrder) {
- // return new \app\frontend\modules\order\discount\CouponDiscount($preOrder);
- // },
- // ]
- ], 'order-price-nodes' => [
- [
- 'class' => function (\app\frontend\modules\order\models\PreOrder $order) {
- return new \app\frontend\modules\order\OrderGoodsPriceNode($order, 1000);
- },
- ],
- [
- 'class' => function (\app\frontend\modules\order\models\PreOrder $order) {
- return new \app\frontend\modules\order\OrderDispatchPriceNode($order, 3000);
- },
- ],
- [
- 'class' => function (\app\frontend\modules\order\models\PreOrder $order) {
- return new \app\frontend\modules\order\OrderTaxFeePriceNode($order, 9200);
- },
- ],
- [
- 'class' => function (\app\frontend\modules\order\models\PreOrder $order) {
- return new \app\frontend\modules\order\OrderFeeNode($order, 9998);
- },
- ],
- [
- 'class' => function (\app\frontend\modules\order\models\PreOrder $order) {
- return new \app\frontend\modules\order\OrderServiceFeeNode($order, 9999);
- },
- ]
- ], 'deduction' => [
- 'enable' => true
- ],
- 'send_back_way' => [
- 'self_send' => '\app\frontend\modules\refund\services\back_way_operation\SelfSend',
- ]
- ],
- 'queue' => [
- ['key' => 'default',
- 'total' => 3,
- 'name' => '默认',
- 'option' => [],
- 'is_serial' => false
- ], ['key' => 'message',
- 'total' => 3,
- 'name' => '消息',
- 'option' => [],
- 'is_serial' => false
- ], ['key' => 'order',
- 'total' => 3,
- 'name' => '订单',
- 'option' => [],
- 'is_serial' => true
- ], [
- 'key' => 'statistics',
- 'total' => 3,
- 'name' => '统计',
- 'option' => [],
- 'is_serial' => false
- ], [
- 'key' => 'limit',
- 'total' => 3,
- 'name' => '限定',
- 'option' => [],
- 'is_serial' => true
- ],
- ],
- 'password' => [
- 'balance' => [
- 'code' => 'balance',
- 'name' => '余额设置',
- 'condition' => [
- [
- 'key' => 'pay',
- 'name' => '余额支付'
- ],
- [
- 'key' => 'transfer',
- 'name' => '余额转让'
- ],
- [
- 'key' => 'withdraw',
- 'name' => '余额提现'
- ]
- ]
- ],
- 'point' => [
- 'code' => 'point',
- 'name' => '积分设置',
- 'condition' => [
- [
- 'key' => 'transfer',
- 'name' => '积分转让'
- ]
- ]
- ],
- ],
- 'data-clear' => [//商城设置-数据清理
- ]
- ];
- $plugins = app('plugins')->getEnabledPlugins('*');
- foreach ($plugins as $plugin) {
- foreach ($plugin->app()->getShopConfigItems() as $key => $item) {
- array_set($result, $key, $item);
- }
- }
- return $result;
- }
- protected function getItems()
- {
- if (!isset($this->items)) {
- $this->items = $this->_getItems();
- }
- return $this->items;
- }
- public function getItem($key)
- {
- return array_get($this->getItems(), $key);
- }
- public function clear()
- {
- $this->items = null;
- }
- public function get($key = null)
- {
- if (empty($key)) {
- return $this->getItems();
- }
- return $this->getItem($key);
- }
- public function set($key, $value = null)
- {
- $items = $this->getItems();
- if (is_array($key)) {
- foreach ($key as $k => $v) {
- array_set($items, $k, $v);
- }
- } else {
- array_set($items, $key, $value);
- }
- $this->items = $items;
- }
- public function push($key, $value)
- {
- $all = $this->getItems();
- $array = $this->getItem($key) ?: [];
- $array[] = $value;
- array_set($all, $key, $array);
- $this->items = $all;
- }
- public function unshift($key, $value)
- {
- $all = $this->getItems();
- $array = $this->getItem($key) ?: [];
- array_unshift($array, $value);
- array_set($all, $key, $array);
- $this->items = $all;
- }
- }
|