初始上传
This commit is contained in:
29
addon/shopcomponent/api/controller/Weapp.php
Executable file
29
addon/shopcomponent/api/controller/Weapp.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\weapp\model\Weapp as WeappModel;
|
||||
|
||||
class Weapp extends BaseApi
|
||||
{
|
||||
/**
|
||||
* 检查场景值是否在支付校验范围内
|
||||
* @return mixed
|
||||
*/
|
||||
public function sceneCheck()
|
||||
{
|
||||
$scene = $this->params[ 'scene' ] ?? '';
|
||||
$weapp_model = new WeappModel($this->site_id);
|
||||
$result = $weapp_model->sceneCheck($scene);
|
||||
return $this->response($result);
|
||||
}
|
||||
}
|
||||
38
addon/shopcomponent/config/diy_view.php
Executable file
38
addon/shopcomponent/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' => []
|
||||
];
|
||||
55
addon/shopcomponent/config/event.php
Executable file
55
addon/shopcomponent/config/event.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\shopcomponent\event\ShowPromotion',
|
||||
],
|
||||
'WeappMenu' => [
|
||||
'addon\shopcomponent\event\WeappMenu',
|
||||
],
|
||||
'GoodsEdit' => [
|
||||
'addon\shopcomponent\event\GoodsEdit'
|
||||
],
|
||||
// 商品删除
|
||||
'DeleteGoods' => [
|
||||
'addon\shopcomponent\event\DeleteGoods'
|
||||
],
|
||||
// 订单支付成功
|
||||
'OrderPay' => [
|
||||
'addon\shopcomponent\event\OrderPay'
|
||||
],
|
||||
// 发货成功
|
||||
'OrderDeliveryAfter' => [
|
||||
'addon\shopcomponent\event\OrderDeliveryAfter'
|
||||
],
|
||||
// 订单收货
|
||||
'OrderTakeDeliveryAfter' => [
|
||||
'addon\shopcomponent\event\OrderTakeDeliveryAfter'
|
||||
],
|
||||
// 发起维权申请
|
||||
'orderRefundApply' => [
|
||||
'addon\shopcomponent\event\OrderRefundApply'
|
||||
],
|
||||
// 维权状态变更
|
||||
'RefundStatusChange' => [
|
||||
'addon\shopcomponent\event\RefundStatusChange'
|
||||
],
|
||||
// 同步微信类目
|
||||
'SyncWxCategory' => [
|
||||
'addon\shopcomponent\event\SyncWxCategory'
|
||||
],
|
||||
// 异步回调
|
||||
'shopcomponentNotify' => [
|
||||
'addon\shopcomponent\event\ShopcomponentNotify'
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
21
addon/shopcomponent/config/info.php
Executable file
21
addon/shopcomponent/config/info.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'shopcomponent',
|
||||
'title' => '微信视频号',
|
||||
'description' => '由于微信接口限制已停用,该插件无法使用,实现小程序与视频号的连接',
|
||||
'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
45
addon/shopcomponent/config/menu_shop.php
Executable file
45
addon/shopcomponent/config/menu_shop.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 平台端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'SHOP_COMPONENT_ROOT',
|
||||
'title' => '视频号',
|
||||
'url' => 'shopcomponent://shop/goods/lists',
|
||||
'picture' => 'addon/shopcomponent/shop/view/public/img/live_new.png',
|
||||
'picture_selected' => 'addon/shopcomponent/shop/view/public/img/live_select.png',
|
||||
'parent' => 'PROMOTION_TOOL',
|
||||
'is_show' => 1,
|
||||
'sort' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'SHOP_COMPONENT_GOODS',
|
||||
'title' => '商品管理',
|
||||
'url' => 'shopcomponent://shop/goods/lists',
|
||||
'is_show' => 1,
|
||||
'sort' => 1,
|
||||
'child_list' => [
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'SHOP_COMPONENT_CATEGORY',
|
||||
'title' => '类目管理',
|
||||
'url' => 'shopcomponent://shop/category/lists',
|
||||
'is_show' => 1,
|
||||
'sort' => 2,
|
||||
'child_list' => [
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'SHOP_COMPONENT_ACCESS',
|
||||
'title' => '视频号接入',
|
||||
'url' => 'shopcomponent://shop/goods/access',
|
||||
'is_show' => 1,
|
||||
'sort' => 3,
|
||||
'child_list' => [
|
||||
]
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
1
addon/shopcomponent/data/install.sql
Executable file
1
addon/shopcomponent/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/shopcomponent/data/uninstall.sql
Executable file
1
addon/shopcomponent/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
29
addon/shopcomponent/event/DeleteGoods.php
Executable file
29
addon/shopcomponent/event/DeleteGoods.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Goods;
|
||||
|
||||
/**
|
||||
* 商品删除之后
|
||||
*/
|
||||
class DeleteGoods
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$goods = new Goods();
|
||||
foreach (explode(',', $data['goods_id']) as $goods_id) {
|
||||
$goods->deleteGoods($goods_id, $data['site_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/shopcomponent/event/GoodsEdit.php
Executable file
27
addon/shopcomponent/event/GoodsEdit.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Goods;
|
||||
|
||||
/**
|
||||
* 商品编辑之后
|
||||
*/
|
||||
class GoodsEdit
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$goods = new Goods();
|
||||
$goods->updateGoods(['goods_id' => $data['goods_id'], 'site_id' => $data['site_id'] ]);
|
||||
}
|
||||
}
|
||||
26
addon/shopcomponent/event/Install.php
Executable file
26
addon/shopcomponent/event/Install.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
26
addon/shopcomponent/event/OrderDeliveryAfter.php
Executable file
26
addon/shopcomponent/event/OrderDeliveryAfter.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Order;
|
||||
|
||||
/**
|
||||
* 订单发货完成
|
||||
*/
|
||||
class OrderDeliveryAfter
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$res = ( new Order() )->delivery($data[ 'order_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
37
addon/shopcomponent/event/OrderPay.php
Executable file
37
addon/shopcomponent/event/OrderPay.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Weapp;
|
||||
|
||||
/**
|
||||
* 订单支付成功
|
||||
*/
|
||||
class OrderPay
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
if ($data['is_video_number'] && $data['pay_type'] == 'wechatpay') {
|
||||
$member = model('member')->getInfo([ ['member_id', '=', $data['member_id'] ] ], 'weapp_openid');
|
||||
$pay = model('pay')->getInfo([ ['out_trade_no', '=', $data['out_trade_no'] ] ], 'trade_no,pay_time');
|
||||
$param = [
|
||||
'out_order_id' => $data['order_id'],
|
||||
'openid' => $member['weapp_openid'],
|
||||
'action_type' => 1,
|
||||
'transaction_id' => $pay['trade_no'],
|
||||
'pay_time' => date('Y-m-d H:i:s', $pay['pay_time'])
|
||||
];
|
||||
(new Weapp($data['site_id']))->pay($param);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/shopcomponent/event/OrderRefundApply.php
Executable file
27
addon/shopcomponent/event/OrderRefundApply.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Order;
|
||||
|
||||
/**
|
||||
* 订单申请维权
|
||||
*/
|
||||
class OrderRefundApply
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
// $res = (new Order())->refundApply($data);
|
||||
// return $res;
|
||||
}
|
||||
}
|
||||
26
addon/shopcomponent/event/OrderTakeDeliveryAfter.php
Executable file
26
addon/shopcomponent/event/OrderTakeDeliveryAfter.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Order;
|
||||
|
||||
/**
|
||||
* 订单收货
|
||||
*/
|
||||
class OrderTakeDeliveryAfter
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$res = ( new Order() )->takeDelivery($data[ 'order_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
27
addon/shopcomponent/event/RefundStatusChange.php
Executable file
27
addon/shopcomponent/event/RefundStatusChange.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Order;
|
||||
|
||||
/**
|
||||
* 订单维权状态变更
|
||||
*/
|
||||
class RefundStatusChange
|
||||
{
|
||||
|
||||
public function handle($data)
|
||||
{
|
||||
$res = (new Order())->refundStatusChange($data);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
31
addon/shopcomponent/event/ShopcomponentNotify.php
Executable file
31
addon/shopcomponent/event/ShopcomponentNotify.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use app\model\system\Pay as PayCommon;
|
||||
|
||||
/**
|
||||
* 视频号异步回调
|
||||
*/
|
||||
class shopcomponentNotify
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
if (!empty($params)) {
|
||||
if (isset($params[ 'order_info' ])) {
|
||||
$pay_common = new PayCommon();
|
||||
$order_info = model('order')->getInfo([ [ 'order_id', '=', $params[ 'order_info' ][ 'out_order_id' ] ] ]);
|
||||
$pay_common->onlinePay($order_info[ 'out_trade_no' ], "wechatpay", $params[ 'order_info' ][ "transaction_id" ], "wechatpay");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
addon/shopcomponent/event/ShowPromotion.php
Executable file
46
addon/shopcomponent/event/ShowPromotion.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'shopcomponent',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'tool',
|
||||
//展示主题
|
||||
'title' => '微信视频号',
|
||||
//展示介绍
|
||||
'description' => '由于微信接口限制已停用,该插件无法使用,视频号直播开启线上带货新模式',
|
||||
//展示图标
|
||||
'icon' => 'addon/shopcomponent/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'shopcomponent://shop/goods/lists',
|
||||
]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
25
addon/shopcomponent/event/SyncWxCategory.php
Executable file
25
addon/shopcomponent/event/SyncWxCategory.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
use addon\shopcomponent\model\Category;
|
||||
|
||||
/**
|
||||
* 同步微信类目
|
||||
*/
|
||||
class SyncWxCategory
|
||||
{
|
||||
public function handle($data)
|
||||
{
|
||||
(new Category())->syncCategory($data['relate_id']);
|
||||
}
|
||||
}
|
||||
30
addon/shopcomponent/event/UnInstall.php
Executable file
30
addon/shopcomponent/event/UnInstall.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
return error('', "系统插件不允许删除");
|
||||
} catch (\Exception $e) {
|
||||
return error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
37
addon/shopcomponent/event/WeappMenu.php
Executable file
37
addon/shopcomponent/event/WeappMenu.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\event;
|
||||
|
||||
/**
|
||||
* 小程序菜单
|
||||
*/
|
||||
class WeappMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* 小程序菜单
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (addon_is_exit('shopcomponent', $param['site_id'])) {
|
||||
$data = [
|
||||
'title' => '微信视频号',
|
||||
'description' => '实现小程序与视频号的连接',
|
||||
'url' => 'shopcomponent://shop/goods/lists',
|
||||
'icon' => 'addon/shopcomponent/icon.png'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
addon/shopcomponent/icon.png
Executable file
BIN
addon/shopcomponent/icon.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
282
addon/shopcomponent/model/Category.php
Executable file
282
addon/shopcomponent/model/Category.php
Executable file
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use think\facade\Cache;
|
||||
|
||||
class Category extends BaseModel
|
||||
{
|
||||
private $statusName = [
|
||||
'0' => '待提交',
|
||||
'1' => '审核成功',
|
||||
'9' => '审核拒绝'
|
||||
];
|
||||
private $type = [
|
||||
'0' => '不需要',
|
||||
'1' => '需要',
|
||||
'2' => '可选'
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取类目列表
|
||||
* @param array $condition
|
||||
* @param bool $field
|
||||
* @param string $order
|
||||
* @param int $page
|
||||
* @param int $list_rows
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoryPageList($condition = [], $field = true, $order = '', $page = 1, $list_rows = PAGE_LIST_ROWS, $alias = 'a', $join = [])
|
||||
{
|
||||
$check_condition = array_column($condition, 2, 0);
|
||||
$site_id = $check_condition['site_id'] ?? 0;
|
||||
|
||||
$site_id_index = array_search('site_id', array_keys(array_column($condition, 2, 0)));
|
||||
unset($condition[ $site_id_index ]);
|
||||
|
||||
$data = model('shopcompoent_category')->pageList($condition, $field, $order, $page, $list_rows, $alias, $join);
|
||||
if (!empty($data[ 'list' ])) {
|
||||
foreach ($data[ 'list' ] as $k => $item) {
|
||||
$audit_info = model('shopcompoent_category_audit')->getInfo([ [ 'site_id', '=', $site_id ], [ 'third_cat_id', '=', $item[ 'third_cat_id' ] ] ]);
|
||||
if (empty($audit_info)) {
|
||||
$audit_info = [
|
||||
'certificate' => '',
|
||||
'qualification_pics' => '',
|
||||
'audit_id' => '',
|
||||
'audit_time' => 0,
|
||||
'status' => 0,
|
||||
'reject_reason' => ''
|
||||
];
|
||||
}
|
||||
|
||||
$item = array_merge($item, $audit_info);
|
||||
$data[ 'list' ][ $k ] = $item;
|
||||
|
||||
if ($item[ 'audit_time' ] > 0 && $item[ 'status' ] == 0) {
|
||||
$data[ 'list' ][ $k ][ 'status_name' ] = '审核中';
|
||||
} else if ($item[ 'qualification_type' ] == 0 && $item[ 'product_qualification_type' ] == 0) {
|
||||
$data[ 'list' ][ $k ][ 'status_name' ] = '--';
|
||||
} else {
|
||||
$data[ 'list' ][ $k ][ 'status_name' ] = $this->statusName[ $item[ 'status' ] ] ?? '';
|
||||
}
|
||||
$data[ 'list' ][ $k ][ 'create_time' ] = $item[ 'create_time' ] > 0 ? time_to_date($item[ 'create_time' ]) : '--';
|
||||
$data[ 'list' ][ $k ][ 'audit_time' ] = $item[ 'audit_time' ] > 0 ? time_to_date($item[ 'audit_time' ]) : '--';
|
||||
$data[ 'list' ][ $k ][ 'leimu' ] = $item[ 'first_cat_name' ] . '>' . $item[ 'second_cat_name' ] . '>' . $item[ 'third_cat_name' ];
|
||||
$data[ 'list' ][ $k ][ 'product_qualification_type_name' ] = $this->type[ $item[ 'product_qualification_type' ] ] ?? '';
|
||||
$data[ 'list' ][ $k ][ 'qualification_type_name' ] = $this->type[ $item[ 'qualification_type' ] ] ?? '';
|
||||
$data[ 'list' ][ $k ][ 'license' ] = Cache::get('license_' . $item[ 'third_cat_id' ]);
|
||||
$data[ 'list' ][ $k ][ 'reject_reason' ] = str_replace('https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent2/API/audit/audit_brand.html', '', $item[ 'reject_reason' ]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步商品类目
|
||||
*/
|
||||
public function syncCategory($site_id)
|
||||
{
|
||||
$res = ( new Weapp($site_id) )->getCatList();
|
||||
if ($res[ 'code' ] < 0) return $res;
|
||||
|
||||
if (!empty($res[ 'data' ])) {
|
||||
model('shopcompoent_category')->delete([ [ 'create_time', '<', time() ] ]);
|
||||
$data = [];
|
||||
foreach ($res[ 'data' ] as $item) {
|
||||
$data[] = [
|
||||
'first_cat_id' => $item['first_cat_id'],
|
||||
'second_cat_id' => $item['second_cat_id'],
|
||||
'third_cat_id' => $item['third_cat_id'],
|
||||
'first_cat_name' => $item['first_cat_name'],
|
||||
'second_cat_name' => $item['second_cat_name'],
|
||||
'third_cat_name' => $item['third_cat_name'],
|
||||
'qualification' => $item['qualification'],
|
||||
'qualification_type' => $item['qualification_type'],
|
||||
'product_qualification_type' => $item['product_qualification_type'],
|
||||
'product_qualification' => $item['product_qualification'],
|
||||
'create_time' => time(),
|
||||
];
|
||||
}
|
||||
model('shopcompoent_category')->addList($data);
|
||||
Cache::tag('wxCategory')->clear();
|
||||
return $this->success(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传类目资质
|
||||
*/
|
||||
public function uploadQualifications($param, $site_id)
|
||||
{
|
||||
$category = model('shopcompoent_category')->getInfo([ [ 'third_cat_id', '=', $param[ 'third_cat_id' ] ] ]);
|
||||
|
||||
$img1 = '';
|
||||
if (!empty($param[ 'leimu_qualification' ])) {
|
||||
$img_info1 = ( new Weapp($site_id) )->getImg(img($param[ 'leimu_qualification' ]));
|
||||
if ($img_info1[ 'code' ] == 0) {
|
||||
$img1 = $img_info1[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
}
|
||||
|
||||
$img2 = '';
|
||||
if (!empty($param[ 'product_qualification' ])) {
|
||||
$img_info2 = ( new Weapp($site_id) )->getImg(img($param[ 'product_qualification' ]));
|
||||
if ($img_info2[ 'code' ] == 0) {
|
||||
$img2 = $img_info2[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
}
|
||||
|
||||
if ($category[ 'qualification_type' ] != 0) {
|
||||
$zhengshu = '';
|
||||
if (isset($param[ 'zhengshu' ])) {
|
||||
$zhengshu_info = ( new Weapp($site_id) )->getImg(img($param[ 'zhengshu' ]));
|
||||
if ($zhengshu_info[ 'code' ] == 0) {
|
||||
$zhengshu = $zhengshu_info[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'license' => $zhengshu ?? '',
|
||||
'category_info' => [
|
||||
'level1' => $param[ 'first_cat_id' ],
|
||||
'level2' => $param[ 'second_cat_id' ],
|
||||
'level3' => $param[ 'third_cat_id' ],
|
||||
'certificate' => []
|
||||
]
|
||||
];
|
||||
if (isset($param[ 'leimu_qualification' ])) {
|
||||
$data['category_info']['certificate'][] = $img1;
|
||||
}
|
||||
if (isset($param[ 'product_qualification' ])) {
|
||||
$data['category_info']['certificate'][] = $img2;
|
||||
}
|
||||
|
||||
$res = ( new Weapp($site_id) )->auditCategory($data);
|
||||
if ($res[ 'code' ] < 0 && $res[ 'data' ] != '1050003') return $res;
|
||||
} else {
|
||||
$res = $this->success();
|
||||
}
|
||||
|
||||
$audit_data = [
|
||||
'site_id' => $site_id,
|
||||
'third_cat_id' => $param[ 'third_cat_id' ],
|
||||
'audit_id' => $res[ 'data' ],
|
||||
'audit_time' => time(),
|
||||
'certificate' => $img1,
|
||||
'qualification_pics' => $img2,
|
||||
'status' => 0
|
||||
];
|
||||
if ($category[ 'qualification_type' ] == 0 || $res[ 'data' ] == '1050003') {
|
||||
$audit_data[ 'status' ] = 1;
|
||||
$audit_data[ 'audit_time' ] = time();
|
||||
}
|
||||
Cache::set('license_' . $param[ 'third_cat_id' ], img($param[ 'zhengshu' ]));
|
||||
|
||||
$is_exit = model('shopcompoent_category_audit')->getCount([ [ 'site_id', '=', $site_id ], [ 'third_cat_id', '=', $param[ 'third_cat_id' ] ] ]);
|
||||
if ($is_exit) {
|
||||
model('shopcompoent_category_audit')->update($audit_data, [ [ 'site_id', '=', $site_id ], [ 'third_cat_id', '=', $param[ 'third_cat_id' ] ] ]);
|
||||
} else {
|
||||
model('shopcompoent_category_audit')->add($audit_data);
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类目通过上级类目ID
|
||||
* @param $level
|
||||
* @param int $pid
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoryByParent($level, $pid = 0)
|
||||
{
|
||||
$cache = Cache::get("wxCategory_{$level}_{$pid}");
|
||||
if ($cache) return $cache;
|
||||
|
||||
switch ( $level ) {
|
||||
case 1:
|
||||
$list = model('shopcompoent_category')->getList([], '*', '', '', null, 'first_cat_id');
|
||||
break;
|
||||
case 2:
|
||||
$list = model('shopcompoent_category')->getList([ [ 'first_cat_id', '=', $pid ] ], '*', '', '', null, 'second_cat_id');
|
||||
break;
|
||||
case 3:
|
||||
$list = model('shopcompoent_category')->getList([ [ 'second_cat_id', '=', $pid ] ], '*', '', '', null, 'third_cat_name');
|
||||
break;
|
||||
}
|
||||
|
||||
$data = $this->success($list);
|
||||
Cache::tag('wxCategory')->set("wxCategory_{$level}_{$pid}", $data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分类是否需要上传资质
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function isQualifications($param)
|
||||
{
|
||||
$info = model('shopcompoent_category')->getInfo([ [ 'third_cat_id', '=', $param[ 'third_cat_id' ] ] ], 'qualification_type,product_qualification_type');
|
||||
if ($info[ 'qualification_type' ] != 0 || $info[ 'product_qualification_type' ] != 0) {
|
||||
$audit_info = model('shopcompoent_category_audit')->getInfo([ [ 'status', '=', 1 ], [ 'site_id', '=', $param[ 'site_id' ] ], [ 'third_cat_id', '=', $param[ 'third_cat_id' ] ] ]);
|
||||
if (empty($audit_info)) return $this->error();
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类信息
|
||||
* @param $third_cat_id
|
||||
* @param $site_id
|
||||
*/
|
||||
public function getCategoryInfo($third_cat_id, $site_id)
|
||||
{
|
||||
$info = model('shopcompoent_category')->getInfo([ [ 'third_cat_id', '=', $third_cat_id ] ]);
|
||||
if (empty($info)) return $info;
|
||||
|
||||
$audit_info = model('shopcompoent_category_audit')->getInfo([ [ 'site_id', '=', $site_id ], [ 'third_cat_id', '=', $third_cat_id ] ]);
|
||||
if (empty($audit_info)) {
|
||||
$audit_info = [
|
||||
'certificate' => '',
|
||||
'qualification_pics' => '',
|
||||
'audit_id' => '',
|
||||
'audit_time' => 0,
|
||||
'status' => 0,
|
||||
'reject_reason' => ''
|
||||
];
|
||||
if (( $info[ 'qualification_type' ] == 0 && $info[ 'product_qualification_type' ] == 0 ) || ( $info[ 'qualification_type' ] == 2 && $info[ 'product_qualification_type' ] == 2 )) $audit_info[ 'status' ] = 1;
|
||||
}
|
||||
|
||||
return array_merge($info, $audit_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步类目审核状态
|
||||
* @param $site_id
|
||||
*/
|
||||
public function syncCategoryAuditStatus($site_id)
|
||||
{
|
||||
$audit_list = model('shopcompoent_category_audit')->getList([ [ 'site_id', '=', $site_id ], [ 'audit_id', '<>', '' ], [ 'status', '=', 0 ] ]);
|
||||
if (!empty($audit_list)) {
|
||||
$weapp = new Weapp($site_id);
|
||||
foreach ($audit_list as $item) {
|
||||
$audit_result = $weapp->getAuditResult($item[ 'audit_id' ]);
|
||||
if ($audit_result[ 'code' ] == 0) {
|
||||
model('shopcompoent_category_audit')->update([ 'status' => $audit_result[ 'data' ][ 'status' ], 'audit_time' => time(), 'reject_reason' => $audit_result[ 'data' ][ 'reject_reason' ] ], [ [ 'id', '=', $item[ 'id' ] ] ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
428
addon/shopcomponent/model/Goods.php
Executable file
428
addon/shopcomponent/model/Goods.php
Executable file
@@ -0,0 +1,428 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
class Goods extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 商品状态
|
||||
* @var string[]
|
||||
*/
|
||||
private $status = [
|
||||
0 => '未上架',
|
||||
5 => '上架中',
|
||||
11 => '已下架',
|
||||
13 => '违规下架'
|
||||
];
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
* @var string[]
|
||||
*/
|
||||
private $editStatus = [
|
||||
0 => '审核中',
|
||||
1 => '编辑中',
|
||||
2 => '审核中',
|
||||
3 => '审核失败',
|
||||
4 => '审核成功',
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @param array $condition
|
||||
* @param bool $field
|
||||
* @param string $order
|
||||
* @param int $page
|
||||
* @param int $list_rows
|
||||
* @param string $alias
|
||||
* @param array $join
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsPageList($condition = [], $field = true, $order = '', $page = 1, $list_rows = PAGE_LIST_ROWS, $alias = 'a', $join = [])
|
||||
{
|
||||
$field = 'sg.*,
|
||||
g.goods_name,g.goods_image,g.price,g.goods_stock,g.recommend_way';
|
||||
$alias = 'sg';
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = sg.out_product_id', 'inner' ],
|
||||
];
|
||||
$data = model('shopcompoent_goods')->pageList($condition, $field, $order, $page, $list_rows, $alias, $join);
|
||||
|
||||
if (!empty($data[ 'list' ])) {
|
||||
foreach ($data[ 'list' ] as $k => $item) {
|
||||
$data[ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($data[ 'list' ][ $k ][ 'goods_stock' ]);
|
||||
$data[ 'list' ][ $k ][ 'status_name' ] = $this->status[ $item[ 'status' ] ] ?? '';
|
||||
$data[ 'list' ][ $k ][ 'edit_status_name' ] = $this->editStatus[ $item[ 'edit_status' ] ] ?? '';
|
||||
$arr_img = explode(',', $item[ 'goods_image' ]);
|
||||
$data[ 'list' ][ $k ][ 'cover_img' ] = $arr_img[ 0 ] ?? '';
|
||||
$data[ 'list' ][ $k ][ 'create_time' ] = $item[ 'create_time' ] > 0 ? time_to_date($item[ 'create_time' ]) : '--';
|
||||
$data[ 'list' ][ $k ][ 'audit_time' ] = $item[ 'audit_time' ] > 0 ? time_to_date($item[ 'audit_time' ]) : '--';
|
||||
$data[ 'list' ][ $k ][ 'reject_reason' ] = str_replace('https://developers.weixin.qq.com/miniprogram/dev/framework/ministore/minishopopencomponent/API/spu/add_spu.html', '', $item[ 'reject_reason' ]);
|
||||
}
|
||||
}
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步商品库商品
|
||||
*/
|
||||
public function syncGoods($start, $limit, $site_id, $status = 5)
|
||||
{
|
||||
$weapp = new Weapp($site_id);
|
||||
$sync_res = $weapp->getSpuPage([ 'page' => $start, 'page_size' => $limit, 'status' => $status ]);
|
||||
|
||||
if ($sync_res[ 'code' ] < 0) return $sync_res;
|
||||
|
||||
if (!empty($sync_res[ 'data' ][ 'list' ])) {
|
||||
foreach ($sync_res[ 'data' ][ 'list' ] as $goods_item) {
|
||||
$count = model('shopcompoent_goods')->getCount([ [ 'out_product_id', '=', $goods_item[ 'out_product_id' ] ], [ 'site_id', '=', $site_id ] ]);
|
||||
if ($count) {
|
||||
model('shopcompoent_goods')->update([
|
||||
'status' => $goods_item[ 'status' ],
|
||||
'edit_status' => $goods_item[ 'edit_status' ],
|
||||
'audit_time' => empty($goods_item[ 'audit_info' ]) ? 0 : strtotime($goods_item[ 'audit_info' ][ 'audit_time' ]),
|
||||
'reject_reason' => $goods_item[ 'edit_status' ] == 3 ? $goods_item[ 'audit_info' ][ 'reject_reason' ] : ''
|
||||
], [
|
||||
[ 'out_product_id', '=', $goods_item[ 'out_product_id' ] ]
|
||||
]);
|
||||
} else {
|
||||
$category = ( new Category() )->getCategoryInfo($goods_item[ 'third_cat_id' ], $site_id);
|
||||
model('shopcompoent_goods')->add([
|
||||
'site_id' => $site_id,
|
||||
'product_id' => $goods_item[ 'product_id' ],
|
||||
'out_product_id' => $goods_item[ 'out_product_id' ],
|
||||
'third_cat_id' => $goods_item[ 'third_cat_id' ],
|
||||
'brand_id' => $goods_item[ 'brand_id' ],
|
||||
'info_version' => $goods_item[ 'info_version' ],
|
||||
'status' => $goods_item[ 'status' ],
|
||||
'edit_status' => $goods_item[ 'edit_status' ],
|
||||
'create_time' => strtotime($goods_item[ 'create_time' ]),
|
||||
'update_time' => strtotime($goods_item[ 'update_time' ]),
|
||||
'audit_time' => empty($goods_item[ 'audit_info' ]) ? 0 : strtotime($goods_item[ 'audit_info' ][ 'audit_time' ]),
|
||||
'reject_reason' => $goods_item[ 'edit_status' ] == 3 ? $goods_item[ 'audit_info' ][ 'reject_reason' ] : '',
|
||||
'cat_name' => "{$category['first_cat_name']}>{$category['second_cat_name']}>{$category['third_cat_name']}"
|
||||
]);
|
||||
}
|
||||
}
|
||||
$total_page = ceil($sync_res[ 'data' ][ 'total' ] / $limit);
|
||||
return $this->success([ 'page' => $start, 'total_page' => $total_page ]);
|
||||
} else {
|
||||
return $this->success([ 'page' => $start, 'total_page' => 1 ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
* @param $param
|
||||
*/
|
||||
public function addGoods($param)
|
||||
{
|
||||
$goods_list = model('goods')->getList([ [ 'goods_id', 'in', explode(',', $param[ 'goods_ids' ]) ], [ 'site_id', '=', $param[ 'site_id' ] ] ], 'goods_id,goods_name,goods_image,sku_id,goods_content');
|
||||
if (!empty($goods_list)) {
|
||||
$category = ( new Category() )->getCategoryInfo($param[ 'third_cat_id' ], $param[ 'site_id' ]);
|
||||
if (empty($category) || $category[ 'status' ] == 0) return $this->error('', '该类目不存在或未审核通过');
|
||||
|
||||
$weapp = new Weapp($param[ 'site_id' ]);
|
||||
foreach ($goods_list as $goods_item) {
|
||||
// 需加到库中的商品数据
|
||||
$goods_data = [
|
||||
'out_product_id' => $goods_item[ 'goods_id' ],
|
||||
'third_cat_id' => $param[ 'third_cat_id' ],
|
||||
'brand_id' => $param[ 'brand_id' ] ?? 2100000000,
|
||||
'info_version' => '0.0.1',
|
||||
];
|
||||
|
||||
//处理图片
|
||||
$goods_image_arr = $this->handleImg($goods_item[ 'goods_image' ]);
|
||||
$goods_image = [];
|
||||
foreach ($goods_image_arr as $img_k => $img_y) {
|
||||
$res = $weapp->getImg($img_y);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$goods_image[] = $res[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
}
|
||||
|
||||
// 同步商品所需数据
|
||||
$spu_data = [
|
||||
'title' => $goods_item[ 'goods_name' ],
|
||||
'path' => 'pages/goods/detail?sku_id=' . $goods_item[ 'sku_id' ],
|
||||
'head_img' => $goods_image,
|
||||
'qualification_pics' => $category[ 'product_qualification_type' ] == 0 ? '' : explode(',', $category[ 'qualification_pics' ]),
|
||||
'desc_info' => [
|
||||
'desc' => $goods_item[ 'goods_content' ]
|
||||
],
|
||||
'skus' => []
|
||||
];
|
||||
|
||||
$sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_item[ 'goods_id' ] ] ], 'sku_id,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format');
|
||||
foreach ($sku_list as $sku_item) {
|
||||
//图片处理
|
||||
$sku_res = $weapp->getImg($this->handleImg($sku_item[ 'sku_image' ])[ 0 ]);
|
||||
$sku_image = '';
|
||||
if ($sku_res[ 'code' ] == 0) {
|
||||
$sku_image = $sku_res[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
|
||||
$sku_data = [
|
||||
'out_product_id' => $goods_item[ 'goods_id' ],
|
||||
'out_sku_id' => $sku_item[ 'sku_id' ],
|
||||
'thumb_img' => $sku_image,
|
||||
'sale_price' => $sku_item[ 'discount_price' ] * 100,
|
||||
'market_price' => $sku_item[ 'market_price' ] * 100,
|
||||
'stock_num' => numberFormat($sku_item[ 'stock' ]),
|
||||
'sku_code' => $sku_item[ 'sku_no' ],
|
||||
'sku_attrs' => []
|
||||
];
|
||||
if (!empty($sku_item[ 'sku_spec_format' ])) {
|
||||
foreach (json_decode($sku_item[ 'sku_spec_format' ], true) as $spec_item) {
|
||||
$sku_data['sku_attrs'][] = [
|
||||
'attr_key' => $spec_item['spec_name'],
|
||||
'attr_value' => $spec_item['spec_value_name']
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$sku_data[ 'sku_attrs' ] = [
|
||||
[
|
||||
'attr_key' => '',
|
||||
'attr_value' => ''
|
||||
]
|
||||
];
|
||||
}
|
||||
$spu_data['skus'][] = $sku_data;
|
||||
}
|
||||
|
||||
// 添加商品到小程序
|
||||
$add_res = $weapp->addSpu(array_merge($goods_data, $spu_data));
|
||||
if ($add_res[ 'code' ] != 0) return $add_res;
|
||||
|
||||
$goods_data[ 'product_id' ] = $add_res[ 'data' ][ 'product_id' ];
|
||||
$goods_data[ 'create_time' ] = !empty($add_res[ 'data' ][ 'create_time' ]) ? strtotime($add_res[ 'data' ][ 'create_time' ]) : time();
|
||||
$goods_data[ 'site_id' ] = $param[ 'site_id' ];
|
||||
$goods_data[ 'cat_name' ] = "{$category['first_cat_name']}>{$category['second_cat_name']}>{$category['third_cat_name']}";
|
||||
|
||||
model('shopcompoent_goods')->add($goods_data);
|
||||
}
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', '未获取到要添加的商品');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function updateGoods($param)
|
||||
{
|
||||
$shopcompoent_goods_info = model('shopcompoent_goods')->getInfo([ [ 'out_product_id', '=', $param[ 'goods_id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ], '*');
|
||||
$goods_info = model('goods')->getInfo([ [ 'goods_id', '=', $param[ 'goods_id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ], 'goods_id,goods_name,goods_image,sku_id,goods_content');
|
||||
if (!empty($shopcompoent_goods_info) && !empty($goods_info)) {
|
||||
|
||||
$third_cat_id = $param[ 'third_cat_id' ] ?? $shopcompoent_goods_info[ 'third_cat_id' ];
|
||||
$category = ( new Category() )->getCategoryInfo($third_cat_id, $param[ 'site_id' ]);
|
||||
if (empty($category) || $category[ 'status' ] == 0) return $this->error('', '该类目不存在或未审核通过');
|
||||
|
||||
$weapp = new Weapp($param[ 'site_id' ]);
|
||||
|
||||
//处理图片
|
||||
$goods_image_arr = $this->handleImg($goods_info[ 'goods_image' ]);
|
||||
$goods_image = [];
|
||||
foreach ($goods_image_arr as $img_k => $img_y) {
|
||||
$res = $weapp->getImg($img_y);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$goods_image[] = $res[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
}
|
||||
|
||||
// 同步商品所需数据
|
||||
$spu_data = [
|
||||
'out_product_id' => $goods_info[ 'goods_id' ],
|
||||
'third_cat_id' => $third_cat_id,
|
||||
'brand_id' => $param[ 'brand_id' ] ?? $shopcompoent_goods_info[ 'brand_id' ],
|
||||
'info_version' => '0.0.1',
|
||||
'title' => $goods_info[ 'goods_name' ],
|
||||
'path' => 'pages/goods/detail?sku_id=' . $goods_info[ 'sku_id' ],
|
||||
'head_img' => $goods_image,
|
||||
'qualification_pics' => $category[ 'product_qualification_type' ] == 0 ? '' : explode(',', $category[ 'qualification_pics' ]),
|
||||
'desc_info' => [
|
||||
'desc' => $goods_info[ 'goods_content' ]
|
||||
],
|
||||
'skus' => []
|
||||
];
|
||||
|
||||
$sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_info[ 'goods_id' ] ] ], 'sku_id,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format');
|
||||
foreach ($sku_list as $sku_item) {
|
||||
//图片处理
|
||||
$sku_res = $weapp->getImg($this->handleImg($sku_item[ 'sku_image' ])[ 0 ]);
|
||||
$sku_image = '';
|
||||
if ($sku_res[ 'code' ] == 0) {
|
||||
$sku_image = $sku_res[ 'data' ][ 'img_info' ][ 'temp_img_url' ];
|
||||
}
|
||||
|
||||
$sku_data = [
|
||||
'out_product_id' => $goods_info[ 'goods_id' ],
|
||||
'out_sku_id' => $sku_item[ 'sku_id' ],
|
||||
'thumb_img' => $sku_image,
|
||||
'sale_price' => $sku_item[ 'discount_price' ] * 100,
|
||||
'market_price' => $sku_item[ 'market_price' ] * 100,
|
||||
'stock_num' => numberFormat($sku_item[ 'stock' ]),
|
||||
'sku_code' => $sku_item[ 'sku_no' ],
|
||||
'sku_attrs' => []
|
||||
];
|
||||
if (!empty($sku_item[ 'sku_spec_format' ])) {
|
||||
foreach (json_decode($sku_item[ 'sku_spec_format' ], true) as $spec_item) {
|
||||
$sku_data['sku_attrs'][] = [
|
||||
'attr_key' => $spec_item['spec_name'],
|
||||
'attr_value' => $spec_item['spec_value_name']
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$sku_data[ 'sku_attrs' ] = [
|
||||
[
|
||||
'attr_key' => '',
|
||||
'attr_value' => ''
|
||||
]
|
||||
];
|
||||
}
|
||||
$spu_data['skus'][] = $sku_data;
|
||||
}
|
||||
|
||||
// 更新商品
|
||||
$update_res = $weapp->updateSpu($spu_data);
|
||||
if ($update_res[ 'code' ] != 0) return $update_res;
|
||||
|
||||
$goods_data = [
|
||||
'edit_status' => 0,
|
||||
'update_time' => time(),
|
||||
'third_cat_id' => $third_cat_id,
|
||||
'cat_name' => "{$category['first_cat_name']}>{$category['second_cat_name']}>{$category['third_cat_name']}"
|
||||
];
|
||||
|
||||
model('shopcompoent_goods')->update($goods_data, [ [ 'out_product_id', '=', $param[ 'goods_id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
|
||||
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', '未获取到要更新的商品');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理图片
|
||||
* @param $images
|
||||
* @return false|string[]
|
||||
*/
|
||||
private function handleImg($images)
|
||||
{
|
||||
$img_arr = explode(',', $images);
|
||||
foreach ($img_arr as $k => $v) {
|
||||
$img_arr[ $k ] = img($v);
|
||||
}
|
||||
return $img_arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param $id
|
||||
* @param $site_id
|
||||
*/
|
||||
public function deleteGoods($goods_ids, $site_id)
|
||||
{
|
||||
if (!empty($goods_ids)) {
|
||||
$array_goodsIds = explode(',', $goods_ids);
|
||||
}
|
||||
foreach ($array_goodsIds as $k => $goods_id) {
|
||||
$res[ $k ] = ( new Weapp($site_id) )->delSpu([ 'out_product_id' => $goods_id ]);
|
||||
if ($res[ $k ][ 'code' ] != 0) return $res[ $k ];
|
||||
}
|
||||
model('shopcompoent_goods')->delete([ [ 'site_id', '=', $site_id ], [ 'out_product_id', 'in', $goods_ids ] ]);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品上架
|
||||
* @param $goods_ids
|
||||
* @param $site_id
|
||||
* @return array|mixed
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function goodsListing($goods_ids, $site_id)
|
||||
{
|
||||
if (!empty($goods_ids)) {
|
||||
$array_goodsIds = explode(',', $goods_ids);
|
||||
}
|
||||
foreach ($array_goodsIds as $k => $goods_id) {
|
||||
$res[ $k ] = ( new Weapp($site_id) )->listing([ 'out_product_id' => $goods_id ]);
|
||||
if ($res[ $k ][ 'code' ] != 0) return $res[ $k ];
|
||||
}
|
||||
model('shopcompoent_goods')->update([ 'status' => 5 ], [ [ 'site_id', '=', $site_id ], [ 'out_product_id', 'in', $goods_ids ] ]);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品下架
|
||||
* @param $goods_ids
|
||||
* @param $site_id
|
||||
* @return array|mixed
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function goodsDelisting($goods_ids, $site_id)
|
||||
{
|
||||
if (!empty($goods_ids)) {
|
||||
$array_goodsIds = explode(',', $goods_ids);
|
||||
}
|
||||
foreach ($array_goodsIds as $k => $goods_id) {
|
||||
$res[ $k ] = ( new Weapp($site_id) )->delisting([ 'out_product_id' => $goods_id ]);
|
||||
if ($res[ $k ][ 'code' ] != 0) return $res[ $k ];
|
||||
}
|
||||
model('shopcompoent_goods')->update([ 'status' => 11 ], [ [ 'site_id', '=', $site_id ], [ 'out_product_id', 'in', $goods_ids ] ]);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $site_id
|
||||
*/
|
||||
public function getOrderPayInfo($site_id)
|
||||
{
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = sg.out_product_id', 'left' ]
|
||||
];
|
||||
$condition = [
|
||||
[ 'sg.site_id', '=', $site_id ],
|
||||
[ 'sg.status', '=', 5 ],
|
||||
[ 'sg.edit_status', '=', 4 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.goods_state', '=', 1 ]
|
||||
];
|
||||
$goods_info = model('shopcompoent_goods')->getInfo($condition, 'g.goods_name,g.price,g.goods_id,g.sku_id', 'sg', $join);
|
||||
if (empty($goods_info)) return $this->error('', '请先将商品同步到微信侧,等待商品审核通过并已上架');
|
||||
|
||||
$qrcode_res = event('Qrcode', [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => 'weapp',
|
||||
'type' => 'create',
|
||||
'data' => [
|
||||
'goods_id' => $goods_info[ 'goods_id' ],
|
||||
'is_test' => 1
|
||||
],
|
||||
'page' => '/pages/goods/detail',
|
||||
'qrcode_path' => 'upload/qrcode/goods',
|
||||
'qrcode_name' => 'goods_qrcode_' . $goods_info[ 'sku_id' ]
|
||||
], true);
|
||||
if ($qrcode_res[ 'code' ] != 0) return $qrcode_res;
|
||||
|
||||
$goods_info[ 'qrcode_path' ] = $qrcode_res[ 'data' ][ 'path' ];
|
||||
|
||||
return $this->success($goods_info);
|
||||
}
|
||||
}
|
||||
173
addon/shopcomponent/model/Order.php
Executable file
173
addon/shopcomponent/model/Order.php
Executable file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\model;
|
||||
|
||||
use app\dict\order_refund\OrderRefundDict;
|
||||
use app\model\BaseModel;
|
||||
use app\model\order\OrderRefund;
|
||||
|
||||
class Order extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 订单发货之后
|
||||
*/
|
||||
public function delivery($order_id)
|
||||
{
|
||||
$order = model('order')->getInfo([ [ 'order_id', '=', $order_id ] ], 'site_id,is_video_number,pay_type,member_id,order_type');
|
||||
if ($order[ 'is_video_number' ] && $order[ 'pay_type' ] == 'wechatpay') {
|
||||
$member = model('member')->getInfo([ [ 'member_id', '=', $order[ 'member_id' ] ] ], 'weapp_openid');
|
||||
$weapp = new Weapp($order[ 'site_id' ]);
|
||||
$data = [
|
||||
'out_order_id' => $order_id,
|
||||
'openid' => $member[ 'weapp_openid' ],
|
||||
'finish_all_delivery' => 1,
|
||||
'delivery_list' => []
|
||||
];
|
||||
if ($order[ 'order_type' ] == 1) {
|
||||
$package_list = model('express_delivery_package')->getList([ [ 'order_id', '=', $order_id ] ], 'express_company_name,delivery_no,order_goods_id_array');
|
||||
if (!empty($package_list)) {
|
||||
$company_list = $weapp->getCompanyList();
|
||||
foreach ($package_list as $item) {
|
||||
$delivery_id = 'OTHERS';
|
||||
if ($company_list[ 'code' ] == 0) {
|
||||
$index = array_search($item[ 'express_company_name' ], array_column($company_list[ 'data' ], 'delivery_name'));
|
||||
if ($index !== false && isset($company_list[ 'data' ][ $index ])) {
|
||||
$delivery_id = $company_list[ 'data' ][ $index ][ 'delivery_id' ];
|
||||
}
|
||||
}
|
||||
|
||||
$order_goods_model = model('order_goods')->getList([ [ 'order_goods_id', "in", $item[ 'order_goods_id_array' ] ] ], "goods_id,sku_id,num");
|
||||
$goods_id_arr = [];
|
||||
$sku_id_arr = [];
|
||||
$number = 0;
|
||||
foreach ($order_goods_model as $order_iem) {
|
||||
$goods_id_arr[] = $order_iem[ 'goods_id' ];
|
||||
$sku_id_arr[] = $order_iem[ 'sku_id' ];
|
||||
$number += $order_iem[ 'num' ];
|
||||
}
|
||||
|
||||
$data['delivery_list'][] = [
|
||||
'delivery_id' => $delivery_id,
|
||||
'waybill_id' => $item['delivery_no'],
|
||||
'product_info_list' => [
|
||||
[
|
||||
'out_product_id' => implode(',', $goods_id_arr),
|
||||
'out_sku_id' => implode(',', $sku_id_arr),
|
||||
'product_cnt' => $number
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = $weapp->sendDelivery($data);
|
||||
return $res;
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收货
|
||||
* @param $order_id
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function takeDelivery($order_id)
|
||||
{
|
||||
$order = model('order')->getInfo([ [ 'order_id', '=', $order_id ] ], 'site_id,is_video_number,pay_type,member_id,order_type');
|
||||
if ($order[ 'is_video_number' ] && $order[ 'pay_type' ] == 'wechatpay') {
|
||||
$member = model('member')->getInfo([ [ 'member_id', '=', $order[ 'member_id' ] ] ], 'weapp_openid');
|
||||
$weapp = new Weapp($order[ 'site_id' ]);
|
||||
$res = $weapp->recieveDelivery([ 'out_order_id' => $order_id, 'openid' => $member[ 'weapp_openid' ] ]);
|
||||
if ($res[ 'code' ] < 0) {
|
||||
return $this->error('', $res[ 'message' ]);
|
||||
}
|
||||
}
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起退款申请
|
||||
* @param $param
|
||||
*/
|
||||
public function refundApply($param)
|
||||
{
|
||||
$join = [
|
||||
[ 'order o', 'o.order_id = og.order_id', 'left' ]
|
||||
];
|
||||
$info = model('order_goods')->getInfo([ [ 'og.order_goods_id', '=', $param[ 'order_goods_id' ] ] ], 'og.out_aftersale_id,og.order_goods_id,og.goods_id,og.sku_id,og.num,o.order_id,o.site_id,o.is_video_number,o.pay_type,o.member_id', 'og', $join);
|
||||
|
||||
if ($info[ 'is_video_number' ] && $info[ 'pay_type' ] == 'wechatpay') {
|
||||
$member = model('member')->getInfo([ [ 'member_id', '=', $info[ 'member_id' ] ] ], 'weapp_openid');
|
||||
$data = [
|
||||
'out_order_id' => (string) $info[ 'order_id' ],
|
||||
'out_aftersale_id' => $info[ 'out_aftersale_id' ],
|
||||
'openid' => $member[ 'weapp_openid' ],
|
||||
'type' => (int) $param[ 'refund_type' ],
|
||||
'product_info' => [
|
||||
'out_product_id' => (string) $info[ 'goods_id' ],
|
||||
'out_sku_id' => (string) $info[ 'sku_id' ],
|
||||
'product_cnt' => (int) $info[ 'num' ],
|
||||
],
|
||||
'refund_reason' => !empty($param[ 'refund_remark' ]) ? $param[ 'refund_remark' ] : "无",
|
||||
'refund_reason_type' => 12,
|
||||
'orderamt' => round($param[ 'refund_apply_money' ] * 100)
|
||||
];
|
||||
$weapp = new Weapp($info[ 'site_id' ]);
|
||||
$weapp->addAftersale($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 维权状态变更
|
||||
*/
|
||||
public function refundStatusChange($param)
|
||||
{
|
||||
if ($param[ 'refund_status' ] != OrderRefundDict::REFUND_APPLY) {
|
||||
$join = [
|
||||
[ 'order o', 'o.order_id = og.order_id', 'left' ]
|
||||
];
|
||||
$info = model('order_goods')->getInfo([ [ 'og.order_goods_id', '=', $param[ 'order_goods_id' ] ] ], 'og.order_goods_id,og.refund_type,o.order_id,o.site_id,o.is_video_number,o.pay_type,o.member_id', 'og', $join);
|
||||
|
||||
if ($info[ 'is_video_number' ] && $info[ 'pay_type' ] == 'wechatpay') {
|
||||
$data = [
|
||||
'out_order_id' => $info[ 'order_id' ],
|
||||
'out_aftersale_id' => $info[ 'order_goods_id' ],
|
||||
'finish_all_aftersale' => 0
|
||||
];
|
||||
|
||||
// status 0:未受理,1:用户取消,2:商家受理中,3:商家逾期未处理,4:商家拒绝退款,5:商家拒绝退货退款,6:待买家退货,7:退货退款关闭,8:待商家收货,11:商家退款中,12:商家逾期未退款,13:退款完成,14:退货退款完成
|
||||
switch ( $param[ 'refund_status' ] ) {
|
||||
case 0: // 会员取消或商家关闭
|
||||
$data[ 'status' ] = $param[ 'action_way' ] == 1 ? 1 : 0;
|
||||
break;
|
||||
case OrderRefundDict::REFUND_CONFIRM: // 同意退款
|
||||
$data[ 'status' ] = 2;
|
||||
break;
|
||||
case OrderRefundDict::REFUND_DIEAGREE: // 拒绝退款
|
||||
$data[ 'status' ] = $info[ 'refund_type' ] == 1 ? 4 : 5;
|
||||
break;
|
||||
case OrderRefundDict::REFUND_COMPLETE: // 退款完成
|
||||
$data[ 'status' ] = $info[ 'refund_type' ] == 1 ? 13 : 14;
|
||||
$order_goods_count = model('order_goods')->getCount([ [ "order_id", "=", $info[ 'order_id' ] ] ], "order_goods_id");
|
||||
$refund_count = model('order_goods')->getCount([ [ "order_id", "=", $info[ 'order_id' ] ], [ "refund_status", "=", OrderRefundDict::REFUND_COMPLETE ] ], "order_goods_id");
|
||||
if ($order_goods_count == $refund_count) $data[ 'finish_all_aftersale' ] = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// if (isset($data['status'])) {
|
||||
// $weapp = new Weapp($info['site_id']);
|
||||
// $weapp->updateAftersale($data);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
657
addon/shopcomponent/model/Weapp.php
Executable file
657
addon/shopcomponent/model/Weapp.php
Executable file
@@ -0,0 +1,657 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\model;
|
||||
|
||||
use addon\weapp\model\Config as WeappConfigModel;
|
||||
use addon\wxoplatform\model\Config as WxOplatformConfigModel;
|
||||
use app\model\BaseModel;
|
||||
use EasyWeChat\Factory;
|
||||
use think\facade\Cache;
|
||||
|
||||
class Weapp extends BaseModel
|
||||
{
|
||||
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();
|
||||
$plateform_config = $plateform_config[ "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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测自定义交易组件接入状态
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function checkRegister()
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->check();
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'data' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接入申请
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->apply();
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信类目
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function getCatList()
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->get();
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'third_cat_list' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交类目资质
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function auditCategory($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->auditCategory($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'audit_id' ]);
|
||||
} else {
|
||||
return $this->error($result[ 'errcode' ] ?? '', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function addSpu($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->addSpu($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'data' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateSpu($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->updateSpu($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'data' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getSpuPage($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->getSpuList($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success([ 'total' => $result[ 'total_num' ], 'list' => $result[ 'spus' ] ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品上架
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function listing($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->listingSpu($param[ 'product_id' ] ?? '', $param[ 'out_product_id' ] ?? '');
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品下架
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delisting($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->delistingSpu($param[ 'product_id' ] ?? '', $param[ 'out_product_id' ] ?? '');
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delSpu($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->delSpu($param[ 'product_id' ] ?? '', $param[ 'out_product_id' ] ?? '');
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function addOrder($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->addOrder($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'data' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function getOrder($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->getOrder($param[ 'order_id' ] ?? '', $param[ 'out_order_id' ] ?? '', $param[ 'openid' ]);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'order' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单支付状态同步
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function pay($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->payOrder($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取快递公司列表
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getCompanyList()
|
||||
{
|
||||
$cache = Cache::get('weixinCompanyList');
|
||||
if ($cache) return $cache;
|
||||
|
||||
try {
|
||||
$result = $this->app->mini_store->getDeliveryCompanyList();
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
$data = $this->success($result[ 'company_list' ]);
|
||||
Cache::set('weixinCompanyList', $data);
|
||||
return $data;
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function sendDelivery($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->sendDelivery($param[ 'order_id' ] ?? '', $param[ 'out_order_id' ] ?? '', $param[ 'openid' ], $param[ 'finish_all_delivery' ], $param[ 'delivery_list' ]);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收货
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function recieveDelivery($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->recieveDelivery($param[ 'order_id' ] ?? '', $param[ 'out_order_id' ] ?? '', $param[ 'openid' ]);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建售后
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addAftersale($param)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->addAftersale($param);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审核状态
|
||||
* @param $audit_id
|
||||
* @return array
|
||||
*/
|
||||
public function getAuditResult($audit_id)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->auditResult($audit_id);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result[ 'data' ]);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成接入任务
|
||||
* @param $item
|
||||
* @return array
|
||||
*/
|
||||
public function finishAccessInfo($item)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->finish_access_info($item);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success();
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片信息
|
||||
* @param $item
|
||||
* @return array
|
||||
*/
|
||||
public function getImg($url)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->uploadImg($url);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateShop($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->updateShop($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateOrderType($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->updateOrderType($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function createOrder($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->addOrder($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getPaymentParams($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->getPaymentParams($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return array
|
||||
* 同意退款
|
||||
*/
|
||||
public function orderRefund($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->orderRefund($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return array
|
||||
* 拒绝退款
|
||||
*/
|
||||
public function orderNoRefund($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->orderNoRefund($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return array
|
||||
* 同意退货
|
||||
*/
|
||||
public function aceptreturn($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->aceptreturn($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return array
|
||||
* 同意退货
|
||||
*/
|
||||
public function cancel($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->cancel($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 卖家发货
|
||||
*/
|
||||
public function uploadreturninfo($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->uploadreturninfo($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//获取售后详情
|
||||
public function getAftersale($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->getAftersale($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新售后
|
||||
* @param $param
|
||||
* @return array
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateAftersale($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->updateAftersale($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return array
|
||||
* 获取售后订单列表
|
||||
*/
|
||||
public function getOrderList($params)
|
||||
{
|
||||
try {
|
||||
$result = $this->app->mini_store->getOrderList($params);
|
||||
if (isset($result[ 'errcode' ]) && $result[ 'errcode' ] == 0) {
|
||||
return $this->success($result);
|
||||
} else {
|
||||
return $this->error('', $result[ 'errmsg' ]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
100
addon/shopcomponent/shop/controller/Category.php
Executable file
100
addon/shopcomponent/shop/controller/Category.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\shopcomponent\model\Category as CategoryModel;
|
||||
|
||||
/**
|
||||
* 类目
|
||||
*/
|
||||
class Category extends BaseShop
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
$third_cat_id = input('third_cat_id', '');
|
||||
|
||||
if (request()->isJson()) {
|
||||
$category = new CategoryModel();
|
||||
$page = input('page', 1);
|
||||
$keywords = empty(input('keywords')) ? '' : input('keywords');
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
if (!empty($keywords)) {
|
||||
$condition [] = [ 'first_cat_name|second_cat_name|third_cat_name', 'like', '%' . $keywords . '%' ];
|
||||
}
|
||||
if (!empty($third_cat_id)) {
|
||||
$condition [] = [ 'third_cat_id', '=', $third_cat_id ];
|
||||
}
|
||||
|
||||
$condition [] = [ 'site_id', '=', $this->site_id ];
|
||||
|
||||
$data = $category->getCategoryPageList($condition, '*', 'first_cat_id asc,second_cat_id asc,third_cat_id asc', $page, $page_size);
|
||||
return $data;
|
||||
} else {
|
||||
$this->assign('third_cat_id', $third_cat_id);
|
||||
|
||||
return $this->fetch('category/index');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步商品类目
|
||||
* @return array
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$category = new CategoryModel();
|
||||
$res = $category->syncCategory($this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传资质
|
||||
* @return array
|
||||
*/
|
||||
public function qualifications()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$category = new CategoryModel();
|
||||
$param = input();
|
||||
$res = $category->uploadQualifications($param, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类通过上级
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoryByParent()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$category = new CategoryModel();
|
||||
$level = input('level', 1);
|
||||
$pid = input('pid', 0);
|
||||
$res = $category->getCategoryByParent($level, $pid);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步类目状态
|
||||
*/
|
||||
public function syncAuditResult()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
( new CategoryModel() )->syncCategoryAuditStatus($this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
186
addon/shopcomponent/shop/controller/Goods.php
Executable file
186
addon/shopcomponent/shop/controller/Goods.php
Executable file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\shopcomponent\shop\controller;
|
||||
|
||||
use addon\shopcomponent\model\Category;
|
||||
use addon\shopcomponent\model\Weapp;
|
||||
use app\model\system\Cron;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\shopcomponent\model\Goods as GoodsModel;
|
||||
use addon\shopcomponent\model\Category as CategoryModel;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
class Goods extends BaseShop
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$goods = new GoodsModel();
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$condition = [
|
||||
'sg.site_id' => $this->site_id
|
||||
];
|
||||
$data = $goods->getGoodsPageList($condition, '*', 'id desc', $page, $page_size);
|
||||
return $data;
|
||||
} else {
|
||||
$category = ( new Category() )->getCategoryByParent(1);
|
||||
$this->assign('first_cat', $category[ 'data' ]);
|
||||
|
||||
$check_res = ( new Weapp($this->site_id) )->checkRegister();
|
||||
$this->assign('checkres', $check_res);
|
||||
|
||||
return $this->fetch('goods/index');
|
||||
}
|
||||
}
|
||||
|
||||
public function sync()
|
||||
{
|
||||
$start = input('start', 0);
|
||||
$res = ( new GoodsModel() )->syncGoods($start, 100, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序添加商品
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$param = input();
|
||||
if (empty($param)) $this->error('必要参数必填');
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'goods_ids' => $param[ 'goods_ids' ],
|
||||
'third_cat_id' => $param[ 'third_cat_id' ],
|
||||
];
|
||||
$goods_model = new GoodsModel();
|
||||
return $goods_model->addGoods($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序修改商品分类
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$param = input();
|
||||
if (empty($param)) $this->error('必要参数必填');
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'goods_id' => $param[ 'goods_id' ],
|
||||
'third_cat_id' => $param[ 'third_cat_id' ],
|
||||
];
|
||||
$goods_model = new GoodsModel();
|
||||
return $goods_model->updateGoods($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检验分类是否已上传资质
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$param = input();
|
||||
if (empty($param)) $this->error('必要参数必填');
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'third_cat_id' => $param[ 'third_cat_id' ],
|
||||
];
|
||||
$cat_model = new CategoryModel();
|
||||
return $cat_model->isQualifications($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序删除商品
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$goods_model = new GoodsModel();
|
||||
return $goods_model->deleteGoods(input('out_product_ids', ''), $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品上架
|
||||
*/
|
||||
public function listing()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$goods_model = new GoodsModel();
|
||||
$out_product_ids = input('out_product_ids', '');
|
||||
return $goods_model->goodsListing($out_product_ids, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品下架
|
||||
*/
|
||||
public function dellisting()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$goods_model = new GoodsModel();
|
||||
$out_product_ids = input('out_product_ids', '');
|
||||
return $goods_model->goodsDelisting($out_product_ids, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频号接入
|
||||
* @return mixed
|
||||
*/
|
||||
public function access()
|
||||
{
|
||||
$weapp = new Weapp($this->site_id);
|
||||
if (request()->isJson()) {
|
||||
$res = $weapp->apply();
|
||||
if ($res[ 'code' ] == 0) {
|
||||
( new Cron() )->addCron(1, 0, '同步微信类目', 'SyncWxCategory', time(), $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
$checkres = $weapp->checkRegister();
|
||||
$this->assign('checkres', $checkres);
|
||||
|
||||
return $this->fetch('goods/access');
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成接入任务
|
||||
*/
|
||||
public function finishAccess()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$item = input('item', '');
|
||||
$weapp = new Weapp($this->site_id);
|
||||
$res = $weapp->finishAccessInfo($item);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单测试数据
|
||||
*/
|
||||
public function getOrderPayInfo()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$goods_model = new GoodsModel();
|
||||
$res = $goods_model->getOrderPayInfo($this->site_id);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
397
addon/shopcomponent/shop/view/category/index.html
Executable file
397
addon/shopcomponent/shop/view/category/index.html
Executable file
@@ -0,0 +1,397 @@
|
||||
<style>
|
||||
.progress-layer {width:400px;background:#fff;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:1px 1px 50px rgba(0,0,0,.3);padding:20px 20px;z-index:100;display:none;}
|
||||
.progress-layer h3 {line-height:1;margin-bottom:15px;text-align:center;font-size:14px;}
|
||||
.progress-layer .layui-progress-big,.progress-layer .layui-progress-big .layui-progress-bar {height:14px;line-height:14px;}
|
||||
.progress-layer .layui-progress-text {line-height:14px;}
|
||||
.goods-info {padding: 5px 0;align-items: center;flex-wrap:unset!important;}
|
||||
.goods-info .room-name {padding-left: 5px;line-height: 1}
|
||||
.goods-info img {width:50px;height: 50px;}
|
||||
.single-filter-box{display: flex; justify-content: space-between}
|
||||
.category-search {padding: 20px;}
|
||||
.search-item {margin-bottom: 20px;display: flex;justify-content: space-between;}
|
||||
.item-right select {margin-right: 20px;width: 80px; height: 25px;}
|
||||
.qualification {line-height: 1.5;background: #f5f5f5;color: #999;font-size: 12px;padding: 10px;border: 1px solid #eee;border-radius: 2px}
|
||||
.layui-form-label{width: 205px}
|
||||
.reject-reason {height: 100%;padding-bottom: 20px;}
|
||||
</style>
|
||||
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="sync()">同步类目库</button>
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="keywords" placeholder="类目搜索" autocomplete="off" class="layui-input">
|
||||
<button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <a href="{:href_url('live://shop/goods/add')}" class="layui-btn layui-btn-primary">添加商品</a>-->
|
||||
</div>
|
||||
<table id="category_list" lay-filter="category_list"></table>
|
||||
|
||||
<!-- 修改服务类目弹出层 -->
|
||||
<script type="text/html" id="sev">
|
||||
<div class="goods-service">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">服务类目:</label>
|
||||
<div class="layui-input-block">
|
||||
<p>{{d.leimu}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>营业执照或组织机构代码证:</label>
|
||||
<div class="layui-input-block img-upload">
|
||||
<div class="upload-img-block">
|
||||
<div class="upload-img-box {{# if (d.license){ }}hover{{# } }}">
|
||||
<div class="upload-default" id="license">
|
||||
{{# if(d.license){ }}
|
||||
<div id="preview_licenseUpload" class="preview_img">
|
||||
<img layer-src src="{{ ns.img(d.license)}}" class="img_prev"/>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="upload">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>上传资质</p>
|
||||
</div>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="operation">
|
||||
<div>
|
||||
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
|
||||
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
|
||||
</div>
|
||||
<div class="replace_img js-replace">点击替换</div>
|
||||
</div>
|
||||
<input type="hidden" name="license" id="zhengshu" value="{{# if(d.license){ }}{{d.license}}{{# } }}" lay-verify="license"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{# if(d.qualification_type !=0){ }}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">{{# if(d.qualification_type==1){ }}*{{# } }}</span>上传类目资质:</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="qualification">{{d.qualification}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block img-upload">
|
||||
<div class="upload-img-block">
|
||||
<div class="upload-img-box {{# if (d.certificate){ }}hover{{# } }}">
|
||||
<div class="upload-default" id="category">
|
||||
{{# if(d.certificate){ }}
|
||||
<div id="preview_categoryUpload" class="preview_img">
|
||||
<img layer-src src="{{ ns.img(d.certificate)}}" class="img_prev"/>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="upload">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>上传资质</p>
|
||||
</div>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="operation">
|
||||
<div>
|
||||
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
|
||||
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
|
||||
</div>
|
||||
<div class="replace_img js-replace">点击替换</div>
|
||||
</div>
|
||||
<input type="hidden" name="category" id="leimu_qualification" value="{{# if(d.certificate){ }}{{d.certificate}}{{# } }}" lay-verify="category"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">类目资质示例可到<a href="https://developers.weixin.qq.com/doc/ministore/minishopspecification/leimuzizhi/qiyeleimu.html" class="text-color" target="_blank">《非个人主体开放类目资质要求》</a>中查看</div>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# if(d.product_qualification_type !=0){ }}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">{{# if(d.product_qualification_type==1){ }}*{{# } }}</span>上传商品资质:</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="qualification">{{d.product_qualification}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block img-upload">
|
||||
<div class="upload-img-block">
|
||||
<div class="upload-img-box {{# if (d.qualification_pics){ }}hover{{# } }}" >
|
||||
<div class="upload-default" id="product">
|
||||
{{# if(d.qualification_pics){ }}
|
||||
<div id="preview_productUpload" class="preview_img">
|
||||
<img layer-src src="{{ ns.img(d.qualification_pics)}}" class="img_prev"/>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="upload">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>上传资质</p>
|
||||
</div>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="operation">
|
||||
<div>
|
||||
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
|
||||
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
|
||||
</div>
|
||||
<div class="replace_img js-replace">点击替换</div>
|
||||
</div>
|
||||
<input type="hidden" name="product" id="product_qualification" value="{{# if(d.qualification_pics){ }}{{d.qualification_pics}}{{# } }}" lay-verify="product"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux">商品资质示例可到<a href="https://developers.weixin.qq.com/doc/ministore/minishopspecification/leimuzizhi/qiyeshangpin.html" class="text-color" target="_blank">《非个人主体开放类目商品资质要求》</a>中查看</div>
|
||||
</div>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="reason">
|
||||
<div class="reject-reason">{{d.reject_reason}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
{{# if(d.status!=1){ }}
|
||||
{{# if( (d.qualification_type != 0) || (d.product_qualification_type != 0) ){ }}
|
||||
<a class="layui-btn" lay-event="audit">上传资质</a>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d.status==9){ }}
|
||||
<a class="layui-btn" lay-event="reason">查看失败原因</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<div class="progress-layer">
|
||||
<!-- <h3>正在同步中...</h3>-->
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="false" lay-filter="progress">
|
||||
<!-- <div class="layui-progress-bar layui-bg-blue" lay-percent="0%"></div>-->
|
||||
<div class="layui-anim" data-anim="layui-anim-rotate layui-anim-loop">正在同步中...</div>
|
||||
<!-- <div class="code">追加:layui-anim-loop</div>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var laytpl;
|
||||
var layer;
|
||||
var form,table,element,syncClick = false,repeat_flag = false;
|
||||
layui.use(['form','layer','laytpl' ,'element'], function() {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
var layer = layui.layer;
|
||||
element = layui.element;
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
table = new Table({
|
||||
elem: '#category_list',
|
||||
url: ns.url("shopcomponent://shop/category/lists"),
|
||||
where: {
|
||||
"keywords": $(".keywords").val(),
|
||||
"third_cat_id" : "{$third_cat_id}",
|
||||
{notempty name="$third_cat_id"}"page": 1{/notempty}
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
title: '类目',
|
||||
unresize: 'false',
|
||||
width: '30%',
|
||||
field: 'leimu'
|
||||
}, {
|
||||
title: '类目资质',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
field: 'qualification_type_name'
|
||||
},{
|
||||
title: '商品资质',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
field: 'product_qualification_type_name'
|
||||
}, {
|
||||
field: 'audit_time',
|
||||
title: '审核时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
}, {
|
||||
field: 'status_name',
|
||||
title: '审核状态',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'audit': //上传资质
|
||||
laytpl($("#sev").html()).render(data, function(html) {
|
||||
layer.open({
|
||||
type: 1,
|
||||
shadeClose: true,
|
||||
shade: 0.3,
|
||||
offset: 'auto',
|
||||
scrollbar: true,
|
||||
fixed: false,
|
||||
title: "上传资质",
|
||||
area: ['800px', 'auto'],
|
||||
btn: ['确认', '取消'],
|
||||
content: html,
|
||||
yes: function(){
|
||||
var first_cat_id = data.first_cat_id;
|
||||
var second_cat_id = data.second_cat_id;
|
||||
var third_cat_id = data.third_cat_id;
|
||||
var zhengshu =$('#zhengshu').val();
|
||||
var leimu_qualification =$('#leimu_qualification').val();
|
||||
var product_qualification =$('#product_qualification').val();
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/category/qualifications"),
|
||||
data: {first_cat_id:first_cat_id,second_cat_id:second_cat_id,third_cat_id:third_cat_id,zhengshu:zhengshu,leimu_qualification:leimu_qualification,product_qualification:product_qualification},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('操作成功', {
|
||||
title: '操作提示',
|
||||
btn: ['返回列表', '继续操作'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("shopcomponent://shop/category/lists")
|
||||
layer.closeAll()
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
success: function(){
|
||||
form.render();
|
||||
|
||||
var categoryUpload = new Upload({
|
||||
elem: '#category'
|
||||
});
|
||||
var productUpload = new Upload({
|
||||
elem: '#product'
|
||||
});
|
||||
var licenseUpload = new Upload({
|
||||
elem: '#license'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
break;
|
||||
case 'reason': //查看失败原因
|
||||
laytpl($("#reason").html()).render(data, function(html) {
|
||||
layer.open({
|
||||
type: 1,
|
||||
shadeClose: true,
|
||||
shade: 0.3,
|
||||
offset: 'auto',
|
||||
scrollbar: true,
|
||||
fixed: false,
|
||||
title: "失败原因",
|
||||
area: ['450px', 'auto'],
|
||||
btn: ['退出'],
|
||||
content: html,
|
||||
});
|
||||
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 同步商品
|
||||
function sync(start){
|
||||
if (syncClick) return;
|
||||
syncClick = true;
|
||||
var start = start == undefined ? 0 : start;
|
||||
// $(".progress-layer").show();
|
||||
i=showSync();
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/category/sync"),
|
||||
data: {
|
||||
start: start,
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
syncClick = false;
|
||||
if (res.code == 0) {
|
||||
var data = res.data,
|
||||
next = parseInt(start) + 1;
|
||||
|
||||
if (next < data.total_page) {
|
||||
if (start == 0) {
|
||||
$(".progress-layer").fadeOut();
|
||||
}
|
||||
var progress = (next / data.total_page * 100).toFixed(2);
|
||||
element.progress('progress', progress + '%');
|
||||
// 拉取下一页
|
||||
sync(next);
|
||||
} else {
|
||||
if (!$(".progress-layer").is(':hidden')) $(".progress-layer").fadeOut();
|
||||
closeSync(i);
|
||||
layer.closeAll();
|
||||
layer.msg('同步成功');
|
||||
table.reload();
|
||||
}
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 同步等待
|
||||
function showSync() {
|
||||
return layer.msg('正在同步中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: 'auto', time:100000});
|
||||
}
|
||||
// 关闭
|
||||
function closeSync(index) {
|
||||
layer.close(index);
|
||||
|
||||
}
|
||||
$('#layerDemo .layui-btn').on('click', function(){
|
||||
var othis = $(this), method = othis.data('method');
|
||||
active[method] ? active[method].call(this, othis) : '';
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/category/syncauditresult"),
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
281
addon/shopcomponent/shop/view/goods/access.html
Executable file
281
addon/shopcomponent/shop/view/goods/access.html
Executable file
@@ -0,0 +1,281 @@
|
||||
<style type="text/css">
|
||||
.access{padding: 10px;}
|
||||
.access-title {font-size: 18px;font-family: Microsoft YaHei;font-weight: 400;color: #333333;}
|
||||
.access-item{background-color: #F8F8F8;display: flex;flex-direction: column;justify-content: space-between;}
|
||||
.item {display: flex;justify-content: space-between;margin: 20px 0 20px 10px;}
|
||||
.item-datail {position: relative;}
|
||||
.item-number {width: 30px;height: 30px;border-radius: 50%;border: 5px solid #eee;position: absolute;top: -5px;left: -45px;box-sizing: border-box;font-size: 10px;line-height: 20px;}
|
||||
.item-number label{width: 20px;height: 20px;background: #ddd;border-radius: 50%; text-align: center;color: #FFFFFF !important;display: inline-block;font-size: 12px;}
|
||||
.item-number.active {border: 5px solid;}
|
||||
.item-number.active label {background: var(--base-color);}
|
||||
.item-check{position: absolute;top: 5px; left: 20px;width: 25px;height: 25px;background: #CCCCCC;border-radius: 50%;display: flex;align-items: center;justify-content: center;}
|
||||
.item-check i{border-radius: 50%;border: none;font-size: 14px;color: #fff}
|
||||
.item-checked{border-radius: 50%;}
|
||||
.item-checked i {color: var(--base-color);}
|
||||
.item-datail div {font-size: 14px;font-family: Microsoft YaHei;font-weight: 400;color: #333333;margin-bottom: 10px;}
|
||||
.item-datail p {display: inline-block; font-size: 12px;font-family: Microsoft YaHei;font-weight: 400;color: #999999;}
|
||||
.item-datail a {font-size: 12px;font-family: Microsoft YaHei;font-weight: 400;color: var(--base-color) !important;}
|
||||
.item button {width: 88px;height: 34px;background: var(--base-color);border-radius: 2px;border: 1px solid #FFFFFF;font-weight: 400;color: #FFFFFF;cursor: pointer;}
|
||||
.item span,.item a,.item button {margin-right: 40px;margin-top: 10px;}
|
||||
.layui-timeline-item:before{top: 27px;}
|
||||
.order-pay-layer .wrap{display: flex;}
|
||||
.order-pay-layer .wrap .flex{flex: 1}
|
||||
.order-pay-layer .wrap .flex:last-child{border-left: 1px solid #eee}
|
||||
.order-pay-layer .qrcode img{width: 150px;margin: auto;display: block;}
|
||||
.order-pay-layer .goods-name {margin-right: 15px;font-weight: bold;}
|
||||
.order-pay-layer .price {margin-right: 15px;margin-top: 15px;font-weight: bold;}
|
||||
.order-pay-layer .tips {margin-bottom: 15px;}
|
||||
a:hover{text-decoration: none!important;cursor: pointer}
|
||||
</style>
|
||||
|
||||
<div class="access">
|
||||
<div class="access-title">微信视频号</div>
|
||||
<ul class="layui-timeline">
|
||||
<li class="layui-timeline-item">
|
||||
<div class="layui-timeline-content layui-text">
|
||||
<div class="item">
|
||||
<div class="item-datail">
|
||||
<div class="item-number active border-color-light-9">
|
||||
<label>1</label>
|
||||
</div>
|
||||
<div>创建微信视频号</div>
|
||||
<p>在微信中创建视频号,如已有视频号可越过该步骤。</p>
|
||||
</div>
|
||||
<a href="https://www.kancloud.cn/niucloud/niushop_b2c_v4/2251549" target="_blank" class="layui-btn">接入指南</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="layui-timeline-item">
|
||||
<div class="layui-timeline-content layui-text">
|
||||
<div class="item">
|
||||
<div class="item-datail">
|
||||
<div class="item-number {if $checkres['code'] == 0 && $checkres['data']['status'] == 2}active border-color-light-9{/if}">
|
||||
<label>2</label>
|
||||
</div>
|
||||
<div>申请开通自定义版交易组件</div>
|
||||
<p>完成自定义版交易组件接入后,小程序即可在视频号中实现商品展示和带货等功能,进一步提升经营能力。若您已开通标准化交易组件,则暂不支持切换</p>
|
||||
</div>
|
||||
{if $checkres['code'] == 0}
|
||||
{if $checkres['data']['status'] != 2 && $checkres['data']['status'] != 3}
|
||||
<button type="button" onclick="apply()">立即开通</button>
|
||||
{/if}
|
||||
{else/}
|
||||
<button type="button" onclick="apply()">立即开通</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="access-item">
|
||||
<div class="item">
|
||||
<div class="item-datail">
|
||||
<div class="item-check {if $checkres['code'] == 0 && $checkres['data']['status'] == 2}item-checked bg-color-light-9{/if}">
|
||||
<i class="iconfont iconduihao"></i>
|
||||
</div>
|
||||
<div style="margin-left: 60px;">
|
||||
<label>完成自定义版交易组件开通申请</label>
|
||||
<br>
|
||||
<p>官方审核团队将对接入资质进行审核,通过后可进行下一步操作。</p>
|
||||
</div>
|
||||
</div>
|
||||
{if $checkres['code'] == 0}
|
||||
{if $checkres['data']['status'] == 2}
|
||||
<span>已开通</span>
|
||||
{elseif $checkres['data']['status'] == 3}
|
||||
<span>封禁中</span>
|
||||
{else/}
|
||||
<span>未开通</span>
|
||||
{/if}
|
||||
{else/}
|
||||
<span>未开通</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="layui-timeline-item">
|
||||
<div class="layui-timeline-content layui-text">
|
||||
<div class="item">
|
||||
<div class="item-datail">
|
||||
<div class="item-number {if $checkres['code'] == 0 && $checkres['data']['status'] == 2}active border-color-light-9{/if}">
|
||||
<label>3</label>
|
||||
</div>
|
||||
<div>自定义版交易组件申请通过,接口调用场景检测</div>
|
||||
<p>自定义交易组件开通之后,如果当前小程序版本低于4.1.5,则需下载4.1.5或更高版本小程序进行发布,<a href="{:href_url('weapp://shop/weapp/package')}" target="_blank">前去发布</a></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="access-item">
|
||||
<div class="item">
|
||||
<div class="item-datail">
|
||||
<div class="item-check {if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['spu_audit_finished'] eq 1}item-checked bg-color-light-9{/if}">
|
||||
<i class="iconfont iconduihao"></i>
|
||||
</div>
|
||||
<div style="margin-left: 60px;">
|
||||
<label>商品接口调用</label>
|
||||
<br>
|
||||
<p>请至少将一件商品同步到微信,并等待商品审核通过<a href="{:href_url('shopcomponent://shop/goods/lists')}">前去添加</a></p>
|
||||
</div>
|
||||
</div>
|
||||
{if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['spu_audit_finished'] eq 1}
|
||||
<span>已完成</span>
|
||||
{else/}
|
||||
<button type="button" onclick="finishAccess(6)">完成</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="item" style="margin-top: 0;">
|
||||
<div class="item-datail">
|
||||
<div class="item-check {if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['ec_order_finished'] eq 1}item-checked bg-color-light-9{/if}">
|
||||
<i class="iconfont iconduihao"></i>
|
||||
</div>
|
||||
<div style="margin-left: 60px;">
|
||||
<label>订单接口调用</label>
|
||||
<br>
|
||||
<p>需手动扫码下单,使用微信支付并付款成功</p>
|
||||
</div>
|
||||
</div>
|
||||
{if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['ec_order_finished'] eq 1}
|
||||
<span>已完成</span>
|
||||
{else/}
|
||||
{if $checkres['code'] == 0 && $checkres['data']['access_info']['pay_order_success'] eq 1}
|
||||
<button type="button" onclick="finishAccess(7)">完成</button>
|
||||
{else/}
|
||||
<button type="button" onclick="orderPay()">扫码下单</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
<div class="item" style="margin-top: 0;">
|
||||
<div class="item-datail">
|
||||
<div class="item-check {if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['send_delivery_finished'] eq 1}item-checked bg-color-light-9{/if}">
|
||||
<i class="iconfont iconduihao"></i>
|
||||
</div>
|
||||
<div style="margin-left: 60px;">
|
||||
<label>物流接口调用</label>
|
||||
<br>
|
||||
<p>订单支付之后,需对该测试订单进行发货操作</p>
|
||||
</div>
|
||||
</div>
|
||||
{if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['send_delivery_finished'] eq 1}
|
||||
<span>已完成</span>
|
||||
{else/}
|
||||
<button type="button" onclick="finishAccess(8)">完成</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="item" style="margin-top: 0;">
|
||||
<div class="item-datail">
|
||||
<div class="item-check {if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['ec_after_sale_finished'] eq 1}item-checked bg-color-light-9{/if}">
|
||||
<i class="iconfont iconduihao"></i>
|
||||
</div>
|
||||
<div style="margin-left: 60px;">
|
||||
<label>售后接口调用</label>
|
||||
<br>
|
||||
<p>订单发货之后,需下单人对该测试订单进行申请售后操作</p>
|
||||
</div>
|
||||
</div>
|
||||
{if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['ec_after_sale_finished'] eq 1}
|
||||
<span>已完成</span>
|
||||
{else/}
|
||||
<button type="button" onclick="finishAccess(9)">完成</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="layui-timeline-item">
|
||||
<div class="layui-timeline-content layui-text">
|
||||
<div class="item">
|
||||
<div class="item-datail">
|
||||
<div class="item-number {if $checkres['code'] == 0 && $checkres['data']['status'] == 2 && $checkres['data']['access_info']['ec_after_sale_finished'] eq 1}active border-color-light-9{/if}">
|
||||
<label>4</label>
|
||||
</div>
|
||||
<div>自定义版交易组件开通成功</div>
|
||||
<p>开通成功之后可在小程序中“功能>交易组件>场景接入>视频号推广”中关联视频号,关联之后视频号管理员可前往“视频号创作者中心>商品橱窗”中添加商品<a href="https://mp.weixin.qq.com" target="_blank">前去添加</a>。 </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="orderPay">
|
||||
<div class="order-pay-layer">
|
||||
<div class="tips text-color">注:需使用微信扫码下单使用微信支付,且支付成功。</div>
|
||||
<div class="wrap">
|
||||
<div class="flex">
|
||||
<div class="goods-name">{{ d.goods_name }}</div>
|
||||
<div class="price">¥{{ d.price }}</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="qrcode">
|
||||
<img src="{{ ns.img(d.qrcode_path) }}" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var laytpl,repeatTag = false;
|
||||
layui.use(['laytpl'], function() {
|
||||
laytpl = layui.laytpl;
|
||||
});
|
||||
|
||||
function apply(){
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/access"),
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
if (res.code == 0) {
|
||||
layer.msg('开通成功');
|
||||
setTimeout(function () {
|
||||
listenerHash(); // 刷新页面
|
||||
}, 500)
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function orderPay() {
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/getorderpayinfo"),
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
if (res.code == 0) {
|
||||
laytpl($('#orderPay').html()).render(res.data, function(string){
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '订单测试',
|
||||
content: string,
|
||||
area: ['500px', '340px'],
|
||||
btn: ['支付成功', '取消'],
|
||||
yes: function () {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.closeAll();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function finishAccess(item) {
|
||||
if (repeatTag) return;
|
||||
repeatTag = true;
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/finishaccess"),
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
data: {item: item},
|
||||
success: function (res) {
|
||||
repeatTag = false;
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
711
addon/shopcomponent/shop/view/goods/index.html
Executable file
711
addon/shopcomponent/shop/view/goods/index.html
Executable file
@@ -0,0 +1,711 @@
|
||||
<style>
|
||||
.progress-layer {width:400px;background:#fff;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:1px 1px 50px rgba(0,0,0,.3);padding:20px 20px;z-index:100;display:none;}
|
||||
.progress-layer h3 {line-height:1;margin-bottom:15px;text-align:center;font-size:14px;}
|
||||
.progress-layer .layui-progress-big,.progress-layer .layui-progress-big .layui-progress-bar {height:14px;line-height:14px;}
|
||||
.progress-layer .layui-progress-text {line-height:14px;}
|
||||
.goods-info {padding: 5px 0;align-items: center;flex-wrap:unset!important;float: left !important;}
|
||||
.goods-info .room-name {padding-left: 5px;line-height: 1}
|
||||
.goods-info img {width:50px;height: 50px;}
|
||||
.single-filter-box{justify-content: end}
|
||||
.add-good-form .layui-input-block {width: 450px;}
|
||||
.add-good-form .layui-form-item {position: relative;}
|
||||
.add-good-form .category-wrap {position: absolute; left: 150px; top: 40px; z-index: 9; background-color: #FFFFFF; border: 1px solid #EEEEEE;}
|
||||
.add-good-form .category-wrap .category-list {display: flex;}
|
||||
.add-good-form .category-wrap ul {width: 151px; height: 300px; overflow: auto; background-color: #FFFFFF; border-right: 1px solid #EEEEEE; box-sizing: border-box;}
|
||||
.add-good-form .category-wrap ul:last-child {border-right: 1px solid #EEEEEE;}
|
||||
.add-good-form .category-wrap ul li {line-height: 26px; padding: 0 15px; cursor: pointer;}
|
||||
.add-good-form .category-wrap .category-btn {width: 100%; padding: 10px 15px; box-sizing: border-box; border-top: 1px solid #EEEEEE;}
|
||||
.layui-layer-page .layui-layer-content {overflow: auto !important; position: relative;}
|
||||
.goods-category-mask {width: 100%; height: 100%; position: absolute; left: 0; top: 0; z-index: 9;}
|
||||
.selected-style {color: #FFFFFF;}
|
||||
.reject-reason {height: 100%;padding-bottom: 20px;}
|
||||
.reason .layui-layer-content {overflow: unset!important}
|
||||
</style>
|
||||
|
||||
{if $checkres['code'] != 0 || $checkres['data']['status'] != 2}
|
||||
<div>
|
||||
<div style="margin-top:10% ">
|
||||
<div style="text-align:center;margin: auto;">
|
||||
<img src="SHOP_IMG/empty.jpg.png" alt="">
|
||||
</div>
|
||||
<div style="text-align:center;margin: auto;margin-top: 10px">
|
||||
<span >视频号未入驻,请先完成视频号入驻</span>
|
||||
</div>
|
||||
<div style="text-align:center;margin: auto;margin-top: 10px">
|
||||
<a href="{:href_url('shopcomponent://shop/goods/access')}" class="text-color">立即处理</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{else/}
|
||||
<div class="single-filter-box">
|
||||
<a href="javascript:addGood();" class="layui-btn ">添加商品</a>
|
||||
<!-- <button class="layui-btn layui-btn-primary " onclick="sync()">同步刷新</button>-->
|
||||
</div>
|
||||
<table id="goods_list" lay-filter="goods_list"></table>
|
||||
{/if}
|
||||
<!-- 直播间信息 -->
|
||||
<script type="text/html" id="goodsinfo">
|
||||
<div class="table-btn goods-info">
|
||||
<img src="{{ ns.img(d.cover_img) }}">
|
||||
<span class="room-name" title="{{ d.goods_name }}">{{ d.goods_name }}</span>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="cat">
|
||||
<div class="table-btn goods-info" style="position: relative">
|
||||
<!-- <input type="text" value="{{d.out_product_id}}" hidden id="goods_id">-->
|
||||
<span class="room-name" style="float: right; width: 100%; overflow: hidden; z-index: 1" title="{{ d.cat_name }}">{{ d.cat_name }}</span> | <span class="text-color" style="float:left;z-index: 100; margin-right: 1px;cursor:pointer" onclick="check_cat({{d.out_product_id}})">修改</span>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="reason">
|
||||
<div class="reject-reason">{{d.reject_reason}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态修改 -->
|
||||
<script type="text/html" id="goodsStatus">
|
||||
<div class="table-btn goods-info" style="position: relative">
|
||||
<span class="room-name {{# if(d.status==5){ }} text-color {{# } }} " {{# if(d.status!=5){ }}style="color:#808080" {{# } }} title="{{ d.status_name }}">{{ d.status_name }}</span>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
{{# if(d.edit_status==3){ }}
|
||||
<a class="layui-btn" lay-event="reason">查看失败原因</a>
|
||||
{{# } }}
|
||||
{{# if(d.edit_status==4){ }}
|
||||
{{# if(d.status==5){ }}
|
||||
<a class="layui-btn" lay-event="dellisting">下架</a>
|
||||
{{# } }}
|
||||
{{# if(d.status!=5){ }}
|
||||
<a class="layui-btn" lay-event="listing">上架</a>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="batchOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="listing">批量上架</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="dellisting">批量下架</button>
|
||||
</script>
|
||||
<div class="progress-layer">
|
||||
<h3>正在同步中...</h3>
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="true" lay-filter="progress">
|
||||
<div class="layui-progress-bar layui-bg-blue" lay-percent="0%"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var form, table, element, laytpl, syncClick = false,
|
||||
delete_flag = false,
|
||||
save_flag = false,saveEdit_flag = false,
|
||||
dellisting_flag = false,
|
||||
listing_flag = false,
|
||||
goodsId = [], selectedGoodsId = [], goods_list = [],out_product_id='',
|
||||
cate_level_1_id = 0, cate_level_2_id = 0, cate_level_3_id = 0;
|
||||
reLoad();
|
||||
function reLoad() {
|
||||
layui.use(['form', 'element', 'laytpl'], function () {
|
||||
form = layui.form;
|
||||
element = layui.element;
|
||||
laytpl = layui.laytpl;
|
||||
|
||||
table = new Table({
|
||||
elem: '#goods_list',
|
||||
url: ns.url("shopcomponent://shop/goods/lists"),
|
||||
bottomToolbar: "#batchOperation",
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox',
|
||||
unresize: 'false',
|
||||
width: '3%'
|
||||
}, {
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: "#goodsinfo",
|
||||
align:'left'
|
||||
}, {
|
||||
title: '微信商品类目',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: "#cat",
|
||||
align:'left'
|
||||
}, {
|
||||
title: '价格',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
field: 'price'
|
||||
}, {
|
||||
field: 'goods_stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '6%'
|
||||
}, {
|
||||
templet: "#goodsStatus",
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '提交时间',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
field: 'audit_time',
|
||||
title: '审核时间',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
field: 'edit_status_name',
|
||||
title: '审核状态',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
table.tool(function (obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'delete': //删除
|
||||
deleteGoods(data.out_product_id);
|
||||
break;
|
||||
case 'listing': //上架
|
||||
listingGoods(data.out_product_id);
|
||||
break;
|
||||
case 'dellisting': //下架
|
||||
dellistingGoods(data.out_product_id);
|
||||
break;
|
||||
case 'reason': //查看失败原因
|
||||
laytpl($("#reason").html()).render(data, function (html) {
|
||||
layer.open({
|
||||
type: 1,
|
||||
shadeClose: true,
|
||||
shade: 0.3,
|
||||
offset: 'auto',
|
||||
fixed: false,
|
||||
title: "失败原因",
|
||||
area: ['450px', 'auto'],
|
||||
btn: ['退出'],
|
||||
content: html,
|
||||
skin: 'reason'
|
||||
});
|
||||
|
||||
});
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 保存添加商品
|
||||
*/
|
||||
form.on('submit(save)', function (data) {
|
||||
if (save_flag) return;
|
||||
save_flag = true;
|
||||
if (selectedGoodsId == '') {
|
||||
layer.msg('请选择商品');
|
||||
}
|
||||
if (cate_level_3_id == '') {
|
||||
layer.msg('请选择分类');
|
||||
}
|
||||
data.field.goods_ids = selectedGoodsId;
|
||||
data.field.third_cat_id = cate_level_3_id;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("shopcomponent://shop/goods/add"),
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
save_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title: '操作提示',
|
||||
btn: ['返回列表', '继续操作'],
|
||||
yes: function (index, layero) {
|
||||
location.hash = ns.hash("shopcomponent://shop/goods/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* 保存编辑分类
|
||||
*/
|
||||
form.on('submit(saveEdit)', function (data) {
|
||||
let goods_id = out_product_id;
|
||||
if (saveEdit_flag) return;
|
||||
saveEdit_flag = true;
|
||||
if (goods_id == '') {
|
||||
layer.msg('请选择商品');
|
||||
}
|
||||
if (cate_level_3_id == '') {
|
||||
layer.msg('请选择分类');
|
||||
}
|
||||
data.field.goods_id = goods_id;
|
||||
data.field.third_cat_id = cate_level_3_id;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("shopcomponent://shop/goods/edit"),
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
save_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title: '操作提示',
|
||||
btn: ['返回列表', '继续操作'],
|
||||
yes: function (index, layero) {
|
||||
location.hash = ns.hash("shopcomponent://shop/goods/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
// 批量操作
|
||||
table.bottomToolbar(function (obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
var id_array = new Array();
|
||||
for (i in obj.data) id_array.push(obj.data[i].out_product_id);
|
||||
switch (obj.event) {
|
||||
case "delete":
|
||||
deleteGoods(id_array.toString());
|
||||
break;
|
||||
case "listing":
|
||||
listingGoods(id_array.toString());
|
||||
break;
|
||||
case "dellisting":
|
||||
dellistingGoods(id_array.toString());
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
function deleteGoods(goods_ids){
|
||||
layer.confirm('是否确定要删除所选商品?', {title: '提示'}, function (index) {
|
||||
if (delete_flag) return;
|
||||
delete_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/delete"),
|
||||
data: {out_product_ids: goods_ids},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
delete_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function listingGoods(goods_ids){
|
||||
layer.confirm('是否确定要上架所选商品?', {title: '提示'}, function (index) {
|
||||
if (listing_flag) return;
|
||||
listing_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/listing"),
|
||||
data: {out_product_ids: goods_ids},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
listing_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function dellistingGoods(goods_ids){
|
||||
layer.confirm('是否确定要下架所选商品?', {title: '提示'}, function (index) {
|
||||
if (dellisting_flag) return;
|
||||
dellisting_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/dellisting"),
|
||||
data: {out_product_ids: goods_ids},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
dellisting_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// 同步商品
|
||||
function sync(start) {
|
||||
if (syncClick) return;
|
||||
syncClick = true;
|
||||
var start = start == undefined ? 0 : start;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/goods/sync"),
|
||||
data: {
|
||||
start: start,
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
syncClick = false;
|
||||
if (res.code == 0) {
|
||||
var data = res.data,
|
||||
next = parseInt(start) + 1;
|
||||
|
||||
if (next < data.total_page) {
|
||||
if (start == 0) {
|
||||
$(".progress-layer").fadeOut();
|
||||
}
|
||||
var progress = (next / data.total_page * 100).toFixed(2);
|
||||
element.progress('progress', progress + '%');
|
||||
// 拉取下一页
|
||||
sync(next);
|
||||
} else {
|
||||
if (!$(".progress-layer").is(':hidden')) $(".progress-layer").fadeOut();
|
||||
layer.closeAll();
|
||||
layer.msg('同步成功');
|
||||
table.reload();
|
||||
}
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
*/
|
||||
function addGood() {
|
||||
laytpl($("#add_good").html()).render({}, function(html) {
|
||||
add_good_layer = layer.open({
|
||||
type: 1,
|
||||
title: '添加商品',
|
||||
area: ['700px', '500px'],
|
||||
content: html,
|
||||
success: function(layero, index) {
|
||||
form.render();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改微信商品分类
|
||||
*/
|
||||
function check_cat(goods_id){
|
||||
if(goods_id!=''){
|
||||
out_product_id = goods_id;
|
||||
}
|
||||
laytpl($("#check_cat").html()).render({}, function(html) {
|
||||
add_good_layer = layer.open({
|
||||
type: 1,
|
||||
title: '修改商品分类',
|
||||
area: ['700px', '500px'],
|
||||
content: html,
|
||||
success: function(layero, index) {
|
||||
form.render();
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function selectGoods() {
|
||||
goodsSelect(function (data) {
|
||||
|
||||
goodsId = [];
|
||||
goods_list = [];
|
||||
|
||||
for (var key in data) {
|
||||
goodsId.push(data[key].goods_id);
|
||||
data[key].buy_num = 2;
|
||||
goods_list.push(data[key]);
|
||||
}
|
||||
|
||||
laytpl($("#table_goods_list").html()).render(goods_list, function(html) {
|
||||
$(".add-good-form .layui-table tbody").html(html);
|
||||
})
|
||||
|
||||
$("input[name='goods_ids']").val(JSON.stringify(goodsId));
|
||||
|
||||
selectedGoodsId = goodsId.toString();
|
||||
}, selectedGoodsId);
|
||||
}
|
||||
|
||||
function closeAddGoodsLayer() {
|
||||
layer.close(add_good_layer);
|
||||
}
|
||||
|
||||
// 选择分类
|
||||
function selectCategory() {
|
||||
$(".category-wrap").removeClass("layui-hide");
|
||||
$(".goods-category-mask").removeClass("layui-hide");
|
||||
}
|
||||
|
||||
$('body').off('click', '.goods-category-mask').on('click', '.goods-category-mask', function() {
|
||||
$(".category-wrap").addClass("layui-hide");
|
||||
$(".goods-category-mask").addClass("layui-hide");
|
||||
})
|
||||
|
||||
function selectThird(event){
|
||||
cate_level_3_id = $(event).attr('lay-id');
|
||||
$(event).addClass('selected-style bg-color').siblings('li').removeClass("selected-style bg-color");
|
||||
}
|
||||
|
||||
// 选中分类
|
||||
function selectedCategory(event, level, id) {
|
||||
$(event).addClass('selected-style bg-color').siblings('li').removeClass("selected-style bg-color");
|
||||
$.ajax({
|
||||
url: ns.url("shopcomponent://shop/category/getCategoryByParent"),
|
||||
data: {
|
||||
level: level,
|
||||
pid: id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
$(".cate-select").val('');
|
||||
var obj = {};
|
||||
obj.level = level;
|
||||
obj.list = res.data;
|
||||
if (obj.list.length > 0 && obj.level < 4) {
|
||||
renderCategory(obj);
|
||||
}
|
||||
if (level == 2) cate_level_1_id = id;
|
||||
else cate_level_2_id = id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderCategory(data) {
|
||||
laytpl($("#category_wrap").html()).render(data, function(html) {
|
||||
|
||||
if (data.level == 2) {
|
||||
$(".category-level-2").removeClass("layui-hide");
|
||||
$(".category-level-2").html(html);
|
||||
$(".category-level-3").addClass("layui-hide");
|
||||
$(".category-level-3").html();
|
||||
} else if (data.level == 3) {
|
||||
$(".category-level-3").removeClass("layui-hide");
|
||||
$(".category-level-3").html(html);
|
||||
}
|
||||
form.render();
|
||||
})
|
||||
}
|
||||
|
||||
function saveCate() {
|
||||
if (!$('.category-level-1 li.selected-style').length) {
|
||||
layer.msg('请选择一级分类', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
if (!$('.category-level-2 li.selected-style').length) {
|
||||
layer.msg('请选择二级分类', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
if (!$('.category-level-3 li.selected-style').length) {
|
||||
layer.msg('请选择三级分类', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
|
||||
var firstLevel = $('.category-level-1 li.selected-style'),
|
||||
secondLevel = $('.category-level-2 li.selected-style'),
|
||||
thirdLevel = $('.category-level-3 li.selected-style');
|
||||
|
||||
$(".cate-select").val(firstLevel.text() + '>' + secondLevel.text() + '>' + thirdLevel.text());
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("shopcomponent://shop/goods/check"),
|
||||
data: {third_cat_id:thirdLevel.attr('lay-id')},
|
||||
success: function(res) {
|
||||
if (res.code != 0) {
|
||||
layer.confirm('该类目需上传相应资质', {
|
||||
title:'操作提示',
|
||||
btn: ['上传资质', '暂不上传'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("shopcomponent://shop/category/lists?third_cat_id="+cate_level_3_id)
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".category-wrap").addClass("layui-hide");
|
||||
$(".goods-category-mask").addClass("layui-hide");
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="check_cat">
|
||||
<div class="goods-category-mask layui-hide"></div>
|
||||
|
||||
<div class="layui-form add-good-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid"><span class="required">*</span>商品分类:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" readonly lay-verify="required" autocomplete="off" class="layui-input len-long cate-select" onclick="selectCategory()">
|
||||
</div>
|
||||
<p class="word-aux mid">分类必选,此分类为调取的微信分类内容</p>
|
||||
|
||||
<div class="category-wrap layui-hide">
|
||||
<div class="category-list">
|
||||
<ul class="category-level-1">
|
||||
{foreach $first_cat as $first_k => $first_v}
|
||||
<li onclick="selectedCategory(this, 2, {$first_v.first_cat_id})" lay-id="{$first_v.first_cat_id}">{$first_v.first_cat_name}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
<ul class="category-level-2 layui-hide"></ul>
|
||||
<ul class="category-level-3 layui-hide"></ul>
|
||||
</div>
|
||||
|
||||
<div class="category-btn">
|
||||
<button class="layui-btn" onclick="saveCate()">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row mid">
|
||||
<button class="layui-btn" lay-submit lay-filter="saveEdit">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="closeAddGoodsLayer()">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="add_good">
|
||||
<div class="goods-category-mask layui-hide"></div>
|
||||
|
||||
<div class="layui-form add-good-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid"><span class="required">*</span>商品分类:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" readonly lay-verify="required" autocomplete="off" class="layui-input len-long cate-select" onclick="selectCategory()">
|
||||
</div>
|
||||
<p class="word-aux mid">分类必选,此分类为调取的微信分类内容</p>
|
||||
|
||||
<div class="category-wrap layui-hide">
|
||||
<div class="category-list">
|
||||
<ul class="category-level-1">
|
||||
{foreach $first_cat as $first_k => $first_v}
|
||||
<li onclick="selectedCategory(this, 2, {$first_v.first_cat_id})" lay-id="{$first_v.first_cat_id}">{$first_v.first_cat_name}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
<ul class="category-level-2 layui-hide"></ul>
|
||||
<ul class="category-level-3 layui-hide"></ul>
|
||||
</div>
|
||||
|
||||
<div class="category-btn">
|
||||
<button class="layui-btn" onclick="saveCate()">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid"><span class="required">*</span>选择商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" onclick="selectGoods()">选择商品</button>
|
||||
</div>
|
||||
<p class="word-aux mid">请选择需要关联至视频号直播的商品</p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid"></label>
|
||||
<div class="layui-input-block">
|
||||
<table class="layui-table" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="100%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>暂无商品</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row mid">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="closeAddGoodsLayer()">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="table_goods_list">
|
||||
{{# layui.each(d, function(index, item) { }}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(item.goods_image){ }}
|
||||
<img layer-src src="{{ns.img(item.goods_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{item.goods_name}}">{{item.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{# }) }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="category_wrap">
|
||||
{{# if (d.level == 2) { }}
|
||||
{{# layui.each(d.list, function(index, item) { }}
|
||||
<li onclick="selectedCategory(this, 3, {{item.second_cat_id}})" lay-id="{{item.second_cat_id}}">{{item.second_cat_name}}</li>
|
||||
{{# }) }}
|
||||
{{# } else if (d.level == 3) { }}
|
||||
{{# layui.each(d.list, function(index, item) { }}
|
||||
<li onclick="selectThird(this)" lay-id="{{item.third_cat_id}}">{{item.third_cat_name}}</li>
|
||||
{{# }) }}
|
||||
{{# } }}
|
||||
</script>
|
||||
BIN
addon/shopcomponent/shop/view/public/img/live_new.png
Executable file
BIN
addon/shopcomponent/shop/view/public/img/live_new.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
addon/shopcomponent/shop/view/public/img/live_select.png
Executable file
BIN
addon/shopcomponent/shop/view/public/img/live_select.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Reference in New Issue
Block a user