init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
155
Application/Common/Setting/Diy.class.php
可执行文件
155
Application/Common/Setting/Diy.class.php
可执行文件
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace Common\Setting;
|
||||
|
||||
use Common\Business\Plug;
|
||||
use Common\Model\RetailPlugModel;
|
||||
use Common\Model\RetailStoreXcxConfigModel;
|
||||
use Common\Model\StoreConfigModel;
|
||||
|
||||
use Common\Model\StoreJurisdictionModel;//门店操作权限表
|
||||
use Common\Model\MerchantConfigModel;//商户基本配置表
|
||||
|
||||
//[1.8.50]
|
||||
|
||||
/**
|
||||
* DIY商城设置类
|
||||
* Class Diy
|
||||
* @package Common\Setting
|
||||
*/
|
||||
class Diy
|
||||
{
|
||||
private $store_id;
|
||||
private $merchant_id;
|
||||
|
||||
public function __construct($store_id, $merchant_id)
|
||||
{
|
||||
$this->store_id = $store_id;
|
||||
$this->merchant_id = $merchant_id;
|
||||
}
|
||||
|
||||
public function getDiy()
|
||||
{
|
||||
$merchantId = $this->merchant_id;//商户id
|
||||
|
||||
$merchantConfigModel = new MerchantConfigModel();
|
||||
$merchantDiy = $merchantConfigModel->getFindField(array('merchant_id' => $merchantId), 'merchant_diy');
|
||||
|
||||
$storeJurisdictionModel = new StoreJurisdictionModel();
|
||||
$home_diy = $storeJurisdictionModel->getFindField(array('storeid' => $this->store_id), 'home_diy');
|
||||
if($home_diy == 2){
|
||||
//门店不可以使用自己的DIY设置,使用商户的DIY设置
|
||||
$diy_mall_data = $merchantDiy;
|
||||
$res['store_merchant'] = 2;//1是门店,2是商户
|
||||
}else{
|
||||
//门店可以使用自己的DIY设置,如果门店没设置,用商户DIY。
|
||||
//读取缓存中的DIY设置
|
||||
$diy_mall_data = S('diy_mall_data' . $this->store_id);
|
||||
if (empty($diy_mall_data)) {
|
||||
//不存在,则重新获取并存储
|
||||
$StoreConfigModel = new StoreConfigModel();
|
||||
$diy_mall_data = $StoreConfigModel->getFindField(array('store_id' => $this->store_id), 'diy_mall_data');
|
||||
if (!empty($diy_mall_data)) {
|
||||
S('diy_mall_data' . $this->store_id, $diy_mall_data);
|
||||
}
|
||||
}
|
||||
$store_diy = I('post.store_diy');
|
||||
if(isset($store_diy) && $store_diy == 1){
|
||||
//强制获取门店DIY,编辑
|
||||
$res['store_merchant'] = 1;//1是门店,2是商户
|
||||
}else{
|
||||
$diy_mall_data = $diy_mall_data ? $diy_mall_data : $merchantDiy;
|
||||
$res['store_merchant'] = $diy_mall_data ? 1: 2;//1是门店,2是商户
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//实例化插件模型
|
||||
$PlugModel = new RetailPlugModel();
|
||||
|
||||
//获取门店插件权限
|
||||
$plug_store = $PlugModel->getStorePlugState($this->store_id);
|
||||
|
||||
//实例化门店基本设置模型
|
||||
$StoreXcxConfigModel = new RetailStoreXcxConfigModel();
|
||||
$field = array(
|
||||
'group_status', //拼团状态
|
||||
'seckill_status', //秒杀状态
|
||||
'advance_sale_status', //预售状态
|
||||
'promotion_status', //促销状态
|
||||
);
|
||||
|
||||
//获取插件首页展示状态
|
||||
$xcx_status = $StoreXcxConfigModel->getFind(array('storeid' => $this->store_id), $field);
|
||||
|
||||
if ($xcx_status['group_status'] != 1) {
|
||||
$plug_store['group_state'] = 0;
|
||||
}
|
||||
if ($xcx_status['seckill_status'] != 1) {
|
||||
$plug_store['seckill_state'] = 0;
|
||||
}
|
||||
if ($xcx_status['advance_sale_status'] != 1) {
|
||||
$plug_store['advance_state'] = 0;
|
||||
}
|
||||
|
||||
//处理促销状态
|
||||
$plug_store['promotion_state'] = $xcx_status['promotion_status'] == 1 ? 1 : 0;
|
||||
|
||||
//获取商户礼品卡插件状态
|
||||
$map = array(
|
||||
'p.identification' => 'giftcard', //礼品卡
|
||||
'm.status' => 1,
|
||||
'm.merchant_id' => $this->merchant_id,
|
||||
);
|
||||
$gift_state = $PlugModel->getGiftStatus($map, 'm.m_status');
|
||||
$plug_store['gift_state'] = $gift_state && $gift_state['m_status'] == 1 ? 1 : 0;
|
||||
|
||||
//实例化插件类
|
||||
$PlugApi = new Plug();
|
||||
|
||||
//获取付费插件列表及状态
|
||||
$result = $PlugApi->PlugPermissions(array(
|
||||
'merchant_id' => $this->merchant_id,
|
||||
'identification_arr' => ['shopcoupon', 'wxpaycoupon', 'malldistribution']
|
||||
));
|
||||
|
||||
//处理优惠券、商家券、代金券插件
|
||||
$plug_store['coupon'] = array(
|
||||
array('name' => '优惠券', 'type' => 1, 'status' => 1),
|
||||
array('name' => '商家券', 'type' => 2, 'status' => (isset($result['data']['plug']['shopcoupon']) && $result['data']['plug']['shopcoupon'] > 0) ? 1 : 0),
|
||||
array('name' => '代金券', 'type' => 3, 'status' => (isset($result['data']['plug']['wxpaycoupon']) && $result['data']['plug']['wxpaycoupon'] > 0) ? 1 : 0),
|
||||
);
|
||||
|
||||
//处理分销插件
|
||||
$plug_store['distribution_state'] = (isset($result['data']['plug']['malldistribution']) && $result['data']['plug']['malldistribution'] > 0) ? 1 : 0;
|
||||
|
||||
if ($plug_store['distribution_state'] == 1) {
|
||||
$uid = I('post.uid');
|
||||
$DistributorModel = new \Distribution\Model\DistributorModel();
|
||||
$isDistributor = $DistributorModel->getFind(['merchant_id' => $this->merchant_id, 'uid' => $uid, 'status' => 0]);
|
||||
if ($isDistributor) {
|
||||
$res['isDistributor'] = 1;
|
||||
$DistriGradeModel = new \Distribution\Model\GradeModel();
|
||||
$res['distributorProp'] = $DistriGradeModel->getFindField(['id' => $isDistributor['grade_level_id']], 'proportion');
|
||||
} else {
|
||||
$res['isDistributor'] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
//无论是否设置DIY,都返回插件权限
|
||||
$res['plug_state'] = $plug_store;
|
||||
|
||||
$MerchantConfigModel = D('RetailMerchantConfig');
|
||||
$MerchantConfig = $MerchantConfigModel->getConfig($merchantId);
|
||||
$res['vip_register_state'] = $MerchantConfig['vip_register_state'] == 1 ? 1 : 0;//引导成为常规会员 0关闭1开启
|
||||
$res['plus_register_state'] = $MerchantConfig['plus_register_state'] == 1 ? 1 : 0;//引导成为/续费PLUS会员 0关闭1开启
|
||||
|
||||
if (!empty($diy_mall_data)) {
|
||||
$msg = '获取成功';
|
||||
$res['data'] = $diy_mall_data;
|
||||
} else {
|
||||
$msg = '门店未设置DIY数据';
|
||||
}
|
||||
return callBack(statusCode()['success'], $msg, $res);
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户