初始上传
32
addon/goodscircle/api/controller/Config.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\goodscircle\model\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 好物圈
|
||||
*/
|
||||
class Config extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 获取好物圈配置
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getGoodscircleConfig($this->site_id);
|
||||
return $this->response($this->success($res['data']));
|
||||
}
|
||||
|
||||
}
|
||||
40
addon/goodscircle/api/controller/Goods.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\api\controller;
|
||||
|
||||
use addon\goodscircle\model\GoodsCircle;
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\goodscircle\model\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 好物圈
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 将商品同步到好物圈
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
$config = $config_model->getGoodscircleConfig($this->site_id);
|
||||
$config = $config[ 'data' ];
|
||||
if (isset($config[ 'is_use' ]) && $config[ 'is_use' ]) {
|
||||
$goods_circle = new GoodsCircle($this->site_id);
|
||||
$res = $goods_circle->importProduct($this->params[ 'goods_id' ]);
|
||||
return $this->response($res);
|
||||
} else {
|
||||
return $this->response($this->error());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
38
addon/goodscircle/config/diy_view.php
Executable file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
20
addon/goodscircle/config/event.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\goodscircle\event\ShowPromotion',
|
||||
],
|
||||
'WeappMenu' => [
|
||||
'addon\goodscircle\event\WeappMenu',
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
21
addon/goodscircle/config/info.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'goodscircle',
|
||||
'title' => '微信圈子',
|
||||
'description' => '由于微信接口限制已停用,该插件无法使用,朋友间的好物分享',
|
||||
'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
16
addon/goodscircle/config/menu_shop.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 平台端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'GOODS_CIRCLE',
|
||||
'title' => '微信圈子',
|
||||
'url' => 'goodscircle://shop/config/index',
|
||||
'picture' => 'addon/goodscircle/shop/view/public/img/goodscircle_new.png',
|
||||
'picture_selected' => 'addon/goodscircle/shop/view/public/img/goodscircle_select.png',
|
||||
'parent' => 'PROMOTION_TOOL',
|
||||
'is_show' => 1,
|
||||
'sort' => 1
|
||||
]
|
||||
];
|
||||
1
addon/goodscircle/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/goodscircle/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
26
addon/goodscircle/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
46
addon/goodscircle/event/ShowPromotion.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\event;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'goodscircle',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'tool',
|
||||
//展示主题
|
||||
'title' => '微信圈子',
|
||||
//展示介绍
|
||||
'description' => '由于微信接口限制已停用,该插件无法使用,客户分享到微信好物圈',
|
||||
//展示图标
|
||||
'icon' => 'addon/goodscircle/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'goodscircle://shop/config/index',
|
||||
]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
31
addon/goodscircle/event/UnInstall.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
return error('', "系统插件不允许删除");
|
||||
//return success();
|
||||
} catch (\Exception $e) {
|
||||
return error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
35
addon/goodscircle/event/WeappMenu.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\event;
|
||||
|
||||
/**
|
||||
* 小程序菜单
|
||||
*/
|
||||
class WeappMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* 小程序菜单
|
||||
*
|
||||
* @return multitype:number unknown
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'title' => '微信圈子',
|
||||
'description' => '朋友间的好物分享',
|
||||
'url' => 'goodscircle://shop/config/index',
|
||||
'icon' => 'addon/goodscircle/icon.png'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
BIN
addon/goodscircle/icon.png
Executable file
|
After Width: | Height: | Size: 1.5 KiB |
49
addon/goodscircle/model/Config.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 好物圈
|
||||
*/
|
||||
class Config extends BaseModel
|
||||
{
|
||||
/******************************************************************** 微信好物圈配置 start ****************************************************************************/
|
||||
/**
|
||||
* 设置微信好物圈配置
|
||||
* @param $data
|
||||
* @param $is_use
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function setGoodscircleConfig($data, $is_use, $site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '微信好物圈设置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'GOODSCIRCLE_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信好物圈配置信息
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodscircleConfig($site_id)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'GOODSCIRCLE_CONFIG' ] ]);
|
||||
return $res;
|
||||
}
|
||||
/******************************************************************** 微信好物圈配置 end ****************************************************************************/
|
||||
|
||||
}
|
||||
237
addon/goodscircle/model/GoodsCircle.php
Executable file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use addon\weapp\model\Config as WeappConfigModel;
|
||||
use addon\wxoplatform\model\Config as WxOplatformConfigModel;
|
||||
use EasyWeChat\Factory;
|
||||
|
||||
/**
|
||||
* 好物圈
|
||||
*/
|
||||
class GoodsCircle extends BaseModel
|
||||
{
|
||||
private $app;
|
||||
|
||||
public function __construct($site_id = 0)
|
||||
{
|
||||
//微信小程序配置
|
||||
$weapp_config_model = new WeappConfigModel();
|
||||
$weapp_config = $weapp_config_model->getWeappConfig($site_id)['data']['value'];
|
||||
|
||||
if (isset($weapp_config[ 'is_authopen' ]) && addon_is_exit('wxoplatform')) {
|
||||
$plateform_config_model = new WxOplatformConfigModel();
|
||||
$plateform_config = $plateform_config_model->getOplatformConfig()['data']['value'];
|
||||
|
||||
$config = [
|
||||
'app_id' => $plateform_config['appid'] ?? '',
|
||||
'secret' => $plateform_config['secret'] ?? '',
|
||||
'token' => $plateform_config['token'] ?? '',
|
||||
'aes_key' => $plateform_config['aes_key'] ?? '',
|
||||
'log' => [
|
||||
'level' => 'debug',
|
||||
'permission' => 0777,
|
||||
'file' => 'runtime/log/wechat/oplatform.logs',
|
||||
],
|
||||
];
|
||||
$open_platform = Factory::openPlatform($config);
|
||||
$this->app = $open_platform->miniProgram($weapp_config[ 'authorizer_appid' ], $weapp_config[ 'authorizer_refresh_token' ]);
|
||||
} else {
|
||||
$config = [
|
||||
'app_id' => $weapp_config['appid'] ?? '',
|
||||
'secret' => $weapp_config['appsecret'] ?? '',
|
||||
'response_type' => 'array',
|
||||
'log' => [
|
||||
'level' => 'debug',
|
||||
'permission' => 0777,
|
||||
'file' => 'runtime/log/wechat/easywechat.logs',
|
||||
],
|
||||
];
|
||||
$this->app = Factory::miniProgram($config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入或更新物品信息
|
||||
*/
|
||||
public function importProduct($goods_ids)
|
||||
{
|
||||
if (!empty($goods_ids)) {
|
||||
$data = [
|
||||
'product_list' => []
|
||||
];
|
||||
$goods_list = model('goods')->getList([ [ 'goods_id', 'in', explode(',', $goods_ids) ] ], 'goods_id,goods_name,introduction,goods_image,sku_id,category_id,goods_attr_format');
|
||||
if (!empty($goods_list)) {
|
||||
try {
|
||||
foreach ($goods_list as $goods_item) {
|
||||
$sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_item[ 'goods_id' ] ] ], 'sku_id,discount_price,price,goods_state,stock');
|
||||
foreach ($sku_list as $k => $v) {
|
||||
$sku_list[ $k ][ 'stock' ] = numberFormat($sku_list[ $k ][ 'stock' ]);
|
||||
}
|
||||
$goods_data = [
|
||||
'item_code' => $goods_item[ 'goods_id' ],
|
||||
'title' => $goods_item[ 'goods_name' ],
|
||||
'desc' => $goods_item[ 'introduction' ],
|
||||
'category_list' => [],
|
||||
'image_list' => array_map(function($value) {
|
||||
return img($value);
|
||||
}, explode(',', $goods_item[ 'goods_image' ])),
|
||||
'src_wxapp_path' => '/pages/goods/detail?sku_id=' . $goods_item[ 'sku_id' ],
|
||||
'sku_list' => [],
|
||||
'attr_list' => []
|
||||
];
|
||||
if (!empty($goods_item[ 'category_id' ])) {
|
||||
$category_id = trim($goods_item[ 'category_id' ], ',');
|
||||
$goods_category = model('goods_category')->getList([ [ 'category_id', 'in', explode(',', $category_id) ] ], 'category_name');
|
||||
if (!empty($goods_category)) {
|
||||
foreach ($goods_category as $item) {
|
||||
$goods_data["category_list"][] = $item['category_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($goods_item[ 'goods_attr_format' ])) {
|
||||
$goods_attr = json_decode($goods_item[ 'goods_attr_format' ], true);
|
||||
foreach ($goods_attr as $attr_item) {
|
||||
$attr_data = [
|
||||
'name' => $attr_item[ 'attr_name' ],
|
||||
'value' => $attr_item[ 'attr_value_name' ]
|
||||
];
|
||||
$goods_data["attr_list"][] = $attr_data;
|
||||
}
|
||||
}
|
||||
foreach ($sku_list as $sku_item) {
|
||||
$sku_data = [
|
||||
'sku_id' => $sku_item[ 'sku_id' ],
|
||||
'price' => $sku_item[ 'discount_price' ] * 100,
|
||||
'original_price' => $sku_item[ 'price' ] * 100
|
||||
];
|
||||
$sku_data[ 'status' ] = $sku_item[ 'goods_state' ] == 1 ? 1 : 2;
|
||||
if ($sku_item[ 'stock' ] == 0) $sku_data[ 'status' ] = 3;
|
||||
$goods_data["sku_list"][] = $sku_data;
|
||||
}
|
||||
$data['product_list'][] = $goods_data;
|
||||
}
|
||||
$result = $this->app->mall->product->import($data);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入订单每次最大10条
|
||||
* @param $order_id
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function importOrder($order_ids)
|
||||
{
|
||||
if (!empty($order_ids)) {
|
||||
$data = [
|
||||
'order_list' => []
|
||||
];
|
||||
$order_join = [
|
||||
[ 'member m', 'm.member_id = o.member_id', 'left' ]
|
||||
];
|
||||
$order_list = model('order')->getList([ [ 'order_id', 'in', explode(',', $order_ids) ] ], 'o.order_id,o.order_no,o.goods_money,o.pay_money,o.delivery_money,o.create_time,o.pay_time,o.buyer_message,o.pay_type,o.order_status_name,m.weapp_openid', '', 'o', $order_join, '', 10);
|
||||
if (!empty($order_list)) {
|
||||
try {
|
||||
foreach ($order_list as $order_item) {
|
||||
$order_data = [
|
||||
'order_id' => $order_item[ 'order_id' ],
|
||||
'create_time' => $order_item[ 'create_time' ],
|
||||
'pay_finish_time' => $order_item[ 'pay_time' ],
|
||||
'desc' => $order_item[ 'buyer_message' ],
|
||||
'fee' => $order_item[ 'pay_money' ],
|
||||
'trans_id' => $order_item[ 'order_no' ],
|
||||
'ext_info' => [
|
||||
'product_info' => [
|
||||
'item_list' => []
|
||||
],
|
||||
'express_info' => [
|
||||
'price' => $order_item[ 'delivery_money' ]
|
||||
],
|
||||
'brand_info' => [
|
||||
'contact_detail_page' => [
|
||||
'path' => '/pages/index/index'
|
||||
]
|
||||
],
|
||||
'payment_method' => $order_item[ 'pay_type' ] == 'wechatpay' ? 1 : 2,
|
||||
'user_open_id' => $order_item[ 'weapp_openid' ],
|
||||
'order_detail_page' => [
|
||||
'path' => '/pages/order/detail?order_id=' . $order_item[ 'order_id' ]
|
||||
],
|
||||
'total_fee' => $order_item[ 'goods_money' ]
|
||||
]
|
||||
];
|
||||
switch ( $order_item[ 'order_status_name' ] ) {
|
||||
case '待发货':
|
||||
$order_data[ 'status' ] = 3;
|
||||
break;
|
||||
case '已发货':
|
||||
$order_data[ 'status' ] = 4;
|
||||
break;
|
||||
case '已完成':
|
||||
$order_data[ 'status' ] = 100;
|
||||
break;
|
||||
}
|
||||
$order_goods_join = [
|
||||
[ 'goods g', 'og.goods_id = g.goods_id', 'left' ]
|
||||
];
|
||||
$order_goods_list = model('order_goods')->getList([ [ 'order_id', '=', $order_item[ 'order_id' ] ] ], 'og.goods_id,og.sku_id,og.num,og.goods_money,og.sku_image,og.sku_name,og.price,g.category_id', '', 'og', $order_goods_join);
|
||||
foreach ($order_goods_list as $goods_item) {
|
||||
$goods_data = [
|
||||
'item_code' => $goods_item[ 'goods_id' ],
|
||||
'sku_id' => $goods_item[ 'sku_id' ],
|
||||
'amount' => numberFormat($goods_item[ 'num' ]),
|
||||
'total_fee' => $goods_item[ 'goods_money' ] * 100,
|
||||
'thumb_url' => img($goods_item[ 'sku_image' ]),
|
||||
'title' => $goods_item[ 'sku_name' ],
|
||||
'unit_price' => $goods_item[ 'price' ],
|
||||
'original_price' => $goods_item[ 'price' ],
|
||||
'category_list' => [],
|
||||
'item_detail_page' => [
|
||||
'path' => '/pages/goods/detail?sku_id=' . $goods_item[ 'sku_id' ]
|
||||
]
|
||||
];
|
||||
if (!empty($goods_item[ 'category_id' ])) {
|
||||
$category_id = trim($goods_item[ 'category_id' ], ',');
|
||||
$goods_category = model('goods_category')->getList([ [ 'category_id', 'in', explode(',', $category_id) ] ], 'category_name');
|
||||
if (!empty($goods_category)) {
|
||||
foreach ($goods_category as $item) {
|
||||
$goods_data["category_list"][] = $item['category_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$order_data['ext_info']['product_info']['item_list'][] = $goods_data;
|
||||
}
|
||||
$data['order_list'][] = $order_data;
|
||||
}
|
||||
$result = $this->app->mall->order->add($data);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
addon/goodscircle/shop/controller/Config.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\goodscircle\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\goodscircle\model\Config as ConfigModel;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 满减控制器
|
||||
*/
|
||||
class Config extends BaseShop
|
||||
{
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'CIRCLE_CSS' => __ROOT__ . '/addon/goodscircle/shop/view/public/css',
|
||||
'CIRCLE_JS' => __ROOT__ . '/addon/goodscircle/shop/view/public/js',
|
||||
'CIRCLE_IMG' => __ROOT__ . '/addon/goodscircle/shop/view/public/img',
|
||||
];
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$config_model = new ConfigModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [];
|
||||
$is_use = input('is_use', 0);
|
||||
return $config_model->setGoodscircleConfig($data, $is_use, $this->site_id);
|
||||
} else {
|
||||
$config = $config_model->getGoodscircleConfig($this->site_id);
|
||||
$this->assign('config', $config[ 'data' ]);
|
||||
return $this->fetch('config/index');
|
||||
}
|
||||
}
|
||||
}
|
||||
87
addon/goodscircle/shop/view/config/index.html
Executable file
@@ -0,0 +1,87 @@
|
||||
|
||||
<style>
|
||||
.layui-form-switch{margin-top: 0;}
|
||||
.layui-card-body{display: flex;justify-content: space-between;align-items: center;}
|
||||
.layui-card-body p{color: #666666;}
|
||||
.card-common:first-child{margin-top: 0;}
|
||||
.card-common{border: 1px solid #f1f1f1;}
|
||||
.wechat-circle {width: 100%;}
|
||||
.wechat-wrap {width: 100%;}
|
||||
.wechat-circle-wrap {width: 1000px; margin: 50px auto; display: flex; justify-content: center; align-items: center;}
|
||||
.wechat-circle-wrap>div:first-child {margin-right: 50px;}
|
||||
.wechat-circle-intro {width: 360px;}
|
||||
.wechat-circle-intro h1 {font-size: 26px; font-weight: 600; color: #333333; line-height: 40px;}
|
||||
.wechat-circle-intro p {font-size: 16px; color: #858585; line-height: 28px; margin-top: 20px;}
|
||||
.wechat-circle-img {width: 360px;}
|
||||
.wechat-circle-img img {width: 100%;}
|
||||
.card-common .layui-card-header{height: 42px;line-height: 42px;padding: 0 15px;}
|
||||
.card-common .layui-card-body{padding: 10px 15px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
<div class="layui-card card-common">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">微信圈子</span>
|
||||
<input type="checkbox" name="isUse" lay-skin="switch" {if $config.is_use == 1} checked {/if} lay-filter="isUse"/>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<p>启用后,将同步商品到微信圈子。</p>
|
||||
<!-- <p>好物圈是微信提供的服务信息管理和物品推荐工具。用户可以在这里浏览朋友推荐的物品,与朋友交流心得,还可以为朋友进行推荐。</p> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wechat-circle">
|
||||
<div class="wechat-wrap">
|
||||
<!-- <div class="wechat-circle-wrap">
|
||||
<div class="wechat-circle-intro">
|
||||
<h1>扫一扫识物</h1>
|
||||
<h1>直接曝光好物圈商品</h1>
|
||||
<p>商家开启好物圈后,用户同步至好物圈的商品,可以通过“微信扫一扫”-识物功能直接曝光展示。</p>
|
||||
</div>
|
||||
<div class="wechat-circle-img">
|
||||
<img src="CIRCLE_IMG/1.png" />
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="wechat-circle-wrap">
|
||||
<div class="wechat-circle-intro">
|
||||
<h1>好物分享</h1>
|
||||
<p>商家开启好物圈之后,用户可以将商品分享到好物圈。</p>
|
||||
</div>
|
||||
<div class="wechat-circle-img">
|
||||
<img src="CIRCLE_IMG/1.png" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="wechat-circle-wrap">
|
||||
<div class="wechat-circle-img">
|
||||
<img src="CIRCLE_IMG/2.png" />
|
||||
</div>
|
||||
<div class="wechat-circle-intro">
|
||||
<h1>搜索商品</h1>
|
||||
<p>开启好物圈,可搜索到商家发布在好物圈的商品,点击进入详情即可通过商品链接进入小程序</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use(['form'], function() {
|
||||
var form = layui.form;
|
||||
|
||||
form.on('switch(isUse)', function(data){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ns.url("goodscircle://shop/config/index"),
|
||||
data: {
|
||||
is_use: $('[name="isUse"]').is(':checked') ? 1 : 0
|
||||
},
|
||||
dataType: 'JSON',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
BIN
addon/goodscircle/shop/view/public/img/1.png
Executable file
|
After Width: | Height: | Size: 334 KiB |
BIN
addon/goodscircle/shop/view/public/img/2.png
Executable file
|
After Width: | Height: | Size: 214 KiB |
BIN
addon/goodscircle/shop/view/public/img/22.jpg
Executable file
|
After Width: | Height: | Size: 261 KiB |
BIN
addon/goodscircle/shop/view/public/img/33.jpg
Executable file
|
After Width: | Height: | Size: 178 KiB |
BIN
addon/goodscircle/shop/view/public/img/goodscircle.png
Executable file
|
After Width: | Height: | Size: 381 B |
BIN
addon/goodscircle/shop/view/public/img/goodscircle_new.png
Executable file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
addon/goodscircle/shop/view/public/img/goodscircle_select.png
Executable file
|
After Width: | Height: | Size: 1.3 KiB |