初始上传

This commit is contained in:
2026-04-04 17:27:12 +08:00
parent 4d80d28eb4
commit b7e11774ee
11191 changed files with 1588469 additions and 0 deletions

200
app/model/shop/Shop.php Executable file
View File

@@ -0,0 +1,200 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace app\model\shop;
use app\model\system\Config as ConfigModel;
use app\model\BaseModel;
use addon\shopcomponent\model\Weapp;
use think\facade\Cache;
/**
* 店铺信息(无缓存)
*/
class Shop extends BaseModel
{
public $cache_model = 'cache_model_shop';
/**
* 添加店铺
* @param $data
* @return array
*/
public function addShop($data)
{
$res = model('shop')->add($data);
return $this->success($res);
}
/**
* 修改店铺(不能随意修改组)
* @param array $data
*/
public function editShop($data, $condition, $site_id = 1)
{
$res = model('shop')->update($data, $condition);
//更新视频号商家信息
if (isset($data[ 'name' ]) && isset($data[ 'mobile' ]) && isset($data[ 'full_address' ]) && isset($data[ 'address' ]) && addon_is_exit("shopcomponent")) {
$weapp_model = new Weapp($site_id);
$info = $weapp_model->checkRegister();
if (isset($info[ 'data' ][ 'status' ]) && $info[ 'data' ][ 'status' ] == 2) {
$params = [
"service_agent_path" => "",
"service_agent_phone" => $data[ 'mobile' ],
"service_agent_type" => [ 0, 2 ],
"default_receiving_address" => [
"receiver_name" => $data[ 'name' ],
"detailed_address" => $data[ 'full_address' ] . $data[ 'address' ],
"tel_number" => $data[ 'mobile' ],
"country" => "",
"province" => $data[ 'province' ],
"city" => $data[ 'city' ],
"town" => $data[ 'district' ]
]
];
$weapp_model->updateShop($params);
}
}
Cache::tag($this->cache_model)->clear();
return $this->success($res);
}
/**
* 获取店铺信息
* @param array $condition
* @param string $field
*/
public function getShopInfo($condition, $field = '*')
{
$res = model('shop')->getInfo($condition, $field);
return $this->success($res);
}
/**
* 获取店铺详情
* @param int $site_id
*/
public function getShopDetail($site_id)
{
$res = [];
$shop_info = model('shop')->getInfo([ [ 'site_id', '=', $site_id ] ], 'site_id,expire_time,site_name,username,shop_status,logo,avatar,banner,seo_description,qq,ww,telephone,workingtime,email');
$res [ 'shop_info' ] = $shop_info;
return $this->success($res);
}
/**
* 店铺推广二维码
* @param $site_id
* @param string $type
* @return array
*/
public function qrcode($site_id, $type = "create")
{
$data = [
'site_id' => $site_id,
'app_type' => "all", // all为全部
'type' => $type, // 类型 create创建 get获取
'data' => [],
'page' => '',
'qrcode_path' => 'upload/qrcode/shop',
'qrcode_name' => "shop_qrcode_" . $site_id,
];
event('Qrcode', $data, true);
$app_type_list = config('app_type');
$path = [];
foreach ($app_type_list as $k => $v) {
switch ( $k ) {
case 'h5':
$wap_domain = getH5Domain();
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ];
$path[ $k ][ 'img' ] = $data[ 'qrcode_path' ] . '/' . $data[ 'qrcode_name' ] . '_' . $k . '.png';
break;
case 'weapp' :
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
if (!empty($res[ 'data' ])) {
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信小程序';
} else {
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
}
} else {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信小程序';
}
break;
case 'wechat' :
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
if (!empty($res[ 'data' ])) {
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信公众号';
} else {
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
}
} else {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信公众号';
}
break;
}
}
$return = [
'path' => $path,
];
return $this->success($return);
}
/**
* 设置商城状态
* @param $data
* @param $site_id
* @param $app_module
* @return array
*/
public function setShopStatus($data, $site_id, $app_module)
{
$config = new ConfigModel();
$res = $config->setConfig($data, '商城状态设置', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'SHOP_STATUS_CONFIG' ] ]);
return $res;
}
/**
* 获取商城状态
* @param $site_id
* @param $app_module
* @return array
*/
public function getShopStatus($site_id, $app_module)
{
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'SHOP_STATUS_CONFIG' ] ]);
if (empty($res[ 'data' ][ 'value' ])) {
$res[ 'data' ][ 'value' ] = [
'shop_pc_status' => 1,
'shop_h5_status' => 1,
'shop_weapp_status' => 1,
];
}
return $res;
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace app\model\shop;
use app\model\BaseModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 商家接受消息设置
*/
class ShopAcceptMessage extends BaseModel
{
/**
* 添加商家消息接收会员
* @param $member_id
* @param $site_id
* @return array
*/
public function addShopAcceptMessage($param)
{
$data = [
'site_id' => $param['site_id'],
'mobile' => $param['mobile'] ?? '',
'wx_openid' => $param['wx_openid'] ?? '',
'nickname' => $param['nickname'],
'create_time' => time()
];
$res = model('shop_accept_message')->add($data);
return $this->success($res);
}
/**
* 编辑消息接收人
* @param $data
* @param $condition
* @return array
*/
public function editShopAcceptMessage($data, $condition)
{
$res = model('shop_accept_message')->update($data, $condition);
return $this->success($res);
}
/**
* 删除商家消息接收会员
* @param $condition
* @return array
*/
public function deleteShopAcceptMessage($condition)
{
$res = model('shop_accept_message')->delete($condition);
return $this->success($res);
}
/**
* 获取商家消息接收会员
* @param array $condition
* @param string $order
* @return array
*/
public function getShopAcceptMessageList($condition = [], $order = '')
{
$list = model('shop_accept_message')->getList($condition, '*', $order);
return $this->success($list);
}
/**
* 获取商家消息接收会员分页列表
* @param array $condition
* @param int $page
* @param int $page_size
* @param string $order
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function getShopAcceptMessagePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'id desc')
{
$list = model('shop_accept_message')->pageList($condition, '*', $order, $page, $page_size);
return $this->success($list);
}
}

94
app/model/shop/ShopAddress.php Executable file
View File

@@ -0,0 +1,94 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace app\model\shop;
use think\facade\Cache;
use app\model\BaseModel;
/**
* 店铺地址库
*/
class ShopAddress extends BaseModel
{
/**
* 添加店铺地址库
* @param array $data
*/
public function addAddress($data)
{
$data["update_time"] = time();
$res = model('shop_address')->add($data);
Cache::tag("shop_address")->clear();
return $this->success($res);
}
/**
* 修改店铺地址库
* @param array $data
*/
public function editAddress($data, $condition)
{
$res = model('shop_address')->update($data, $condition);
//修改对应店铺
Cache::tag("shop_address")->clear();
return $this->success($res);
}
/**
* 删除店铺地址库
* @param unknown $condition
*/
public function deleteAddress($condition)
{
$res = model('shop_address')->delete($condition);
Cache::tag("shop_address")->clear();
return $this->success($res);
}
/**
* 获取店铺地址库信息
* @param unknown $condition
* @param string $field
*/
public function getAddressInfo($condition, $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time')
{
$res = model('shop_address')->getInfo($condition, $field);
return $this->success($res);
}
/**
* 获取店铺地址库列表
* @param array $condition
* @param string $field
* @param string $order
* @param string $limit
*/
public function getAddressList($condition = [], $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time', $order = '', $limit = null)
{
$list = model('shop_address')->getList($condition, $field, $order, '', '', '', $limit);
return $this->success($list);
}
/**
* 获取店铺地址库分页列表
* @param array $condition
* @param number $page
* @param string $page_size
* @param string $order
* @param string $field
*/
public function getAddressPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time')
{
$list = model('shop_address')->pageList($condition, $field, $order, $page, $page_size);
return $this->success($list);
}
}

131
app/model/shop/SiteAddress.php Executable file
View File

@@ -0,0 +1,131 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
* =========================================================
*/
namespace app\model\shop;
use think\facade\Cache;
use app\model\BaseModel;
/**
* 站点地址库
*/
class SiteAddress extends BaseModel
{
/**
* 添加店铺地址库
* @param $data
* @return array
*/
public function addAddress($data)
{
model('site_address')->startTrans();
try {
if (empty($data['site_id']) || empty($data['contact_name']) || empty($data['mobile']) || empty($data['province_id']) || empty($data['city_id']) || empty($data['address']) || empty($data['full_address'])){
return $this->error('','参数错误');
}
$data[ "update_time" ] = time();
if($data['is_return_default'] == 1){
model('site_address')->update([ 'is_return_default' => 0 ], [ [ 'site_id', '=', $data['site_id'] ] ]);
}
$res = model('site_address')->add($data);
model('site_address')->commit();
Cache::tag("site_address")->clear();
return $this->success($res);
}catch (\Exception $e){
model('site_address')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 修改店铺地址库
* @param $data
* @param $condition
* @return array
*/
public function editAddress($data, $condition)
{
model('site_address')->startTrans();
try {
if (empty($data['contact_name']) || empty($data['mobile']) || empty($data['province_id']) || empty($data['city_id']) || empty($data['address']) || empty($data['full_address'])){
return $this->error('','参数错误');
}
if($data['is_return_default'] == 1){
$site_address_info = model('site_address')->getInfo($condition, 'site_id');
model('site_address')->update([ 'is_return_default' => 0 ], [ [ 'site_id', '=', $site_address_info['site_id'] ] ]);
}
$res = model('site_address')->update($data, $condition);
model('site_address')->commit();
//修改对应店铺
Cache::tag("site_address")->clear();
return $this->success($res);
}catch (\Exception $e){
model('site_address')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 删除店铺地址库
* @param $condition
* @return array
*/
public function deleteAddress($condition)
{
$res = model('site_address')->delete($condition);
Cache::tag("site_address")->clear();
return $this->success($res);
}
/**
* 获取店铺地址库信息
* @param $condition
* @param string $field
* @return array
*/
public function getAddressInfo($condition, $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time')
{
$res = model('site_address')->getInfo($condition, $field);
return $this->success($res);
}
/**
* 获取店铺地址库列表
* @param array $condition
* @param string $field
* @param string $order
* @param null $limit
* @return array
*/
public function getAddressList($condition = [], $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time', $order = '', $limit = null)
{
$list = model('site_address')->getList($condition, $field, $order, '', '', '', $limit);
return $this->success($list);
}
/**
* 获取店铺地址库分页列表
* @param array $condition
* @param int $page
* @param int $page_size
* @param string $order
* @param string $field
* @return array
*/
public function getAddressPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'id, site_id, contact_name, mobile, postcode, province_id, city_id, district_id, community_id, address, full_address, is_return, is_return_default, is_delivery, update_time')
{
$list = model('site_address')->pageList($condition, $field, $order, $page, $page_size);
return $this->success($list);
}
}