初始上传
179
addon/pintuan/api/controller/Goods.php
Executable file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\api\controller;
|
||||
|
||||
use addon\pintuan\model\Pintuan as PintuanModel;
|
||||
use addon\pintuan\model\Poster;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\model\goods\GoodsApi;
|
||||
|
||||
/**
|
||||
* 拼团商品
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 拼团商品详情信息
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$pintuan_id = $this->params['pintuan_id'] ?? 0;
|
||||
if (empty($pintuan_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$pintuan_model = new PintuanModel();
|
||||
$condition = [
|
||||
[ 'ppg.pintuan_id', '=', $pintuan_id ],
|
||||
[ 'ppg.site_id', '=', $this->site_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$goods_sku_detail = $pintuan_model->getPintuanGoodsDetail($condition)[ 'data' ];
|
||||
if (empty($goods_sku_detail)) return $this->response($this->error());
|
||||
|
||||
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
|
||||
|
||||
if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
|
||||
//判断商品规格项
|
||||
$goods_spec_format = $pintuan_model->getGoodsSpecFormat($pintuan_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
|
||||
$res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
|
||||
// 处理公共数据
|
||||
$goods_sku_api = new GoodsApi();
|
||||
$goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ], $this->member_id, $this->site_id);
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品SKU集合
|
||||
* @return false|string
|
||||
*/
|
||||
public function goodsSku()
|
||||
{
|
||||
$goods_id = $this->params['goods_id'] ?? 0;
|
||||
$pintuan_id = $this->params['pintuan_id'] ?? 0;
|
||||
$pintuan_num = $this->params[ 'pintuan_num' ] ?? 0;
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
if (empty($pintuan_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$pintuan_model = new PintuanModel();
|
||||
|
||||
$condition = [
|
||||
[ 'ppg.pintuan_id', '=', $pintuan_id ],
|
||||
[ 'ppg.site_id', '=', $this->site_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'g.goods_id', '=', $goods_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$list = $pintuan_model->getPintuanGoodsSkuList($condition);
|
||||
|
||||
foreach ($list[ 'data' ] as $k => $v) {
|
||||
if ($v[ 'pintuan_type' ] == 'ladder') {
|
||||
$v[ 'pintuan_ladder' ] = $pintuan_num;
|
||||
$price = $pintuan_model->getPintuanPrice($v);
|
||||
$list[ 'data' ][ $k ][ 'pintuan_price' ] = $price;
|
||||
}
|
||||
|
||||
if (!empty($v[ 'goods_spec_format' ])) {
|
||||
$goods_spec_format = $pintuan_model->getGoodsSpecFormat($pintuan_id, $this->site_id, $v[ 'goods_spec_format' ]);
|
||||
$list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
}
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function page()
|
||||
{
|
||||
$site_id = $this->site_id;
|
||||
$page = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$goods_id_arr = $this->params['goods_id_arr'] ?? '';//goods_id数组
|
||||
|
||||
$condition = [
|
||||
[ 'pp.status', '=', 1 ],// 状态(0正常 1活动进行中 2活动已结束 3失效 4删除)
|
||||
[ 'g.goods_stock', '>', 0 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.site_id', '=', $site_id ]
|
||||
];
|
||||
|
||||
if (!empty($goods_id_arr)) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
|
||||
}
|
||||
|
||||
$pintuan_model = new PintuanModel();
|
||||
$list = $pintuan_model->getPintuanGoodsPageList($condition, $page, $page_size, 'pp.pintuan_id desc');
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$site_id = $this->site_id;
|
||||
$num = $this->params['num'] ?? null;
|
||||
$goods_id_arr = $this->params['goods_id_arr'] ?? '';//goods_id数组
|
||||
|
||||
$condition = [
|
||||
[ 'pp.status', '=', 1 ],// 状态(0正常 1活动进行中 2活动已结束 3失效 4删除)
|
||||
[ 'g.goods_stock', '>', 0 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'g.site_id', '=', $site_id ]
|
||||
];
|
||||
|
||||
if (!empty($goods_id_arr)) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $goods_id_arr ];
|
||||
}
|
||||
|
||||
$pintuan_model = new PintuanModel();
|
||||
$list = $pintuan_model->getPintuanList($condition, '', 'pp.pintuan_id desc', $num);
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品海报
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
$promotion_type = 'pintuan';
|
||||
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
|
||||
$qrcode_param[ 'source_member' ] = $this->member_id;
|
||||
$poster = new Poster();
|
||||
$res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享图片
|
||||
* @return false|string
|
||||
*/
|
||||
public function shareImg()
|
||||
{
|
||||
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
|
||||
|
||||
$poster = new Poster();
|
||||
$res = $poster->shareImg($this->params[ 'page' ] ?? '', $qrcode_param, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
113
addon/pintuan/api/controller/Order.php
Executable file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Index.php
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
* @author : niuteam
|
||||
* @date : 2022.8.8
|
||||
* @version : v5.0.0.1
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\api\controller;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
use addon\pintuan\model\PintuanOrder as PintuanOrderModel;
|
||||
use app\api\controller\BaseApi;
|
||||
|
||||
/**
|
||||
* 拼团订单
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Order extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 拼团订单详情
|
||||
* @return string
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params['id'] ?? 0;//拼团订单主键id
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$pintuan_order_model = new PintuanOrderModel();
|
||||
$res = $pintuan_order_model->getPintuanOrderDetail($id, $this->member_id, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @return string
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$pintuan_order_model = new PintuanOrderModel();
|
||||
$condition = array (
|
||||
[ "ppo.member_id", "=", $this->member_id ],
|
||||
[ "ppo.site_id", "=", $this->site_id ]
|
||||
);
|
||||
$pintuan_status = $this->params['pintuan_status'] ?? 'all';
|
||||
if ($pintuan_status != "all") {
|
||||
$condition[] = [ "ppo.pintuan_status", "=", $pintuan_status ];
|
||||
} else {
|
||||
$condition[] = [ "ppo.pintuan_status", "<>", "0" ];//不查询未支付的拼团
|
||||
}
|
||||
|
||||
$page_index = $this->params['page'] ?? 1;
|
||||
$page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
|
||||
$res = $pintuan_order_model->getPintuanOrderPageList($condition, $page_index, $page_size, "o.pay_time desc");
|
||||
if (!empty($res[ 'data' ][ 'list' ])) {
|
||||
foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
|
||||
$member_list = $pintuan_order_model->getPintuanOrderList([ [ "group_id", "=", $v[ "group_id" ] ], [ 'pintuan_status', 'in', '2,3' ] ], "member_img,nickname");
|
||||
$res[ 'data' ][ 'list' ][ $k ][ 'member_list' ] = $member_list[ 'data' ];
|
||||
}
|
||||
|
||||
}
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团会员
|
||||
* @return string
|
||||
*/
|
||||
public function pintuanMember()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
|
||||
$pintuan_order_model = new PintuanOrderModel();
|
||||
$pintuan = new Pintuan();
|
||||
$condition = array (
|
||||
[ "site_id", "=", $this->site_id ],
|
||||
[ "pintuan_status", "=", '3' ],
|
||||
);
|
||||
|
||||
$limit = $this->params['num'] ?? 5;
|
||||
$field = 'head_id,member_id,member_img,nickname';
|
||||
$pintuna_member_list = $pintuan_order_model->getPintuanOrderList($condition, $field, 'id desc', $limit, 'member_id')[ 'data' ] ?? [];
|
||||
|
||||
$pintuna_member_count = $pintuan->getPintuanInfo([
|
||||
[ 'pp.site_id', '=', $this->site_id ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
], '(sum(g.sale_num) + sum(g.virtual_sale)) as sale_num', 'pp', [
|
||||
[ 'goods g', 'g.goods_id=pp.goods_id', 'inner' ],
|
||||
])[ 'data' ][ 'sale_num' ] ?? 0;
|
||||
|
||||
$data = [
|
||||
'member_list' => $pintuna_member_list,
|
||||
'pintuan_count' => numberFormat($pintuna_member_count)
|
||||
];
|
||||
return $this->response($this->success($data));
|
||||
}
|
||||
}
|
||||
84
addon/pintuan/api/controller/Ordercreate.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Index.php
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
* @author : niuteam
|
||||
* @date : 2022.8.8
|
||||
* @version : v5.0.0.1
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\api\controller;
|
||||
|
||||
use addon\pintuan\model\PintuanOrderCreate as OrderCreateModel;
|
||||
use app\api\controller\BaseOrderCreateApi;
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*
|
||||
*/
|
||||
class Ordercreate extends BaseOrderCreateApi
|
||||
{
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params['order_key'] ?? '',
|
||||
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getInputParam(), $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->create();
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算信息
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params['order_key'] ?? '',//订单缓存
|
||||
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->confirm();
|
||||
return $this->response($this->success($res));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 待支付订单 数据初始化
|
||||
* @return string
|
||||
*/
|
||||
public function payment()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'id' => $this->params[ 'pintuan_goods_id' ] ?? '',//拼团商品id
|
||||
'num' => $this->params[ 'num' ] ?? 1,//拼团商品数量(买几套)
|
||||
'group_id' => $this->params[ 'group_id' ] ?? 0,//拼团组id
|
||||
'extend' => !empty($this->params[ 'extend' ]) ? json_decode($this->params[ 'extend' ], true) : [],//业务扩展字段 {"pintuan_num":5}
|
||||
];
|
||||
if (empty($data[ 'id' ])) {
|
||||
return $this->response($this->error('', '缺少必填参数商品数据'));
|
||||
}
|
||||
if ($data[ 'num' ] < 1) {
|
||||
return $this->response($this->error('', '购买数量不能小于1'));
|
||||
}
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->orderPayment();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
}
|
||||
83
addon/pintuan/api/controller/Pintuangroup.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\api\controller;
|
||||
|
||||
use addon\pintuan\model\PintuanGroup as PintuanGroupModel;
|
||||
use addon\pintuan\model\PintuanOrder;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\model\order\OrderCommon;
|
||||
|
||||
/**
|
||||
* 拼团组
|
||||
*/
|
||||
class Pintuangroup extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$goods_id = $this->params[ 'goods_id' ] ?? 0;
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_GOODS_ID'));
|
||||
}
|
||||
|
||||
$pintuan_group_model = new PintuanGroupModel();
|
||||
$condition = [
|
||||
[ 'ppg.goods_id', '=', $goods_id ],
|
||||
[ 'ppg.status', '=', 2 ],// 当前状态:0未支付 1拼团失败 2.组团中3.拼团成功
|
||||
[ 'ppg.site_id', '=', $this->site_id ]
|
||||
];
|
||||
$list = $pintuan_group_model->getPintuanGoodsGroupList($condition);
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开团信息
|
||||
* @return false|string
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$group_id = input('group_id', 0);
|
||||
$condition = [
|
||||
[ 'pg.group_id', '=', $group_id ],
|
||||
[ 'pg.site_id', '=', $this->site_id ]
|
||||
];
|
||||
$pintuan_group_model = new PintuanGroupModel();
|
||||
$info = $pintuan_group_model->getPintuanGroupDetail($condition);
|
||||
if (!empty($info)) {
|
||||
$info[ 'data' ][ 'is_self' ] = 0;
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0 && $info[ 'data' ][ 'head_id' ] == $this->member_id) $info[ 'data' ][ 'is_self' ] = 1;
|
||||
|
||||
//待支付的参团订单
|
||||
$info[ 'data' ][ 'order_id' ] = 0;
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$pintuan_order = new PintuanOrder();
|
||||
$field = 'po.order_id';
|
||||
$order_info = $pintuan_order->getPintuanOrderInfo([
|
||||
[ 'po.pintuan_id', '=', $info[ 'data' ][ 'pintuan_id' ] ],
|
||||
[ 'po.site_id', '=', $this->site_id ],
|
||||
[ 'po.group_id', '=', $group_id ],
|
||||
[ 'po.head_id', '<>', $this->member_id ],
|
||||
[ 'o.member_id', '=', $this->member_id ],
|
||||
[ 'o.order_status', '<>', OrderCommon::ORDER_CLOSE ],
|
||||
|
||||
], $field, 'po', [
|
||||
[ 'order o', 'o.order_id = po.order_id', 'left' ]
|
||||
]);
|
||||
$info[ 'data' ][ 'order_id' ] = $order_info[ 'data' ][ 'order_id' ] ?? 0;
|
||||
}
|
||||
}
|
||||
return $this->response($info);
|
||||
}
|
||||
}
|
||||
21
addon/pintuan/component/controller/Pintuan.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace addon\pintuan\component\controller;
|
||||
|
||||
use app\component\controller\BaseDiyView;
|
||||
|
||||
/**
|
||||
* 拼团模块·组件
|
||||
*
|
||||
*/
|
||||
class Pintuan extends BaseDiyView
|
||||
{
|
||||
|
||||
/**
|
||||
* 设计界面
|
||||
*/
|
||||
public function design()
|
||||
{
|
||||
return $this->fetch("pintuan/design.html");
|
||||
}
|
||||
}
|
||||
70
addon/pintuan/component/view/pintuan/css/design.css
Executable file
@@ -0,0 +1,70 @@
|
||||
@CHARSET "UTF-8";
|
||||
.component-pintuan .pintuan-list{overflow: hidden;}
|
||||
|
||||
/* 头部样式 */
|
||||
/* 样式一 */
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head{display: flex;height: 44px;width: 100%;justify-content: space-between;align-items: center;padding: 0 12px;box-sizing: border-box;margin:0;background-repeat: no-repeat;background-size: cover;margin-bottom: 10px;border-radius: 9px 9px 0 0;line-height: 1;}
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head .left-img{max-height: 20px;max-width: 78px;}
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head .head-content{display: flex;align-items: center;color:#fff;margin-right: auto;margin-left: 22px;}
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head .head-content .img-wrap{position: relative;display: inline-block;margin-right: 5px;}
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head .head-content .img-wrap:after{content: "";width: 1px;height: 14px;background-color: #fff;position: absolute;left: -16px;top: 50%;transform: translateY(-50%);}
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head .head-content .img-wrap img{width: 20px;height: 20px;border: 1px solid #FF3D3D;border-radius: 50%;margin-left: -10px;}
|
||||
.component-pintuan .pintuan-list .style-1.pintuan-head .head-right{display: flex;align-items: center;color: #fff;}
|
||||
/* 样式二 */
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head{display: flex;height: 44px;width: 100%;justify-content: space-between;align-items: center;padding: 0 12px;box-sizing: border-box;margin:0;background-repeat: no-repeat;background-size: cover;margin-bottom: 10px;border-radius: 9px 9px 0 0;line-height: 1;}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .left-img{max-height: 20px;max-width: 78px;}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-content{display: flex;align-items: center;color:#fff;margin-right: auto;margin-left: 18px;}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-content .img-wrap{position: relative;display: inline-block;margin-right: 4px;}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-content .img-wrap:after{content: "";width: 1px;height: 14px;background-color: #fff;position: absolute;left: -16px;top: 50%;transform: translateY(-50%);}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-content .img-wrap img{width: 20px;height: 20px;border: 1px solid #FF3D3D;border-radius: 50%;margin-left: -10px;}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-right{display: flex;align-items: center;justify-content: center;height: 18px;background: linear-gradient(270deg, #FFBD5B 0%, #FD882E 100%);border-radius: 12px;padding: 1px;}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-right span:nth-child(1){position: relative;left: 3px;transform: scale(0.9);}
|
||||
.component-pintuan .pintuan-list .style-2.pintuan-head .head-right span:nth-child(2){padding: 2px;background-color: #fff;color: #FFBD5B;border-radius: 50%;transform: scale(0.6);font-weight: bold;}
|
||||
|
||||
/* 样式:单列 */
|
||||
.component-pintuan .pintuan-list .row1-of1{}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item{display: flex;margin-bottom: 10px;padding: 8px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item:last-child{margin-bottom: 0;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .img-wrap {width: 100px;height: 100px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .img-wrap > img{width: 100%;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content{flex:1;margin-left: 10px;position: relative;display: flex;justify-content: space-between;flex-direction: column;padding: 3px 0 5px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .tag-wrap{display: flex;align-items: center;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .tag-wrap > div{height: 15px;line-height: 15px;border: 1px solid;border-radius: 3px;margin-right: 5px;font-size: 12px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .tag-wrap > div i {display: inline-block;width: 15px;height: 15px;font-size: 12px;color: #FFFFFF;text-align: center;margin-right: -3px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .tag-wrap > div span {padding: 0 5px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .bottom-wrap{display: flex;align-items: center;justify-content: space-between;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .price-wrap{display: flex;align-items: baseline;width: 125px;overflow: hidden;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .price-wrap>div:last-of-type{flex: 1;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .price-wrap .discount-price{font-size: 0;font-weight: bold;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .price-wrap .discount-price .unit{font-size: 12px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .price-wrap .discount-price .price{font-size: 16px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content .price-wrap .original-price {font-size: 12px;line-height: 1;text-decoration: line-through;margin: 0 5px;}
|
||||
.component-pintuan .pintuan-list .row1-of1 .item .content button{height: 25px;line-height: 20px;font-size: 12px;padding: 0 8px;}
|
||||
|
||||
/* 样式:横向滑动 */
|
||||
.component-pintuan .pintuan-list .horizontal-slide{display: flex;margin: 10px;overflow: hidden;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item {width: 97px;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .img-wrap {width: 97px;height: 97px;overflow: hidden;position: relative;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .img-wrap > img{width: calc(100% + 1px);}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .img-wrap .num {width: 40px;position: absolute;bottom: 0;font-size: 12px;line-height: 1;color: #FFFFFF;text-align: center;border-top-left-radius: 10px;border-top-right-radius: 10px;padding: 5px;transform: translate(50%);}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .content {padding: 5px 10px;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .content .price-wrap{margin-top: 5px;font-weight: bold;display: flex;align-items: flex-end;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .content .price-wrap .unit{font-size: 12px; height: 16px;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide .item .content .price-wrap .price{font-size: 16px;}
|
||||
/* 样式二 */
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-2.pintuan-content{margin: 0;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-2.pintuan-content .item{width: 103px;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-2.pintuan-content .item .img-wrap{width: 103px;height: 103px;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-2.pintuan-content .price-wrap{width: 100%;justify-content: center;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-2.pintuan-content .sale-num{text-align: center;color: #666666;}
|
||||
/* 样式三 */
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-3.pintuan-content .content{position: relative;}
|
||||
.component-pintuan .pintuan-list .horizontal-slide.style-3.pintuan-content .sale-action{position: absolute;bottom: 4px;right: -9px;font-size: 12px;width: 47px;height: 22px;background: linear-gradient(131deg, #3EDB73 0%, #1DB576 100%);border-radius: 4px;color: #fff;text-align: center;line-height: 22px;transform: scale(0.9);}
|
||||
|
||||
/* 秒杀头部弹窗样式 */
|
||||
.component-pintuan .style-list-box-pintuan{display: none;}
|
||||
.style-list-con-pintuan{display: flex;flex-wrap: wrap;}
|
||||
.style-list-con-pintuan .style-li-pintuan{overflow: hidden;display: flex;align-items: center;justify-content: center;width: 280px;height: 100px;margin-right: 12px;margin-top: 15px;cursor: pointer;border: 1px solid #ededed;background: #f7f8fa;}
|
||||
.style-list-con-pintuan .style-li-pintuan img{max-width: 280px;max-height: 220px;}
|
||||
.style-list-con-pintuan .style-li-pintuan:nth-child(1), .style-list-con-pintuan .style-li-pintuan:nth-child(2), .style-list-con-pintuan .style-li-pintuan:nth-child(3){margin-top: 0;}
|
||||
.style-list-con-pintuan .style-li-pintuan:nth-child(3n){margin-right: 0;}
|
||||
476
addon/pintuan/component/view/pintuan/design.html
Executable file
@@ -0,0 +1,476 @@
|
||||
<nc-component :data="data[index]" class="component-pintuan">
|
||||
|
||||
<!-- 预览 -->
|
||||
<template slot="preview">
|
||||
<div class="pintuan-list" :style="{ backgroundColor: nc.componentBgColor,
|
||||
borderTopLeftRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0),
|
||||
}">
|
||||
<div v-if="nc.titleStyle.isShow" :class="[nc.titleStyle.style,'pintuan-head']" :style="{'backgroundImage':'url('+ changeImgUrl(nc.titleStyle.backgroundImage) + '), linear-gradient(to right,'+nc.titleStyle.bgColorStart+','+ nc.titleStyle.bgColorEnd+')'}">
|
||||
<h3 v-if="nc.titleStyle.leftStyle == 'text'" :style="{fontSize: nc.titleStyle.fontSize + 'px',color: nc.titleStyle.textColor,fontWeight: nc.titleStyle.fontWeight ? 'bold' : ''}">{{nc.titleStyle.leftText}}</h3>
|
||||
<img v-else class="left-img" :src="changeImgUrl(nc.titleStyle.leftImg)" />
|
||||
<div class="head-content" v-if="nc.titleStyle.style == 'style-1'">
|
||||
<div class="img-wrap">
|
||||
<img :src="changeImgUrl('public/static/img/default_img/square.png')" alt="">
|
||||
<img :src="changeImgUrl('public/static/img/default_img/square.png')" alt="">
|
||||
<img :src="changeImgUrl('public/static/img/default_img/square.png')" alt="">
|
||||
</div>
|
||||
<span :style="{color: nc.titleStyle.textColor}">{{nc.titleStyle.virtualNum || 0}}人拼团成功</span>
|
||||
</div>
|
||||
<div class="head-content" v-if="nc.titleStyle.style == 'style-2'">
|
||||
<div class="img-wrap">
|
||||
<img src="{$resource_path}/img/style_2_logo_1.png" alt="">
|
||||
<img src="{$resource_path}/img/style_2_logo_2.png" alt="">
|
||||
<img src="{$resource_path}/img/style_2_logo_3.png" alt="">
|
||||
</div>
|
||||
<span :style="{color: nc.titleStyle.textColor}">{{nc.titleStyle.virtualNum || 0}}人参与</span>
|
||||
</div>
|
||||
<div class="head-right" :style="{fontSize: nc.titleStyle.moreFontSize + 'px',color: nc.titleStyle.moreColor}">
|
||||
<span>{{nc.titleStyle.more}}</span>
|
||||
<span class="iconyoujiantou iconfont"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="[nc.template,nc.style,'pintuan-content']">
|
||||
<template v-if="nc.tempData.previewList && Object.keys(nc.tempData.previewList).length">
|
||||
<template v-if="nc.template == 'row1-of1'">
|
||||
<div class="item" v-for="(item, previewIndex) in nc.tempData.previewList" :key="previewIndex"
|
||||
:style="{
|
||||
borderTopLeftRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
backgroundColor: nc.elementBgColor,
|
||||
boxShadow: nc.ornament.type == 'shadow' ? ('0 0 5px ' + nc.ornament.color) : '',
|
||||
border: nc.ornament.type == 'stroke' ? '1px solid ' + nc.ornament.color : ''}">
|
||||
<div class="img-wrap" :style="{ borderRadius: nc.imgAroundRadius + 'px' }">
|
||||
<img :style="{ borderRadius: nc.imgAroundRadius + 'px' }" :src="changeImgUrl('public/static/img/default_img/square.png')" />
|
||||
</div>
|
||||
<div class="content" v-if="nc.goodsNameStyle.control || nc.priceStyle.mainControl || nc.priceStyle.lineControl || nc.btnStyle.control">
|
||||
<div class="goods-name" v-if="nc.goodsNameStyle.control" :style="{ color : nc.goodsNameStyle.color,fontWeight : nc.goodsNameStyle.fontWeight ? 'bold' : '' }" :class="[{'using-hidden' : nc.nameLineMode == 'single'},{'multi-hidden' : nc.nameLineMode == 'multiple'}]">{{ item.goods_name }}</div>
|
||||
<div class="tag-wrap" v-if="nc.groupStyle.control || nc.saleStyle.control">
|
||||
<div v-if="nc.groupStyle.control" :style="{ color : nc.groupStyle.bgColorStart,borderColor : nc.groupStyle.bgColorStart }">
|
||||
<i class="iconfont iconyonghu3" :style="{ backgroundColor : nc.groupStyle.bgColorStart }"></i>
|
||||
<span>2人团</span>
|
||||
</div>
|
||||
<div v-if="nc.saleStyle.control" :style="{ color : nc.saleStyle.color }">
|
||||
<span>已拼159件</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom-wrap">
|
||||
<div class="price-wrap">
|
||||
<div class="discount-price" v-if="nc.priceStyle.mainControl">
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">¥</span>
|
||||
<span class="price" :style="{ color : nc.priceStyle.mainColor }">{{ item.discount_price.split(".")[0] }}</span>
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">{{ "."+item.discount_price.split(".")[1] }}</span>
|
||||
</div>
|
||||
<div class="original-price" v-if="nc.priceStyle.lineControl" :style="{ color : nc.priceStyle.lineColor }">¥{{item.line_price}}</div>
|
||||
</div>
|
||||
<button v-if="nc.btnStyle.control" class="layui-btn" :style="{ background : 'linear-gradient(to right,' + nc.btnStyle.bgColorStart + ',' + nc.btnStyle.bgColorEnd + ')', color : nc.btnStyle.textColor,borderRadius : nc.btnStyle.aroundRadius + 'px' }">{{ nc.btnStyle.text }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="nc.template == 'horizontal-slide'">
|
||||
<div class="item" v-for="(item, previewIndex) in nc.tempData.previewList" :key="previewIndex"
|
||||
:style="{
|
||||
borderTopLeftRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
backgroundColor: nc.elementBgColor,
|
||||
marginLeft: nc.template == 'horizontal-slide' && (nc.slideMode == 'scroll' && nc.goodsMarginType=='diy' && (nc.goodsMarginNum+'px') || ((60 - nc.margin.both*2) /6 + 'px')) || '',
|
||||
marginRight: nc.template == 'horizontal-slide' && (nc.slideMode == 'scroll' && nc.goodsMarginType=='diy' && (nc.goodsMarginNum+'px') || ((60 - nc.margin.both*2) /6 + 'px')) || '',
|
||||
boxShadow: nc.ornament.type == 'shadow' ? ('0 0 5px ' + nc.ornament.color) : '',
|
||||
border: nc.ornament.type == 'stroke' ? '1px solid ' + nc.ornament.color : ''}">
|
||||
<div class="img-wrap" :style="{ borderRadius: nc.imgAroundRadius + 'px' }">
|
||||
<img :style="{ borderRadius: nc.imgAroundRadius + 'px' }" :src="changeImgUrl('public/static/img/default_img/square.png')" />
|
||||
<div v-if="nc.groupStyle.control&&nc.style =='style-1'" class="num" :style="{ color : nc.groupStyle.color,background : 'linear-gradient(to right,' + nc.groupStyle.bgColorStart + ',' + nc.groupStyle.bgColorEnd + ')' }">2人团</div>
|
||||
</div>
|
||||
<div class="content" v-if="nc.goodsNameStyle.control || nc.priceStyle.mainControl">
|
||||
<div class="goods-name" v-if="nc.goodsNameStyle.control&&(nc.style=='style-1' || nc.style=='style-3')" :style="{ color : nc.goodsNameStyle.color,fontWeight : nc.goodsNameStyle.fontWeight ? 'bold' : '' }" :class="[{'using-hidden' : nc.nameLineMode == 'single'},{'multi-hidden' : nc.nameLineMode == 'multiple'}]">{{ item.goods_name }}</div>
|
||||
<div class="price-wrap" v-if="nc.priceStyle.mainControl">
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">¥</span>
|
||||
<span class="price" :style="{ color : nc.priceStyle.mainColor }">{{ item.discount_price.split(".")[0] }}</span>
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">{{ "."+item.discount_price.split(".")[1] }}</span>
|
||||
</div>
|
||||
<div class="sale-action" v-if="nc.style=='style-3'">去参团</div>
|
||||
<div class="sale-num" v-if="nc.style=='style-2'">已拼{{item.sale_num}}件</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 内容编辑 -->
|
||||
<template slot="edit-content">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<pintuan-list-sources></pintuan-list-sources>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>头部风格</h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">头部状态</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.titleStyle.isShow = !nc.titleStyle.isShow" :class="{ 'layui-form-checked' : nc.titleStyle.isShow }">
|
||||
<span>{{ nc.titleStyle.isShow ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="nc.titleStyle.isShow">
|
||||
<div class="layui-form-item" v-if="nc.tempData.methods">
|
||||
<label class="layui-form-label sm">选择风格</label>
|
||||
<div class="layui-input-block">
|
||||
<div v-if="nc.titleStyle.styleName" class="text-color selected-style" @click="nc.tempData.methods.selectTopStyle">
|
||||
<span>{{nc.titleStyle.styleName}}</span>
|
||||
<i class="layui-icon layui-icon-right"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">主标题类型</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.titleStyle.leftStyle='text'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.titleStyle.leftStyle=='text') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.titleStyle.leftStyle=='text' ? "" : "" }}</i>
|
||||
<div>文字</div>
|
||||
</div>
|
||||
<div @click="nc.titleStyle.leftStyle='img'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.titleStyle.leftStyle=='img') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.titleStyle.leftStyle=='img' ? "" : "" }}</i>
|
||||
<div>图片</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.titleStyle.leftStyle=='text'">
|
||||
<label class="layui-form-label sm">标题文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.titleStyle.leftText" maxlength="4" placeholder="限时秒杀" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" v-if="nc.titleStyle.leftStyle=='img'">
|
||||
<label class="layui-form-label sm">标题图片</label>
|
||||
<div class="layui-input-block">
|
||||
<img-upload :data="{ data: nc.titleStyle,field:'leftImg'}" data-disabled="1"></img-upload>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">虚拟成团数</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.titleStyle.virtualNum" maxlength="8" placeholder="请输入虚拟成团数" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">右侧文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.titleStyle.more" maxlength="8" placeholder="查看更多" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品风格</h3>
|
||||
<div class="layui-form-item list-style" v-if="nc.tempData.templateList">
|
||||
<label class="layui-form-label sm">风格</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source">{{ nc.tempData.templateList[nc.template].text }}</div>
|
||||
<div class="template-selected">
|
||||
<div v-for="(item,templateKey) in nc.tempData.templateList" :key="templateKey" class="source-item" :title="item.text"
|
||||
@click="nc.tempData.methods.selectTemplate(templateKey)"
|
||||
:class="[(nc.template == templateKey) ? 'text-color border-color' : '' ]">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 暂时只有一种样式,先隐藏 -->
|
||||
<div class="style-selected">
|
||||
<div v-for="(item,styleIndex) in nc.tempData.templateList[nc.template].styleList" :key="styleIndex" @click="nc.tempData.methods.selectTemplate('',item)" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.style==item.value) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.style == item.value ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品数据</h3>
|
||||
<div class="layui-form-item" v-if="nc.tempData.goodsSources">
|
||||
<label class="layui-form-label sm">数据来源</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source-selected">
|
||||
<div class="source">{{ nc.tempData.goodsSources[nc.sources].text }}</div>
|
||||
<div v-for="(item,sourcesKey) in nc.tempData.goodsSources" :key="sourcesKey" class="source-item" :title="item.text" @click="nc.sources=sourcesKey" :class="{ 'text-color border-color' : (nc.sources == sourcesKey) }">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.sources == 'diy'">
|
||||
<label class="layui-form-label sm">手动选择</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="selected-style" @click="nc.tempData.methods.addGoods()">
|
||||
<span v-if="nc.goodsId.length == 0">请选择</span>
|
||||
<span v-if="nc.goodsId.length > 0" class="text-color">已选{{ nc.goodsId.length }}个</span>
|
||||
<i class="iconfont iconyoujiantou"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<slide :data="{ field : 'count', label: '商品数量', min:1, max: 30}" v-if="nc.sources != 'diy'"></slide>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">是否显示</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.btnStyle.control = !nc.btnStyle.control" :class="{ 'layui-form-checked' : nc.btnStyle.control }">
|
||||
<span>{{ nc.btnStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.btnStyle.control">
|
||||
<label class="layui-form-label sm">文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.btnStyle.text" maxlength="6" placeholder="请输入按钮文字" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>显示内容</h3>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.control = !nc.goodsNameStyle.control" :class="{ 'layui-form-checked' : nc.goodsNameStyle.control }">
|
||||
<span>{{ nc.goodsNameStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">团购人数</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.groupStyle.control = !nc.groupStyle.control" :class="{ 'layui-form-checked' : nc.groupStyle.control }">
|
||||
<span>{{ nc.groupStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">销售价</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.mainControl = !nc.priceStyle.mainControl" :class="{ 'layui-form-checked' : nc.priceStyle.mainControl }">
|
||||
<span>{{ nc.priceStyle.mainControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.priceStyle.lineSupport">
|
||||
<label class="layui-form-label sm">划线价</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.lineControl = !nc.priceStyle.lineControl" :class="{ 'layui-form-checked' : nc.priceStyle.lineControl }">
|
||||
<span>{{ nc.priceStyle.lineControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.saleStyle.support">
|
||||
<label class="layui-form-label sm">商品销量</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.saleStyle.control = !nc.saleStyle.control" :class="{ 'layui-form-checked' : nc.saleStyle.control }">
|
||||
<span>{{ nc.saleStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<!-- 弹框 -->
|
||||
<article class="style-list-box-pintuan">
|
||||
<div class="style-list-pintuan layui-form">
|
||||
<div class="style-list-con-pintuan">
|
||||
<div class="style-li-pintuan" v-for="(value,name,previewIndex) in nc.tempData.styleList" :key="name" :class="{'selected border-color': nc.titleStyle.style == name}" :data_key="name">
|
||||
<span class="layui-hide">风格{{previewIndex + 1}}</span>
|
||||
<img :src="'{$resource_path}/img/style_title_' + (previewIndex+1) + '.png'" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="style">
|
||||
<input type="hidden" name="style_name" />
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- 样式编辑 -->
|
||||
<template slot="edit-style">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<template v-if="nc.titleStyle.isShow">
|
||||
<div class="template-edit-title">
|
||||
<h3>头部样式</h3>
|
||||
<template v-if="nc.titleStyle.leftStyle == 'text'">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">标题加粗</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.titleStyle.fontWeight = !nc.titleStyle.fontWeight" :class="{ 'layui-form-checked' : nc.titleStyle.fontWeight }">
|
||||
<span>加粗</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<color :data="{ field : 'textColor', 'label' : '标题颜色', parent : 'titleStyle', defaultColor : '#303133' }"></color>
|
||||
<slide :data="{ field : 'fontSize',parent : 'titleStyle', label : '标题大小', min: 12, max : 16 }"></slide>
|
||||
</template>
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '背景颜色', parent : 'titleStyle', defaultColor : '#6236FF,#0091FF' }"></color>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">背景图片</label>
|
||||
<div class="layui-input-block">
|
||||
<img-upload :data="{ data: nc.titleStyle,field:'backgroundImage'}" data-disabled="1"></img-upload>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="template-edit-title">
|
||||
<h3>“更多”样式</h3>
|
||||
<color :data="{ field : 'moreColor', 'label' : '文字颜色', parent : 'titleStyle', defaultColor : '#999999' }"></color>
|
||||
<slide :data="{ field : 'moreFontSize',parent : 'titleStyle', label : '文字大小', min: 12, max : 14 }"></slide>
|
||||
</div>
|
||||
</template>
|
||||
<div class="template-edit-title">
|
||||
<h3>商品样式</h3>
|
||||
|
||||
<div class="layui-form-item tag-wrap">
|
||||
<label class="layui-form-label sm">边框</label>
|
||||
<div class="layui-input-block">
|
||||
<div v-for="(item,ornamentIndex) in nc.tempData.ornamentList" :key="ornamentIndex" @click="nc.ornament.type=item.type" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.ornament.type==item.type) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.ornament.type == item.type ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color v-if="nc.ornament.type != 'default'" :data="{ field : 'color', 'label' : '边框颜色', parent : 'ornament', defaultColor : '#EDEDED' }"></color>
|
||||
|
||||
<slide :data="{ field : 'imgAroundRadius', label: '图片圆角', min:0, max: 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.template == 'horizontal-slide'">
|
||||
<label class="layui-form-label sm">滚动方式</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.slideMode = 'scroll' " :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.slideMode == 'scroll') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.slideMode == 'scroll' ? "" : "" }}</i>
|
||||
<div>平移</div>
|
||||
</div>
|
||||
<div @click="nc.slideMode = 'slide' " :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.slideMode == 'slide') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.slideMode == 'slide' ? "" : "" }}</i>
|
||||
<div>切屏</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.goodsNameStyle.control">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.fontWeight = !nc.goodsNameStyle.fontWeight" :class="{ 'layui-form-checked' : nc.goodsNameStyle.fontWeight }">
|
||||
<span>加粗</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
<div v-for="(item,nameLineIndex) in nc.tempData.nameLineModeList" :key="nameLineIndex" @click="nc.nameLineMode=item.value" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.nameLineMode==item.value) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.nameLineMode == item.value ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color :data="{ field : 'elementBgColor', 'label' : '商品背景' }"></color>
|
||||
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'topElementAroundRadius', label : '上圆角', max : 50 }"></slide>
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'bottomElementAroundRadius', label : '下圆角', max : 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="nc.theme == 'diy'">
|
||||
<color :data="{ field : 'color', 'label' : '商品名称', parent : 'goodsNameStyle', defaultColor : '#303133' }"></color>
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '团购人数', parent : 'groupStyle', defaultColor : '#FA2379,#FF4F61' }"></color>
|
||||
<color :data="{ field : 'mainColor', 'label' : '销售价', parent : 'priceStyle', defaultColor : '#FF6A00' }"></color>
|
||||
<div v-show="nc.priceStyle.lineSupport">
|
||||
<color :data="{ field : 'lineColor', 'label' : '划线价', parent : 'priceStyle', defaultColor : '#999CA7' }"></color>
|
||||
</div>
|
||||
<div v-show="nc.saleStyle.support">
|
||||
<color :data="{ field : 'color', 'label' : '商品销量', parent : 'saleStyle', defaultColor : '#999CA7' }"></color>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support && nc.btnStyle.control">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<slide :data="{ field : 'aroundRadius', label: '圆角', min:0, max: 50, parent: 'btnStyle' }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.btnStyle.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.btnStyle.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="nc.btnStyle.theme == 'diy'">
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '背景颜色', parent : 'btnStyle', defaultColor : '#FF7B1D,#FF1544' }"></color>
|
||||
<color :data="{ field : 'textColor', 'label' : '文字颜色', parent : 'btnStyle', defaultColor : '#FFFFFF' }"></color>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- 资源 -->
|
||||
<template slot="resource">
|
||||
<js>
|
||||
var pintuanResourcePath = "{$resource_path}"; // http路径
|
||||
var pintuanRelativePath = "{$relative_path}"; // 相对路径
|
||||
</js>
|
||||
<css src="{$resource_path}/css/design.css"></css>
|
||||
<js src="{$resource_path}/js/design.js"></js>
|
||||
</template>
|
||||
|
||||
</nc-component>
|
||||
BIN
addon/pintuan/component/view/pintuan/img/horizontal_slide_bg.png
Executable file
|
After Width: | Height: | Size: 11 KiB |
BIN
addon/pintuan/component/view/pintuan/img/horizontal_slide_name.png
Executable file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
addon/pintuan/component/view/pintuan/img/style_2_logo_1.png
Executable file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
addon/pintuan/component/view/pintuan/img/style_2_logo_2.png
Executable file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
addon/pintuan/component/view/pintuan/img/style_2_logo_3.png
Executable file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
addon/pintuan/component/view/pintuan/img/style_2_title.png
Executable file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
addon/pintuan/component/view/pintuan/img/style_title_1.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
addon/pintuan/component/view/pintuan/img/style_title_2.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
200
addon/pintuan/component/view/pintuan/js/design.js
Executable file
@@ -0,0 +1,200 @@
|
||||
var pintuanListHtml = '<div style="display:none;"></div>';
|
||||
|
||||
Vue.component("pintuan-list-sources", {
|
||||
template: pintuanListHtml,
|
||||
data: function () {
|
||||
return {
|
||||
data: this.$parent.data,
|
||||
goodsSources: {
|
||||
initial: {
|
||||
text: "默认",
|
||||
icon: "iconmofang"
|
||||
},
|
||||
diy: {
|
||||
text: "手动选择",
|
||||
icon: "iconshoudongxuanze"
|
||||
},
|
||||
},
|
||||
templateList: {
|
||||
"row1-of1": {
|
||||
text: "单列",
|
||||
icon: "iconiPhone86",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
saleSupport: true, // 是否支持商品销量
|
||||
lineSupport: true, // 是否支持划线价
|
||||
},
|
||||
],
|
||||
},
|
||||
"horizontal-slide": {
|
||||
text: "横向滑动",
|
||||
icon: "iconshangpinliebiaohengxianghuadong",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: false, // 是否支持按钮
|
||||
saleSupport: false, // 是否支持商品销量
|
||||
lineSupport: false, // 是否支持划线价
|
||||
},
|
||||
{
|
||||
text: "样式2",
|
||||
value: "style-2",
|
||||
cartSupport: false, // 是否支持按钮
|
||||
saleSupport: false, // 是否支持商品销量
|
||||
lineSupport: false, // 是否支持划线价
|
||||
},
|
||||
{
|
||||
text: "样式3",
|
||||
value: "style-3",
|
||||
cartSupport: false, // 是否支持按钮
|
||||
saleSupport: false, // 是否支持商品销量
|
||||
lineSupport: false, // 是否支持划线价
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
ornamentList: [
|
||||
{
|
||||
type: 'default',
|
||||
text: '默认',
|
||||
},
|
||||
{
|
||||
type: 'shadow',
|
||||
text: '投影',
|
||||
},
|
||||
{
|
||||
type: 'stroke',
|
||||
text: '描边',
|
||||
},
|
||||
],
|
||||
nameLineModeList: [
|
||||
{
|
||||
text: "单行",
|
||||
value: "single"
|
||||
},
|
||||
{
|
||||
text: "多行",
|
||||
value: "multiple"
|
||||
}
|
||||
],
|
||||
styleList: {
|
||||
"style-1": {
|
||||
styleName:'风格1',
|
||||
leftStyle: "img",
|
||||
leftImg: pintuanRelativePath + '/img/horizontal_slide_name.png',
|
||||
leftText: "超值拼团",
|
||||
backgroundImage: pintuanRelativePath + '/img/horizontal_slide_bg.png',
|
||||
bgColorStart: "#6236FF",
|
||||
bgColorEnd: "#0091FF",
|
||||
textColor: "#FFFFFF",
|
||||
moreColor: "#FFFFFF",
|
||||
more: "更多"
|
||||
},
|
||||
"style-2": {
|
||||
styleName:'风格2',
|
||||
leftStyle: "img",
|
||||
leftImg: pintuanRelativePath + '/img/style_2_title.png',
|
||||
leftText: "超值拼团",
|
||||
backgroundImage: "",
|
||||
bgColorStart: "#FFFFFF",
|
||||
bgColorEnd: "#FFFFFF",
|
||||
textColor: "#888888",
|
||||
moreColor: "#FFFFFF",
|
||||
more: "更多"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
if (!this.$parent.data.verify) this.$parent.data.verify = [];
|
||||
this.$parent.data.verify.push(this.verify);//加载验证方法
|
||||
|
||||
this.$parent.data.ignore = ['textColor']; //加载忽略内容 -- 其他设置中的属性设置
|
||||
this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
|
||||
|
||||
var previewList = {};
|
||||
for (var i = 1; i < 4; i++) {
|
||||
previewList["goods_id_" + ns.gen_non_duplicate(i)] = {
|
||||
goods_name: "拼团商品",
|
||||
discount_price: (Math.random() * 100 * i + 10).toFixed(2), // 随机价格
|
||||
line_price: (Math.random() * 100 * i + 100 + 10).toFixed(2), // 随机价格
|
||||
sale_num: Math.floor((Math.random() * 100 * i + 10 + 10))
|
||||
};
|
||||
}
|
||||
|
||||
// 组件所需的临时数据
|
||||
this.$parent.data.tempData = {
|
||||
goodsSources: this.goodsSources,
|
||||
templateList: this.templateList,
|
||||
ornamentList: this.ornamentList,
|
||||
nameLineModeList: this.nameLineModeList,
|
||||
styleList: this.styleList,
|
||||
previewList: previewList,
|
||||
methods: {
|
||||
addGoods: this.addGoods,
|
||||
selectTemplate: this.selectTemplate,
|
||||
selectTopStyle: this.selectTopStyle
|
||||
}
|
||||
};
|
||||
|
||||
loadImgMagnify();
|
||||
},
|
||||
methods: {
|
||||
verify: function (index) {
|
||||
var res = {code: true, message: ""};
|
||||
if (vue.data[index].sources === 'diy' && vue.data[index].goodsId.length === 0) {
|
||||
res.code = false;
|
||||
res.message = "请选择商品";
|
||||
}
|
||||
return res;
|
||||
},
|
||||
addGoods: function () {
|
||||
var self = this;
|
||||
goodsSelect(function (res) {
|
||||
self.$parent.data.goodsId = res;
|
||||
}, self.$parent.data.goodsId, {mode: "spu", promotion: "pintuan", disabled: 0, post: ns.appModule});
|
||||
},
|
||||
selectTemplate(template, item) {
|
||||
if (template) {
|
||||
this.$parent.data.template = template;
|
||||
item = this.templateList[template].styleList[0];
|
||||
}
|
||||
this.$parent.data.style = item.value;
|
||||
this.$parent.data.btnStyle.support = item.cartSupport;
|
||||
this.$parent.data.btnStyle.control = item.cartSupport;
|
||||
this.$parent.data.saleStyle.support = item.saleSupport;
|
||||
this.$parent.data.saleStyle.control = item.saleSupport;
|
||||
this.$parent.data.priceStyle.lineSupport = item.lineSupport;
|
||||
this.$parent.data.priceStyle.lineControl = item.lineSupport;
|
||||
},
|
||||
selectTopStyle: function () {
|
||||
var self = this;
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '风格选择',
|
||||
area: ['910px', '350px'],
|
||||
btn: ['确定', '返回'],
|
||||
content: $(".draggable-element[data-index='" + self.data.index + "'] .edit-attribute .style-list-box-pintuan").html(),
|
||||
success: function (layero, index) {
|
||||
$(".layui-layer-content input[name='style']").val(self.data.titleStyle.style);
|
||||
$(".layui-layer-content input[name='style_name']").val(self.data.titleStyle.styleName);
|
||||
$("body").off("click", ".layui-layer-content .style-list-con-pintuan .style-li-pintuan").on("click", ".layui-layer-content .style-list-con-pintuan .style-li-pintuan", function () {
|
||||
$(this).addClass("selected border-color").siblings().removeClass("selected border-color bg-color-after");
|
||||
$(".layui-layer-content input[name='style']").val($(this).attr("data_key"));
|
||||
$(".layui-layer-content input[name='style_name']").val($(this).find("span").text());
|
||||
});
|
||||
},
|
||||
yes: function (index, layero) {
|
||||
self.data.titleStyle.style = $(".layui-layer-content input[name='style']").val();
|
||||
Object.assign(self.data.titleStyle, self.styleList[self.data.titleStyle.style]);
|
||||
self.data.titleStyle.styleName = $(".layui-layer-content input[name='style_name']").val();
|
||||
layer.closeAll()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
83
addon/pintuan/config/diy_view.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [
|
||||
[
|
||||
'name' => 'Pintuan',
|
||||
'title' => '拼团',
|
||||
'type' => 'PROMOTION',
|
||||
'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"ornament":{"type":"default","color":"#EDEDED"},"nameLineMode":"single","template":"horizontal-slide","btnStyle":{"text":"去拼团","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":false,"support":false,"bgColorStart":"#FF1544","bgColorEnd":"#FF1544"},"imgAroundRadius":10,"saleStyle":{"color":"#FF1544","control":false,"support":false},"slideMode":"scroll","theme":"default","goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false},"priceStyle":{"mainColor":"#FF1544","mainControl":true,"lineColor":"#999CA7","lineControl":true,"lineSupport":true},"titleStyle":{"virtualNum": 999,"bgColorStart":"#6236FF","bgColorEnd":"#0091FF","isShow":true,"leftStyle":"img","leftImg":"addon/pintuan/component/view/pintuan/img/horizontal_slide_name.png","style":"style-1","styleName":"风格1","leftText":"超值拼团","fontSize":16,"fontWeight":true,"textColor":"#FFFFFF","more":"查看更多","moreColor":"#FFFFFF","moreFontSize":12,"backgroundImage":"addon/pintuan/component/view/pintuan/img/horizontal_slide_bg.png"},"goodsMarginType":"default","goodsMarginNum":10,"groupStyle":{"color":"#FFFFFF","control":true,"support":true,"bgColorStart":"#FA2379","bgColorEnd":"#FF4F61"}}',
|
||||
'sort' => '30001',
|
||||
'support_diy_view' => '',
|
||||
'max_count' => 0,
|
||||
'icon' => 'iconfont iconpintuan1'
|
||||
]
|
||||
],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [
|
||||
[
|
||||
'name' => 'PINTUAN',
|
||||
'title' => '拼团',
|
||||
'parent' => 'MARKETING_LINK',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'sort' => 0,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PINTUAN_PREFECTURE',
|
||||
'title' => '拼团专区',
|
||||
'wap_url' => '/pages_promotion/pintuan/list',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'MY_PINTUAN',
|
||||
'title' => '我的拼团',
|
||||
'wap_url' => '/pages_promotion/pintuan/my_spell',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PINTUAN_GOODS',
|
||||
'title' => '拼团商品',
|
||||
'parent' => 'COMMODITY',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'child_list' => []
|
||||
],
|
||||
],
|
||||
|
||||
// 自定义图标库
|
||||
'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' => []
|
||||
];
|
||||
78
addon/pintuan/config/event.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\pintuan\event\ShowPromotion',
|
||||
],
|
||||
//订单支付事件
|
||||
'OrderPay' => [
|
||||
'addon\pintuan\event\OrderPay',
|
||||
],
|
||||
'OrderClose' => [
|
||||
'addon\pintuan\event\OrderClose',
|
||||
],
|
||||
'PromotionType' => [
|
||||
'addon\pintuan\event\PromotionType',
|
||||
],
|
||||
//开启拼团活动
|
||||
'OpenPintuan' => [
|
||||
'addon\pintuan\event\OpenPintuan',
|
||||
],
|
||||
//关闭拼团活动
|
||||
'ClosePintuan' => [
|
||||
'addon\pintuan\event\ClosePintuan',
|
||||
],
|
||||
//关闭拼团组
|
||||
'ClosePintuanGroup' => [
|
||||
'addon\pintuan\event\ClosePintuanGroup',
|
||||
],
|
||||
// 商品营销活动类型
|
||||
'GoodsPromotionType' => [
|
||||
'addon\pintuan\event\GoodsPromotionType',
|
||||
],
|
||||
|
||||
// 商品营销活动信息
|
||||
'GoodsPromotion' => [
|
||||
'addon\pintuan\event\GoodsPromotion',
|
||||
],
|
||||
|
||||
// 商品列表
|
||||
'GoodsListPromotion' => [
|
||||
'addon\pintuan\event\GoodsListPromotion',
|
||||
],
|
||||
// 商品列表
|
||||
'GoodsListCategoryIds' => [
|
||||
'addon\pintuan\event\GoodsListCategoryIds',
|
||||
],
|
||||
|
||||
// 订单营销活动类型
|
||||
'OrderPromotionType' => [
|
||||
'addon\pintuan\event\OrderPromotionType',
|
||||
],
|
||||
/**
|
||||
* 消息发送
|
||||
*/
|
||||
//消息模板
|
||||
'SendMessageTemplate' => [
|
||||
//拼团成功
|
||||
'addon\pintuan\event\MessagePintuanComplete',
|
||||
|
||||
//拼团失败
|
||||
'addon\pintuan\event\MessagePintuanFail',
|
||||
],
|
||||
|
||||
// 活动专区——拼团页面配置
|
||||
'PromotionZoneConfig' => [
|
||||
'addon\pintuan\event\PintuanZoneConfig',
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/pintuan/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'pintuan',
|
||||
'title' => '拼团',
|
||||
'description' => '拼团管理活动',
|
||||
'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
84
addon/pintuan/config/menu_shop.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 店铺端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN',
|
||||
'title' => '拼团',
|
||||
'url' => 'pintuan://shop/pintuan/lists',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'is_show' => 1,
|
||||
'sort' => 100,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_LIST',
|
||||
'title' => '拼团商品',
|
||||
'url' => 'pintuan://shop/pintuan/lists',
|
||||
'is_show' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_ADD',
|
||||
'title' => '添加商品',
|
||||
'url' => 'pintuan://shop/pintuan/add',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_EDIT',
|
||||
'title' => '编辑商品',
|
||||
'url' => 'pintuan://shop/pintuan/edit',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_DETAIL',
|
||||
'title' => '拼团详情',
|
||||
'url' => 'pintuan://shop/pintuan/detail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_DELETE',
|
||||
'title' => '删除商品',
|
||||
'url' => 'pintuan://shop/pintuan/delete',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_INVALID',
|
||||
'title' => '结束活动',
|
||||
'url' => 'pintuan://shop/pintuan/invalid',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_GROUP',
|
||||
'title' => '拼团列表',
|
||||
'url' => 'pintuan://shop/pintuan/group',
|
||||
'parent' => 'PROMOTION_PINTUAN',
|
||||
'is_show' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_PINTUAN_GROUP_ORDER',
|
||||
'title' => '拼团组订单列表',
|
||||
'url' => 'pintuan://shop/pintuan/groupOrder',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
1
addon/pintuan/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/pintuan/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
28
addon/pintuan/event/ClosePintuan.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class ClosePintuan
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$pintuan = new Pintuan();
|
||||
$res = $pintuan->cronClosePintuan($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
28
addon/pintuan/event/ClosePintuanGroup.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\PintuanGroup;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class ClosePintuanGroup
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$pintuan = new PintuanGroup();
|
||||
$res = $pintuan->cronClosePintuanGroup($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
43
addon/pintuan/event/GoodsListCategoryIds.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
/**
|
||||
* 营销活动商品分类id
|
||||
*/
|
||||
class GoodsListCategoryIds
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'pintuan') return [];
|
||||
|
||||
$condition[] = [
|
||||
['pp.site_id', '=', $param[ 'site_id' ]],
|
||||
['pp.status', '=', 1],
|
||||
['g.is_delete','=',0],
|
||||
['g.goods_state','=',1],
|
||||
];
|
||||
|
||||
$model = new Pintuan();
|
||||
$res = $model->getGoodsCategoryIds($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
63
addon/pintuan/event/GoodsListPromotion.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsListPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'pintuan') return [];
|
||||
|
||||
$condition[] = [
|
||||
['pp.site_id', '=', $param[ 'site_id' ]],
|
||||
['pp.status', '=', 1],
|
||||
['g.is_delete','=',0],
|
||||
['g.goods_state','=',1]
|
||||
];
|
||||
|
||||
if ($param[ 'promotion_name' ]) {
|
||||
$condition[] = ['pp.pintuan_name', 'like', '%' . $param[ 'promotion_name' ] . '%'];
|
||||
}
|
||||
if(!empty($param['goods_name'])){
|
||||
$condition[] = ['g.goods_name', 'like', '%'.$param['goods_name'].'%'];
|
||||
}
|
||||
if (!empty($param['select_type']) && $param['select_type'] == 'selected' && isset($param['goods_ids'])) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $param['goods_ids'] ];
|
||||
}
|
||||
if (!empty($param['category_id'])) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $param['category_id'] . ',%' ];
|
||||
}
|
||||
if (!empty($param['label_id'])) {
|
||||
$condition[] = [ 'g.label_id', '=', $param['label_id'] ];
|
||||
}
|
||||
if (!empty($param['goods_class'])) {
|
||||
$condition[] = [ 'g.goods_class', '=', $param['goods_class'] ];
|
||||
}
|
||||
|
||||
$model = new Pintuan();
|
||||
$list = $model->getPintuanGoodsPageList($condition, $param[ 'page' ], $param[ 'page_size' ], 'pp.pintuan_id desc');
|
||||
$list['condition'] = $condition;
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
69
addon/pintuan/event/GoodsPromotion.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (isset($param[ 'goods_sku_detail' ])) {
|
||||
$goods_info = $param[ 'goods_sku_detail' ];
|
||||
if (!empty($goods_info[ 'promotion_addon' ])) {
|
||||
$promotion_addon = json_decode($goods_info[ 'promotion_addon' ], true);
|
||||
if (!empty($promotion_addon[ 'pintuan' ])) {
|
||||
return [
|
||||
'promotion_type' => 'pintuan',
|
||||
'promotion_name' => '拼团',
|
||||
'pintuan_id' => $promotion_addon[ 'pintuan' ]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (empty($param[ 'goods_id' ])) return [];
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_info = $goods_model->getGoodsInfo([ [ 'goods_id', '=', $param[ 'goods_id' ] ] ], 'promotion_addon')[ 'data' ];
|
||||
if (!empty($goods_info[ 'promotion_addon' ])) {
|
||||
$promotion_addon = json_decode($goods_info[ 'promotion_addon' ], true);
|
||||
if (!empty($promotion_addon[ 'pintuan' ])) {
|
||||
$pintuan_model = new Pintuan();
|
||||
$condition = [
|
||||
[ 'ppg.pintuan_id', '=', $promotion_addon[ 'pintuan' ] ],
|
||||
[ 'pp.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$field = 'ppg.id,ppg.pintuan_id,ppg.goods_id,ppg.sku_id,ppg.pintuan_price,ppg.promotion_price,pp.pintuan_name';
|
||||
$goods_detail = $pintuan_model->getPintuanGoodsDetail($condition, $field)[ 'data' ];
|
||||
if (!empty($goods_detail)) {
|
||||
$goods_detail[ 'promotion_type' ] = 'pintuan';
|
||||
$goods_detail[ 'promotion_name' ] = '拼团';
|
||||
return $goods_detail;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/pintuan/event/GoodsPromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class GoodsPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ 'name' => '拼团', 'short' => '拼', 'type' => 'pintuan', 'color' => '#F58760', 'url' => 'pintuan://shop/pintuan/lists' ];
|
||||
}
|
||||
}
|
||||
25
addon/pintuan/event/Install.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
27
addon/pintuan/event/MessagePintuanComplete.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
class MessagePintuanComplete
|
||||
{
|
||||
|
||||
public function handle($param)
|
||||
{
|
||||
//发送消息
|
||||
if ($param[ "keywords" ] == "PINTUAN_COMPLETE") {
|
||||
$model = new Pintuan();
|
||||
$result = $model->pintuanCompleteMessage($param);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
addon/pintuan/event/MessagePintuanFail.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
/**
|
||||
* 关闭活动消息
|
||||
*/
|
||||
class MessagePintuanFail
|
||||
{
|
||||
|
||||
public function handle($param)
|
||||
{
|
||||
//发送消息
|
||||
if ($param["keywords"] == "PINTUAN_FAIL") {
|
||||
$model = new Pintuan();
|
||||
$result = $model->pintuanFailMessage($param);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
addon/pintuan/event/OpenPintuan.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class OpenPintuan
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$pintuan = new Pintuan();
|
||||
$res = $pintuan->cronOpenPintuan($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
37
addon/pintuan/event/OrderClose.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\PintuanOrder;
|
||||
|
||||
/**
|
||||
* 订单关闭衍生
|
||||
*/
|
||||
class OrderClose
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param $param
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
if ($params[ 'promotion_type' ] == 'pintuan') {
|
||||
$pintuan_order = new PintuanOrder();
|
||||
$condition= array(
|
||||
['order_id', '=', $params['order_id']]
|
||||
);
|
||||
$res = $pintuan_order->pintuanOrderClose($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
34
addon/pintuan/event/OrderPay.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use addon\pintuan\model\PintuanOrder;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class OrderPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param $param
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if ($param[ 'promotion_type' ] == 'pintuan') {
|
||||
$pintuan_order = new PintuanOrder();
|
||||
$res = $pintuan_order->orderPay($param);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/pintuan/event/OrderPromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
/**
|
||||
* 订单营销活动类型
|
||||
*/
|
||||
class OrderPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 订单营销活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "拼团", "type" => "pintuan" ];
|
||||
}
|
||||
}
|
||||
37
addon/pintuan/event/PintuanZoneConfig.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
|
||||
/**
|
||||
* 活动专区——拼团页面配置
|
||||
*/
|
||||
class PintuanZoneConfig
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
if (empty($params) || $params[ 'name' ] == 'pintuan') {
|
||||
$data = [
|
||||
'name' => 'pintuan', // 标识
|
||||
'title' => '拼团', // 名称
|
||||
'url' => 'shop/adv/lists?keyword=NS_PINTUAN', // 自定义跳转链接
|
||||
'preview' => 'addon/pintuan/shop/view/public/img/zone_preview.png', // 预览图
|
||||
// 页面配置
|
||||
'value' => [
|
||||
'bg_color' => '#FA3A1D'
|
||||
],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
27
addon/pintuan/event/PromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "拼团", "type" => "pintuan" ];
|
||||
}
|
||||
}
|
||||
98
addon/pintuan/event/ShowPromotion.php
Executable file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params = [])
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'pintuan',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '拼团',
|
||||
//展示介绍
|
||||
'description' => '邀请朋友一起拼团购买',
|
||||
//展示图标
|
||||
'icon' => 'addon/pintuan/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'pintuan://shop/pintuan/lists',
|
||||
'summary' => $this->summary($params)
|
||||
]
|
||||
]
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("promotion_pintuan")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$join = [
|
||||
[ 'goods g', 'p.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
$list = model("promotion_pintuan")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'p.site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'p.status', '<>', 2 ],
|
||||
[ 'p.status', '<>', 3 ],
|
||||
[ 'p.status', '<>', 4 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
], 'p.pintuan_name as promotion_name,p.pintuan_id as promotion_id,p.start_time,p.end_time', '', 'p', $join, 'p.pintuan_name');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#6D66FF'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
25
addon/pintuan/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/pintuan/icon.png
Executable file
|
After Width: | Height: | Size: 1.0 KiB |
1006
addon/pintuan/model/Pintuan.php
Executable file
513
addon/pintuan/model/PintuanGroup.php
Executable file
@@ -0,0 +1,513 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\message\Message;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderRefund;
|
||||
use app\model\system\Cron;
|
||||
|
||||
/**
|
||||
* 拼团组
|
||||
*/
|
||||
class PintuanGroup extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 创建拼团组
|
||||
* @param $pintuan_order_info
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function addPintuanGroup($pintuan_order_info)
|
||||
{
|
||||
model('promotion_pintuan_group')->startTrans();
|
||||
//获取拼团信息
|
||||
$pintuan_model = new Pintuan();
|
||||
$pintuan_id = $pintuan_order_info[ 'pintuan_id' ];
|
||||
$pintuan_info = $pintuan_model->getPintuanInfo([ [ 'pintuan_id', '=', $pintuan_id ] ])[ 'data' ] ?? [];
|
||||
$pintuan_type = $pintuan_info[ 'pintuan_type' ];//类型
|
||||
switch ( $pintuan_type ) {
|
||||
case 'ordinary'://默认拼团方式
|
||||
$pintuan_num = $pintuan_info[ 'pintuan_num' ];
|
||||
break;
|
||||
case 'ladder'://阶梯拼团
|
||||
$pintuan_num = $pintuan_order_info[ 'pintuan_num' ];
|
||||
break;
|
||||
}
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'site_id' => $pintuan_info[ 'site_id' ],
|
||||
'goods_id' => $pintuan_info[ 'goods_id' ],
|
||||
'is_virtual_goods' => $pintuan_info[ 'is_virtual_goods' ],
|
||||
'pintuan_id' => $pintuan_order_info[ 'pintuan_id' ],
|
||||
'head_id' => $pintuan_order_info[ 'head_id' ],
|
||||
'pintuan_num' => $pintuan_num,
|
||||
'pintuan_count' => 1,
|
||||
'create_time' => time(),
|
||||
'end_time' => time() + ( $pintuan_info[ 'pintuan_time' ] * 60 ),
|
||||
'status' => 2,
|
||||
'is_virtual_buy' => $pintuan_info[ 'is_virtual_buy' ],
|
||||
'is_single_buy' => $pintuan_info[ 'is_single_buy' ],
|
||||
'is_promotion' => $pintuan_info[ 'is_promotion' ],
|
||||
'buy_num' => $pintuan_info[ 'buy_num' ],
|
||||
];
|
||||
$res = model('promotion_pintuan_group')->add($data);
|
||||
|
||||
//添加拼团组关闭事件
|
||||
$cron = new Cron();
|
||||
$cron->addCron(1, 0, "拼团组关闭", "ClosePintuanGroup", $data[ 'end_time' ], $res);
|
||||
|
||||
//更新拼团开组人数及购买人数
|
||||
$pintua_data = [
|
||||
'group_num' => $pintuan_info[ 'group_num' ] + 1,
|
||||
'order_num' => $pintuan_info[ 'order_num' ] + 1,
|
||||
];
|
||||
$pintuan_model->editPintuanNum($pintua_data, [ [ 'pintuan_id', '=', $pintuan_order_info[ 'pintuan_id' ] ] ]);
|
||||
|
||||
model('promotion_pintuan_group')->commit();
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑组信息
|
||||
* @param array $condition
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public function editPintuanGroup($condition = [], $data = [])
|
||||
{
|
||||
$res = model('promotion_pintuan_group')->update($data, $condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入拼团组
|
||||
* @param $pintuan_order_info
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function joinPintuanGroup($pintuan_order_info)
|
||||
{
|
||||
model('promotion_pintuan_group')->startTrans();
|
||||
//获取拼团信息
|
||||
$pintuan_model = new Pintuan();
|
||||
$pintuan_id = $pintuan_order_info[ 'pintuan_id' ];
|
||||
$pintuan = $pintuan_model->getPintuanInfo([ [ 'pintuan_id', '=', $pintuan_id ] ]);
|
||||
$pintuan_info = $pintuan[ 'data' ];
|
||||
|
||||
try {
|
||||
|
||||
$order_num = $pintuan_info[ 'order_num' ] + 1;
|
||||
$success_group_num = $pintuan_info[ 'success_group_num' ];
|
||||
|
||||
//获取拼团组信息
|
||||
$group_info = $this->getPintuanGroupInfo([ [ 'group_id', '=', $pintuan_order_info[ 'group_id' ] ] ])[ 'data' ] ?? [];
|
||||
//更新拼团组当前数量及状态
|
||||
$pintuan_count = $group_info[ 'pintuan_count' ] + 1;
|
||||
$res = $this->editPintuanGroup([ [ 'group_id', '=', $pintuan_order_info[ 'group_id' ] ] ], [ 'pintuan_count' => $pintuan_count ]);
|
||||
|
||||
if ($pintuan_count == $group_info[ 'pintuan_num' ]) {//已成团
|
||||
|
||||
$success_group_num += 1;
|
||||
//修改拼团组状态
|
||||
model('promotion_pintuan_group')->update([ 'status' => 3 ], [ [ 'group_id', '=', $pintuan_order_info[ 'group_id' ] ] ]);
|
||||
|
||||
//查询该组所有订单
|
||||
$pintuan_order_model = new PintuanOrder();
|
||||
$pintuan_order = $pintuan_order_model->getPintuanOrderList([ [ 'group_id', '=', $pintuan_order_info[ 'group_id' ] ] ], 'order_id,pintuan_status');
|
||||
$pintuan_order_list = $pintuan_order[ 'data' ];
|
||||
$message_model = new Message();
|
||||
$order_model = new OrderCommon();
|
||||
if (!empty($pintuan_order_list)) {
|
||||
foreach ($pintuan_order_list as $v) {
|
||||
switch ( $v[ 'pintuan_status' ] ) {
|
||||
case 0:
|
||||
//将未支付的修改为失败
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//开放订单
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
//关闭订单
|
||||
$result = $order_model->orderClose($v[ 'order_id' ], [], '当前拼团已成团,由于您未及时支付,该订单已关闭');
|
||||
if ($result[ "code" ] < 0) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $result;
|
||||
}
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团失败' ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
|
||||
// 发送消息
|
||||
$param = [ 'keywords' => 'PINTUAN_FAIL', 'time' => time(), 'order_id' => $v[ 'order_id' ], 'site_id' => $group_info[ 'site_id' ] ];
|
||||
$message_model->sendMessage($param);
|
||||
break;
|
||||
|
||||
break;
|
||||
case 2://已支付
|
||||
|
||||
//将已支付的修改为成功
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 3 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//开放订单
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团成功', 'is_enable_refund' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//针对虚拟订单执行收发货操作
|
||||
// if ($group_info['is_virtual_goods'] == 1) {
|
||||
// $order_model->orderCommonTakeDelivery($v['order_id']);
|
||||
// }
|
||||
$pintuan_order_model = new PintuanOrder();
|
||||
$pintuan_order_model->virtualSuccessAction($v[ 'order_id' ]);
|
||||
|
||||
// 发送消息
|
||||
$param = [ 'keywords' => 'PINTUAN_COMPLETE', 'time' => time(), 'order_id' => $v[ 'order_id' ], 'site_id' => $group_info[ 'site_id' ] ];
|
||||
$message_model->sendMessage($param);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//更新拼团 购买人数
|
||||
$pintuan_model->editPintuanNum([ 'order_num' => $order_num, 'success_group_num' => $success_group_num ], [ [ 'pintuan_id', '=', $pintuan_order_info[ 'pintuan_id' ] ] ]);
|
||||
|
||||
model('promotion_pintuan_group')->commit();
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询拼团组信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanGroupInfo($condition = [], $field = '*')
|
||||
{
|
||||
$group_info = model('promotion_pintuan_group')->getInfo($condition, $field);
|
||||
return $this->success($group_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团组详情
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanGroupDetail($condition)
|
||||
{
|
||||
$field = 'pg.*,m.nickname,m.headimg,og.sku_name,og.sku_image,pp.pintuan_price';
|
||||
$alias = 'pg';
|
||||
$join = [
|
||||
[ 'promotion_pintuan_order ppo', 'ppo.group_id = pg.group_id and ppo.member_id = pg.head_id', 'inner' ],
|
||||
[ 'promotion_pintuan pp', 'pp.pintuan_id = pg.pintuan_id', 'inner' ],
|
||||
[ 'order_goods og', 'og.order_id = ppo.order_id', 'inner' ],
|
||||
[ 'member m', 'm.member_id = pg.head_id', 'inner' ]
|
||||
];
|
||||
$info = model('promotion_pintuan_group')->getInfo($condition, $field, $alias, $join);
|
||||
//查询参与拼单的会员
|
||||
if (!empty($info)) {
|
||||
$member_list = model('promotion_pintuan_order')->getList([ [ "group_id", "=", $info[ "group_id" ] ], [ 'pintuan_status', 'not in', '0,1' ] ], "pintuan_status,member_img,nickname,member_id");
|
||||
$info[ "member_list" ] = $member_list;
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanGroupList($condition = [], $field = '*')
|
||||
{
|
||||
$list = model('promotion_pintuan_group')->getList($condition, $field);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团组商品列表
|
||||
* @param array $condition
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanGoodsGroupList($condition = [])
|
||||
{
|
||||
$field = 'ppg.group_id,ppg.goods_id,ppg.pintuan_id,ppg.head_id,ppg.pintuan_num,ppg.pintuan_count,ppg.create_time,ppg.end_time,ppg.status,ppg.is_single_buy,ppg.is_promotion,ppg.buy_num,m.member_id,m.nickname,m.headimg';
|
||||
$alias = 'ppg';
|
||||
$join = [
|
||||
[
|
||||
'member m',
|
||||
'ppg.head_id = m.member_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$list = model('promotion_pintuan_group')->getList($condition, $field, 'ppg.create_time desc', $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团组分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
*/
|
||||
public function getPintuanGroupPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '')
|
||||
{
|
||||
$field = 'pg.*,g.goods_name,g.goods_image,m.nickname,m.headimg';
|
||||
$alias = 'pg';
|
||||
$join = [
|
||||
[
|
||||
'goods g',
|
||||
'pg.goods_id = g.goods_id',
|
||||
'inner'
|
||||
],
|
||||
[
|
||||
'member m',
|
||||
'm.member_id = pg.head_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$list = model('promotion_pintuan_group')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭拼团组
|
||||
* @param $group_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function cronClosePintuanGroup($group_id)
|
||||
{
|
||||
model('promotion_pintuan_group')->startTrans();
|
||||
try {
|
||||
|
||||
//获取拼团组信息
|
||||
$pintuan_group = model('promotion_pintuan_group')->getInfo([ [ 'group_id', '=', $group_id ] ], 'status,is_virtual_buy,is_virtual_goods');
|
||||
|
||||
if (!empty($pintuan_group)) {
|
||||
|
||||
if ($pintuan_group[ 'status' ] == 2) {
|
||||
//关闭所有已支付的订单
|
||||
$res = $this->closePaidGroupOrder($group_id, $pintuan_group[ 'is_virtual_buy' ], $pintuan_group[ 'is_virtual_goods' ]);
|
||||
if ($res[ 'code' ] < 0) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
model('promotion_pintuan_group')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭拼团组未支付订单
|
||||
* @param $group_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function closeUnpaidGroupOrder($group_id)
|
||||
{
|
||||
//获取所有改组未支付的订单
|
||||
$pintuan_order_model = new PintuanOrder();
|
||||
$unpaid_order = $pintuan_order_model->getPintuanOrderList([ [ 'group_id', '=', $group_id ], [ 'pintuan_status', '=', 0 ] ], 'order_id');
|
||||
$unpaid_order_list = $unpaid_order[ 'data' ];
|
||||
|
||||
model('promotion_pintuan_order')->startTrans();
|
||||
|
||||
$order_model = new OrderCommon();
|
||||
try {
|
||||
if (!empty($unpaid_order_list)) {
|
||||
foreach ($unpaid_order_list as $v) {
|
||||
|
||||
//修改拼团订单状态
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//解除锁定
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
//关闭订单
|
||||
$result = $order_model->orderClose($v[ 'order_id' ], [], '拼团祖关闭,订单自动关闭');
|
||||
if ($result[ "code" ] < 0) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $result;
|
||||
}
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团失败' ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
model('promotion_pintuan_order')->commit();
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_pintuan_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭拼团组已支付订单
|
||||
* @param $group_id
|
||||
* @param $is_virtual_buy
|
||||
* @param $is_virtual_goods
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function closePaidGroupOrder($group_id, $is_virtual_buy, $is_virtual_goods)
|
||||
{
|
||||
//获取所有该组的订单
|
||||
$pintuan_order_model = new PintuanOrder();
|
||||
$paid_order = $pintuan_order_model->getPintuanOrderList([ [ 'group_id', '=', $group_id ] ], 'order_id,pintuan_status,site_id');
|
||||
$paid_order_list = $paid_order[ 'data' ];
|
||||
|
||||
$order_model = new OrderCommon();
|
||||
$message_model = new Message();
|
||||
model('promotion_pintuan_group')->startTrans();
|
||||
|
||||
try {
|
||||
if ($is_virtual_buy == 1) {//虚拟成团
|
||||
//修改拼团组状态(成功)
|
||||
$res = model('promotion_pintuan_group')->update([ 'status' => 3 ], [ [ 'group_id', '=', $group_id ] ]);
|
||||
|
||||
//获取拼团组信息
|
||||
$pintuan_id = model('promotion_pintuan_group')->getValue([ [ 'group_id', '=', $group_id ] ], 'pintuan_id');
|
||||
//更新拼团 成团组数
|
||||
model('promotion_pintuan')->setInc([ [ 'pintuan_id', '=', $pintuan_id ] ], 'success_group_num');
|
||||
|
||||
if (!empty($paid_order_list)) {
|
||||
|
||||
$order_id = 0;
|
||||
foreach ($paid_order_list as $v) {
|
||||
switch ( $v[ 'pintuan_status' ] ) {
|
||||
case 0:
|
||||
//将未支付的修改为失败
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//解除锁定
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
//关闭订单
|
||||
$result = $order_model->orderClose($v[ 'order_id' ], [], '拼团祖关闭,订单自动关闭');
|
||||
if ($result[ "code" ] < 0) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $result;
|
||||
}
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团失败' ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
// 发送消息
|
||||
$param = [ 'keywords' => 'PINTUAN_FAIL', 'time' => time(), 'order_id' => $v[ 'order_id' ], 'site_id' => $v[ 'site_id' ] ];
|
||||
$message_model->sendMessage($param);
|
||||
break;
|
||||
case 2://已支付
|
||||
|
||||
$order_id = $v[ 'order_id' ];
|
||||
//解除锁定
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
|
||||
//将已支付的修改为成功
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 3 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团成功', 'is_enable_refund' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//针对虚拟订单执行收发货操作
|
||||
// if ($is_virtual_goods == 1) {
|
||||
// $Virtual_model = new VirtualOrder();
|
||||
// $Virtual_model->orderTakeDelivery($v['order_id']);
|
||||
// }
|
||||
$pintuan_order_model = new PintuanOrder();
|
||||
$pintuan_order_model->virtualSuccessAction($v[ 'order_id' ]);
|
||||
// 发送消息
|
||||
$param = [ 'keywords' => 'PINTUAN_COMPLETE', 'time' => time(), 'order_id' => $v[ 'order_id' ], 'site_id' => $v[ 'site_id' ] ];
|
||||
$message_model->sendMessage($param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {//未开启虚拟成团
|
||||
|
||||
//修改拼团组状态为失败
|
||||
$res = model('promotion_pintuan_group')->update([ 'status' => 1 ], [ [ 'group_id', '=', $group_id ] ]);
|
||||
if (!empty($paid_order_list)) {
|
||||
foreach ($paid_order_list as $v) {
|
||||
switch ( $v[ 'pintuan_status' ] ) {
|
||||
case 0:
|
||||
|
||||
//将未支付的修改为失败
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//解除锁定
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
//关闭订单
|
||||
$result = $order_model->orderClose($v[ 'order_id' ], [], '拼团失败,订单自动关闭');
|
||||
if ($result[ "code" ] < 0) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $result;
|
||||
}
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团失败' ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
// 发送消息
|
||||
$param = [ 'keywords' => 'PINTUAN_FAIL', 'time' => time(), 'order_id' => $v[ 'order_id' ], 'site_id' => $v[ 'site_id' ] ];
|
||||
$message_model->sendMessage($param);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
//关闭拼团订单
|
||||
model('promotion_pintuan_order')->update([ 'pintuan_status' => 1 ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
//解除锁定
|
||||
$order_model->orderUnlock($v[ 'order_id' ]);
|
||||
|
||||
//主动退款
|
||||
$order_refund_model = new OrderRefund();
|
||||
$refund_result = $order_refund_model->activeRefund($v[ 'order_id' ], "拼团订单关闭", '拼团订单关闭');
|
||||
|
||||
if ($refund_result[ "code" ] < 0) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $refund_result;
|
||||
}
|
||||
|
||||
//关闭订单
|
||||
// $result = $order_model->orderClose($v['order_id'], [], '拼团失败,订单自动关闭');
|
||||
// if ($result["code"] < 0) {
|
||||
// model('promotion_pintuan_group')->rollback();
|
||||
// return $result;
|
||||
// }
|
||||
//更新订单营销状态名称
|
||||
model('order')->update([ 'promotion_status_name' => '拼团失败' ], [ [ 'order_id', '=', $v[ 'order_id' ] ] ]);
|
||||
// 发送消息
|
||||
$param = [ 'keywords' => 'PINTUAN_FAIL', 'time' => time(), 'order_id' => $v[ 'order_id' ], 'site_id' => $v[ 'site_id' ] ];
|
||||
$message_model->sendMessage($param);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
model('promotion_pintuan_group')->commit();
|
||||
return $this->success($res);
|
||||
} catch (\Exception $e) {
|
||||
model('promotion_pintuan_group')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
310
addon/pintuan/model/PintuanOrder.php
Executable file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\VirtualOrder;
|
||||
|
||||
/**
|
||||
* 拼团订单
|
||||
*/
|
||||
class PintuanOrder extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 开团/参团
|
||||
* @param $order
|
||||
* @param int $group_id
|
||||
* @param $pintuan_id
|
||||
* @return array|\multitype
|
||||
*/
|
||||
public function addPintuanOrder($order, $group_id, $pintuan_id)
|
||||
{
|
||||
$site_id = $order['site_id'];
|
||||
$order_id = $order['order_id'];
|
||||
$order_no = $order['order_no'];
|
||||
$order_type = $order['order_type']['order_type_id'];
|
||||
$member_id = $order['member_id'];
|
||||
$member_info = $order['member_account'];
|
||||
//获取拼团信息
|
||||
$pintuan_info = $order['pintuan_info'];
|
||||
//判断拼团活动状态
|
||||
if ($pintuan_info['status'] != 1) {
|
||||
return $this->error('', '该拼团活动已结束');//该拼团活动已结束
|
||||
}
|
||||
$order_extend = $order['extend'] ?? [];
|
||||
if (!empty($order_extend)) {
|
||||
$pintuan_num = $order_extend['pintuan_num'];
|
||||
}
|
||||
//判断是开团还是拼团
|
||||
$pintuan_order_data = array(
|
||||
'pintuan_id' => $pintuan_id,
|
||||
'order_id' => $order_id,
|
||||
'order_no' => $order_no,
|
||||
'order_type' => $order_type,
|
||||
'pintuan_status' => 0,
|
||||
'site_id' => $site_id,
|
||||
'member_id' => $member_id,
|
||||
'member_img' => $member_info['headimg'],
|
||||
'nickname' => $member_info['nickname'],
|
||||
'pintuan_num' => $pintuan_num ?? 0//阶梯规格
|
||||
);
|
||||
if ($group_id) {//拼团
|
||||
//拼团组信息
|
||||
$pintuan_group_info = $order['pintuan_group_info'];
|
||||
$result = $this->isCanJoinGroup($group_id, $member_id);
|
||||
if ($result['code'] < 0) {
|
||||
return $result;
|
||||
}
|
||||
$pintuan_order_data['group_id'] = $group_id;
|
||||
$pintuan_order_data['head_id'] = $pintuan_group_info['head_id'];
|
||||
} else {//开团
|
||||
$pintuan_order_data['group_id'] = 0;
|
||||
$pintuan_order_data['head_id'] = $member_id;
|
||||
}
|
||||
$res = model('promotion_pintuan_order')->add($pintuan_order_data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否可以参团
|
||||
* @param $group_id
|
||||
* @param $member_id
|
||||
* @return array
|
||||
*/
|
||||
public function isCanJoinGroup($group_id, $member_id)
|
||||
{
|
||||
if ($group_id > 0) {
|
||||
$pintuan_group_model = new PintuanGroup();
|
||||
$pintuan_group = $pintuan_group_model->getPintuanGroupInfo(
|
||||
[['group_id', '=', $group_id]], 'group_id,head_id,pintuan_num,pintuan_count,status'
|
||||
);
|
||||
$pintuan_group_info = $pintuan_group['data'];
|
||||
|
||||
if ($pintuan_group_info['head_id'] == $member_id) {
|
||||
return $this->error('', '抱歉,您不能参与自己的团');
|
||||
}
|
||||
if ($pintuan_group_info['status'] != 2) {
|
||||
return $this->error('', '该拼团组已失效');
|
||||
}
|
||||
if ($pintuan_group_info['pintuan_num'] == $pintuan_group_info['pintuan_count']) {
|
||||
return $this->error('', '该拼团组已满员,请参加别的拼团或自己开团');
|
||||
}
|
||||
//判断是否已参团
|
||||
$count = model('promotion_pintuan_order')->getCount(
|
||||
[
|
||||
['po.group_id', '=', $group_id],
|
||||
['po.pintuan_status', 'in', '0,2'],
|
||||
['po.member_id', '=', $member_id],
|
||||
[' o.order_status', '<>', OrderCommon::ORDER_CLOSE],
|
||||
],
|
||||
'po.pintuan_id', 'po',
|
||||
[
|
||||
['order o', 'o.order_id = po.order_id', 'left']
|
||||
]
|
||||
);
|
||||
|
||||
if ($count > 0) {
|
||||
return $this->error('', '请不要重复参团');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @return array
|
||||
*/
|
||||
public function orderPay($order)
|
||||
{
|
||||
model('promotion_pintuan_order')->startTrans();
|
||||
try {
|
||||
//禁止拼团订单在未成团中申请退款
|
||||
model('order')->update(['is_enable_refund' => 0], [['order_id', '=', $order['order_id']]]);
|
||||
//支付操作查询拼团订单,如果group_id=0,创建组,else,检测成团
|
||||
//获取拼团订单信息
|
||||
$pintuan_order = $this->getPintuanOrderInfo([['order_id', '=', $order['order_id']]]);
|
||||
$pintuan_order_info = $pintuan_order['data'];
|
||||
|
||||
$order_common_model = new OrderCommon();
|
||||
$local_result = $order_common_model->orderLock($order['order_id']);
|
||||
if (!$local_result) return $this->error();
|
||||
|
||||
$pintuan_group_model = new PintuanGroup();
|
||||
if ($pintuan_order_info['group_id'] == 0) {
|
||||
//开团
|
||||
//创建组
|
||||
$group_id = $pintuan_group_model->addPintuanGroup($pintuan_order_info);
|
||||
|
||||
//更新拼团订单组信息
|
||||
$pintuan_order_data['group_id'] = $group_id['data'];
|
||||
$pintuan_order_data['pintuan_status'] = 2;
|
||||
$res = model('promotion_pintuan_order')->update($pintuan_order_data, [['order_id', '=', $order['order_id']]]);
|
||||
//更新订单营销状态名称
|
||||
model('order')->update(['promotion_status_name' => '拼团中'], [['order_id', '=', $order['order_id']]]);
|
||||
|
||||
} else {//参团
|
||||
|
||||
//更新拼团订单信息
|
||||
$pintuan_order_data['pintuan_status'] = 2;
|
||||
$res = model('promotion_pintuan_order')->update($pintuan_order_data, [['order_id', '=', $order['order_id']]]);
|
||||
//更新订单营销状态名称
|
||||
model('order')->update(['promotion_status_name' => '拼团中'], [['order_id', '=', $order['order_id']]]);
|
||||
|
||||
//加入组
|
||||
$pintuan_group_model->joinPintuanGroup($pintuan_order_info);
|
||||
}
|
||||
|
||||
model('promotion_pintuan_order')->commit();
|
||||
return $this->success($res);
|
||||
} catch ( \Exception $e ) {
|
||||
model('promotion_pintuan_order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团订单信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanOrderInfo($condition = [], $field = '*', $alias = '', $join = '')
|
||||
{
|
||||
$order_info = model('promotion_pintuan_order')->getInfo($condition, $field, $alias, $join);
|
||||
return $this->success($order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanOrderList($condition = [], $field = '*', $order = '', $limit = null, $group_by = '')
|
||||
{
|
||||
$list = model('promotion_pintuan_order')->getList($condition, $field, $order, '', '', $group_by, $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanOrderPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '')
|
||||
{
|
||||
$field = 'ppo.*,ppgs.id as pintuan_goods_id,
|
||||
ppg.pintuan_num,ppg.pintuan_count,ppg.is_promotion,ppg.end_time as group_end_time,
|
||||
o.site_name,o.pay_time,o.pay_money,o.order_status_name,o.name,o.order_money,o.mobile,o.address,o.full_address,o.order_from_name,o.pay_type_name,
|
||||
og.sku_name,og.sku_image';
|
||||
$alias = 'ppo';
|
||||
$join = [
|
||||
['order o', 'o.order_id = ppo.order_id', 'left'],
|
||||
['order_goods og', 'og.order_id = ppo.order_id', 'left'],
|
||||
['promotion_pintuan_group ppg', 'ppo.group_id = ppg.group_id', 'left'],
|
||||
['promotion_pintuan_goods ppgs', 'og.sku_id = ppgs.sku_id and ppgs.pintuan_id=ppo.pintuan_id', 'inner']
|
||||
];
|
||||
$list = model('promotion_pintuan_order')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团订单详情
|
||||
* @param $order_id
|
||||
* @param $member_id
|
||||
*/
|
||||
public function getPintuanOrderDetail($id, $member_id, $site_id)
|
||||
{
|
||||
$field = 'ppo.*,ppgs.id as pintuan_goods_id,
|
||||
ppg.pintuan_num,ppg.pintuan_count,ppg.is_promotion,ppg.end_time as group_end_time,ppgs.pintuan_price,
|
||||
pp.group_num,pp.order_num,pp.status,
|
||||
gs.discount_price,
|
||||
o.site_name,o.pay_time,o.pay_money,o.order_status_name,o.name,o.mobile,o.address,o.full_address,o.order_from_name,o.pay_type_name,o.order_type,o.order_money,
|
||||
og.sku_name,og.sku_image';
|
||||
$alias = 'ppo';
|
||||
$join = [
|
||||
['order o', 'o.order_id = ppo.order_id', 'left'],
|
||||
['order_goods og', 'og.order_id = ppo.order_id', 'left'],
|
||||
['promotion_pintuan_group ppg', 'ppo.group_id = ppg.group_id', 'left'],
|
||||
['promotion_pintuan pp', 'pp.pintuan_id = ppo.pintuan_id', 'left'],
|
||||
['goods_sku gs', 'gs.sku_id = og.sku_id', 'left'],
|
||||
['promotion_pintuan_goods ppgs', 'og.sku_id = ppgs.sku_id and ppgs.pintuan_id=ppo.pintuan_id', 'left']
|
||||
];
|
||||
$condition = array(
|
||||
["ppo.id", "=", $id],
|
||||
["ppo.member_id", "=", $member_id],
|
||||
["ppo.site_id", "=", $site_id],
|
||||
);
|
||||
$info = model('promotion_pintuan_order')->getInfo($condition, $field, $alias, $join);
|
||||
//查询参与拼单的会员
|
||||
if (!empty($info)) {
|
||||
$member_list = model('promotion_pintuan_order')->getList([["group_id", "=", $info["group_id"]], ['pintuan_status', 'in', '2,3']], "member_img,nickname,member_id");
|
||||
$info["member_list"] = $member_list;
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团订单数量
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getPintuanOrderCount($condition = [], $field = '*', $alias = '', $join = '', $group = '')
|
||||
{
|
||||
$order_info = model('promotion_pintuan_order')->getCount($condition, $field, $alias, $join, $group);
|
||||
return $this->success($order_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团成功
|
||||
* @param $params
|
||||
*/
|
||||
public function pintuanOrderSuccess($params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团订单关闭
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function pintuanOrderClose($condition)
|
||||
{
|
||||
//将未支付的修改为失败
|
||||
model('promotion_pintuan_order')->update(['pintuan_status' => 1], $condition);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 虚拟商品成功后操作
|
||||
* @param $order_id
|
||||
*/
|
||||
public function virtualSuccessAction($order_id)
|
||||
{
|
||||
$order_info = model('order')->getInfo([['order_id', '=', $order_id]]);
|
||||
$order_type = $order_info['order_type'];
|
||||
if ($order_type == 4) {//虚拟订单
|
||||
$virtual_order_model = new VirtualOrder();
|
||||
$virtual_order_model->toSend(['order_id' => $order_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
309
addon/pintuan/model/PintuanOrderCreate.php
Executable file
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\order\OrderCreate;
|
||||
use app\model\order\OrderCreateTool;
|
||||
use extend\exception\OrderException;
|
||||
use app\model\system\Pay;
|
||||
|
||||
/**
|
||||
* 订单创建(拼团)
|
||||
*/
|
||||
class PintuanOrderCreate extends BaseModel
|
||||
{
|
||||
|
||||
use OrderCreateTool;
|
||||
public $group_id = 0;
|
||||
public $pintuan_info = [];
|
||||
public $pintuan_id = 0;
|
||||
public $pintuan_group_info = [];
|
||||
public $extend = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->promotion_type = 'pintuan';
|
||||
$this->promotion_type_name = '拼团';
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//计算
|
||||
$this->confirm();
|
||||
if ($this->error > 0) {
|
||||
return $this->error([ 'error_code' => $this->error ], $this->error_msg);
|
||||
}
|
||||
//订单创建数据
|
||||
$order_insert_data = $this->getOrderInsertData([ 'discount' ], 'invert');
|
||||
$order_insert_data[ 'store_id' ] = $this->store_id;
|
||||
$order_insert_data[ 'create_time' ] = time();
|
||||
$order_insert_data[ 'is_enable_refund' ] = 0;
|
||||
//订单类型以及状态
|
||||
$this->orderType();
|
||||
$order_insert_data[ 'order_type' ] = $this->order_type[ 'order_type_id' ];
|
||||
$order_insert_data[ 'order_type_name' ] = $this->order_type[ 'order_type_name' ];
|
||||
$order_insert_data[ 'order_status_name' ] = $this->order_type[ 'order_status' ][ 'name' ];
|
||||
$order_insert_data[ 'order_status_action' ] = json_encode($this->order_type[ 'order_status' ], JSON_UNESCAPED_UNICODE);
|
||||
$order_insert_data[ 'promotion_status_name' ] = '待参团';
|
||||
$order_insert_data[ 'extend' ] = empty($this->param[ 'extend' ]) ? '' : json_encode($this->param[ 'extend' ]);
|
||||
model('order')->startTrans();
|
||||
//循环生成多个订单
|
||||
try {
|
||||
$this->order_id = model('order')->add($order_insert_data);
|
||||
$order_goods_insert_data = [];
|
||||
//订单项目表
|
||||
foreach ($this->goods_list as &$order_goods_v) {
|
||||
$order_goods_insert_data[] = $this->getOrderGoodsInsertData($order_goods_v);
|
||||
}
|
||||
model('order_goods')->addList($order_goods_insert_data);
|
||||
//同步生成拼团
|
||||
$pintuan_order_model = new PintuanOrder();
|
||||
$result = $pintuan_order_model->addPintuanOrder($this->getOrderObjectData(), $this->group_id, $this->pintuan_id);
|
||||
|
||||
if ($result[ 'code' ] != 0) {
|
||||
model('order')->rollback();
|
||||
return $result;
|
||||
}
|
||||
//扣除余额(统一扣除)
|
||||
$this->useBalance();
|
||||
//批量库存处理(卡密商品支付后在扣出库存)
|
||||
$this->batchDecOrderGoodsStock();
|
||||
|
||||
model('order')->commit();
|
||||
//订单创建后事件
|
||||
$this->orderCreateAfter();
|
||||
//支付单据
|
||||
$pay = new Pay();
|
||||
$pay->addPay($this->site_id, $this->out_trade_no, $this->pay_type, $this->order_name, $this->order_name, $this->pay_money, '', 'OrderPayNotify', '/pages_promotion/pintuan/share?id=' . $result[ 'data' ], $this->order_id, $this->member_id);
|
||||
return $this->success($this->out_trade_no);
|
||||
} catch (\Exception $e) {
|
||||
model('order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算后的进一步计算(不存缓存,每次都是重新计算)
|
||||
* @return array
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$order_key = $this->param[ 'order_key' ];
|
||||
$this->getOrderCache($order_key);
|
||||
//初始化地址
|
||||
$this->initMemberAddress();
|
||||
//初始化门店信息
|
||||
$this->initStore();
|
||||
//配送计算
|
||||
$this->calculateDelivery();
|
||||
//批量校验配送方式
|
||||
$this->batchCheckDeliveryType();
|
||||
//计算发票相关
|
||||
$this->calculateInvoice();
|
||||
//计算余额
|
||||
$this->calculateBalcnce();
|
||||
$this->pay_money = $this->order_money - $this->balance_money;
|
||||
//设置过的商品项信息
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
//要提前赋值,商品计算要用到
|
||||
$this->group_id = $this->param[ 'group_id' ];
|
||||
//初始化会员地址
|
||||
$this->initMemberAddress();
|
||||
//初始化会员账户
|
||||
$this->initMemberAccount();
|
||||
//商品列表信息
|
||||
$this->getOrderGoodsCalculate();
|
||||
//查询拼团信息
|
||||
$pintuan_model = new Pintuan();
|
||||
$this->pintuan_info = $pintuan_model->getPintuanInfo([ [ 'pintuan_id', '=', $this->pintuan_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
|
||||
if (empty($this->pintuan_info)) throw new OrderException('找不到有效的拼团活动!');
|
||||
//判断购买数是否超过限购
|
||||
if ($this->pintuan_info[ 'buy_num' ] < $this->param[ 'num' ] && $this->pintuan_info[ 'buy_num' ] > 0) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '该商品限制购买不能大于' . $this->pintuan_info[ 'buy_num' ] . '件!';
|
||||
}
|
||||
|
||||
//判断是否可参团
|
||||
$pintuan_order = new PintuanOrder();
|
||||
$result = $pintuan_order->isCanJoinGroup($this->group_id, $this->member_id);
|
||||
if ($result[ 'code' ] < 0) throw new OrderException($result[ 'message' ]);
|
||||
|
||||
//查询拼团组信息
|
||||
$pintuan_model = new PintuanGroup();
|
||||
$this->pintuan_group_info = $pintuan_model->getPintuanGroupInfo([ [ 'group_id', '=', $this->group_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
|
||||
$this->shopOrderCalculate();
|
||||
|
||||
//获取发票相关
|
||||
$this->getInovice();
|
||||
$this->order_key = create_no();
|
||||
$this->setOrderCache(get_object_vars($this), $this->order_key);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 待付款订单
|
||||
*/
|
||||
public function orderPayment()
|
||||
{
|
||||
//计算
|
||||
$this->calculate();
|
||||
//查询配送信息
|
||||
$this->getDeliveryData();
|
||||
//订单初始项
|
||||
event('OrderPayment', [ 'order_object' => $this ]);
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品的计算信息
|
||||
*/
|
||||
public function getOrderGoodsCalculate()
|
||||
{
|
||||
$this->getPintuanGoodsInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拼团商品列表信息
|
||||
*/
|
||||
public function getPintuanGoodsInfo()
|
||||
{
|
||||
$id = $this->param[ 'id' ];
|
||||
$num = $this->param[ 'num' ];
|
||||
//组装商品列表
|
||||
$field = 'nppg.id,nppg.sku_id,nppg.pintuan_id,nppg.pintuan_price,nppg.promotion_price,ngs.sku_name, ngs.sku_no,
|
||||
ngs.price, ngs.discount_price, ngs.cost_price, ngs.stock, ngs.weight, ngs.volume, ngs.sku_image,
|
||||
ngs.site_id, ns.site_name, ngs.goods_state, ngs.is_virtual, ngs.support_trade_type,ngs.supplier_id,ngs.form_id,
|
||||
ngs.is_free_shipping, ngs.shipping_template, ngs.goods_class, ngs.goods_class_name,ngs.goods_id,ngs.sku_spec_format,ngs.goods_name,g.goods_image,
|
||||
nppg.pintuan_price_2,nppg.pintuan_price_3';
|
||||
$alias = 'nppg';
|
||||
$join = [
|
||||
[
|
||||
'goods_sku ngs',
|
||||
'nppg.sku_id = ngs.sku_id',
|
||||
'inner'
|
||||
],
|
||||
[
|
||||
'site ns',
|
||||
'ngs.site_id = ns.site_id',
|
||||
'inner'
|
||||
],
|
||||
[ 'goods g', 'ngs.goods_id = g.goods_id', 'inner' ],
|
||||
];
|
||||
$info = model('promotion_pintuan_goods')->getInfo([ [ 'nppg.id', '=', $id ], [ 'nppg.site_id', '=', $this->site_id ] ], $field, $alias, $join);
|
||||
|
||||
if (!$info) throw new OrderException('商品不存在!');
|
||||
|
||||
$pintuan_model = new Pintuan();
|
||||
$this->pintuan_id = $info[ 'pintuan_id' ];
|
||||
|
||||
$pintuan_info = $pintuan_model->getPintuanInfo([ [ 'pintuan_id', '=', $this->pintuan_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
|
||||
|
||||
//判断是否是虚拟订单
|
||||
if ($info[ 'is_virtual' ]) {
|
||||
$this->is_virtual = 1;
|
||||
} else {
|
||||
$this->is_virtual = 0;
|
||||
}
|
||||
$info[ 'num' ] = $num;
|
||||
|
||||
$pintuan_type = $pintuan_info[ 'pintuan_type' ];
|
||||
switch ($pintuan_type) {
|
||||
case 'ordinary'://默认拼团方式
|
||||
//判断是否是开团 团长
|
||||
if ($this->group_id > 0) {
|
||||
$price = $info[ 'pintuan_price' ];//参团价
|
||||
} else {
|
||||
$price = $info[ 'promotion_price' ];//开团价
|
||||
}
|
||||
break;
|
||||
case 'ladder'://阶梯拼团
|
||||
$pintuan_num = $pintuan_info[ 'pintuan_num' ];
|
||||
$pintuan_num_2 = $pintuan_info[ 'pintuan_num_2' ];
|
||||
$pintuan_num_3 = $pintuan_info[ 'pintuan_num_3' ];
|
||||
$this->extend = $this->param[ 'extend' ] ?? [];
|
||||
$price = $info[ 'pintuan_price' ];//一级参团价
|
||||
if (empty($this->extend)) {
|
||||
|
||||
$group_model = new PintuanGroup();
|
||||
$pintuan_group_condition = array (
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'group_id', '=', $this->group_id ]
|
||||
);
|
||||
$group_info = $group_model->getPintuanGroupInfo($pintuan_group_condition)[ 'data' ] ?? [];
|
||||
if (empty($group_info)) {
|
||||
break;
|
||||
}
|
||||
$pintuan_ladder = $group_info[ 'pintuan_num' ];
|
||||
} else {
|
||||
$pintuan_ladder = $this->extend[ 'pintuan_num' ];
|
||||
}
|
||||
|
||||
switch ($pintuan_ladder) {
|
||||
case $pintuan_num:
|
||||
$price = $info[ 'pintuan_price' ];//一级参团价
|
||||
break;
|
||||
case $pintuan_num_2:
|
||||
$price = $info[ 'pintuan_price_2' ];//二级参团价
|
||||
break;
|
||||
case $pintuan_num_3:
|
||||
$price = $info[ 'pintuan_price_3' ];//三级参团价
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$goods_money = $price * $info[ 'num' ];
|
||||
$info[ 'price' ] = $price;
|
||||
$info[ 'goods_money' ] = $goods_money;
|
||||
|
||||
$info[ 'real_goods_money' ] = $goods_money;//真实商品金额
|
||||
$info[ 'coupon_money' ] = 0;//优惠券金额
|
||||
$info[ 'promotion_money' ] = 0;//优惠金额
|
||||
|
||||
$this->site_name = $info[ 'site_name' ];
|
||||
$this->goods_money = $goods_money;
|
||||
$this->goods_list_str = $info[ 'sku_id' ] . ':' . $info[ 'num' ];
|
||||
$this->order_name = string_split('', ',', $info[ 'sku_name' ]);
|
||||
$this->goods_num = $info[ 'num' ];
|
||||
$this->goods_list[] = $info;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单计算
|
||||
*/
|
||||
public function shopOrderCalculate()
|
||||
{
|
||||
//重新计算订单总额
|
||||
$this->getOrderMoney();
|
||||
//理论上是多余的操作
|
||||
if ($this->order_money < 0) {
|
||||
$this->order_money = 0;
|
||||
}
|
||||
//总结计算
|
||||
$this->pay_money = $this->order_money;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
655
addon/pintuan/model/Poster.php
Executable file
@@ -0,0 +1,655 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\model;
|
||||
|
||||
use addon\postertemplate\model\PosterTemplate;
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\upload\Upload;
|
||||
use app\model\web\Config;
|
||||
use extend\Poster as PosterExtend;
|
||||
|
||||
/**
|
||||
* 海报生成类
|
||||
*/
|
||||
class Poster extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 商品海报
|
||||
*/
|
||||
public function goods($app_type, $page, $qrcode_param, $promotion_type, $site_id)
|
||||
{
|
||||
try {
|
||||
$pintuan_id = $qrcode_param[ 'id' ];
|
||||
$goods_info = $this->getGoodsInfo($pintuan_id);
|
||||
if (empty($goods_info)) return $this->error('未获取到商品信息');
|
||||
|
||||
$qrcode_info = $this->getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id);
|
||||
if ($qrcode_info[ 'code' ] < 0) return $qrcode_info;
|
||||
//判断海报是否存在或停用
|
||||
$template_info = $this->getTemplateInfo($goods_info[ 'template_id' ]);
|
||||
$site_model = new Site();
|
||||
$condition = array (
|
||||
[ "site_id", "=", $site_id ]
|
||||
);
|
||||
$site_info = $site_model->getSiteInfo($condition);
|
||||
$member_info = [];
|
||||
if (!empty($qrcode_param[ 'source_member' ])) {
|
||||
$member_info = $this->getMemberInfo($qrcode_param[ 'source_member' ]);
|
||||
}
|
||||
|
||||
$upload_config_model = new Config();
|
||||
$upload_config_result = $upload_config_model->getDefaultImg($site_id);
|
||||
|
||||
$goods_pintuan_price = $goods_info[ 'pintuan_price' ];
|
||||
$goods_img = $goods_info[ 'sku_image' ];
|
||||
$goods_name = $goods_info[ 'sku_name' ];
|
||||
$group_id = $qrcode_param[ 'group_id' ] ?? 0;
|
||||
$group_info = model('promotion_pintuan_group')->getInfo([ [ 'group_id', '=', $group_id ] ]);
|
||||
if (!empty($group_info)) {
|
||||
$pintuan_num = $group_info[ 'pintuan_num' ];
|
||||
// if($pintuan_num > 0){
|
||||
// $pintuan_num_name = $pintuan_num.'人团';
|
||||
$pintuan_order_info = model('promotion_pintuan_order')->getInfo([ [ 'group_id', '=', $group_id ] ]);
|
||||
if (!empty($pintuan_order_info)) {
|
||||
$order_goods_info = model('order_goods')->getInfo([ [ 'order_id', '=', $pintuan_order_info[ 'order_id' ] ] ]);
|
||||
if (!empty($order_goods_info)) {
|
||||
$sku_id = $order_goods_info[ 'sku_id' ];
|
||||
|
||||
$pintuan_id = $qrcode_param[ 'id' ] ?? 0;
|
||||
$pintuan_info = model('promotion_pintuan')->getInfo([ [ 'pintuan_id', '=', $pintuan_id ] ]);
|
||||
if (!empty($pintuan_info)) {
|
||||
$pintuan_type = $pintuan_info[ 'pintuan_type' ];
|
||||
$pintuan_goods_info = model('promotion_pintuan_goods')->getInfo([ [ 'pintuan_id', '=', $pintuan_id ], [ 'sku_id', '=', $sku_id ] ]);
|
||||
if ($pintuan_type == 'ladder') {
|
||||
|
||||
$sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $sku_id ] ], 'sku_image,sku_name');
|
||||
if (!empty($sku_info)) {
|
||||
$goods_img = $sku_info[ 'sku_image' ];
|
||||
$goods_name = $sku_info[ 'sku_name' ];
|
||||
}
|
||||
|
||||
if (!empty($pintuan_goods_info)) {
|
||||
switch ( $pintuan_num ) {
|
||||
case $pintuan_info[ 'pintuan_num' ]:
|
||||
$goods_pintuan_price = $pintuan_goods_info[ 'pintuan_price' ];//一级参团价
|
||||
break;
|
||||
case $pintuan_info[ 'pintuan_num_2' ]:
|
||||
$goods_pintuan_price = $pintuan_goods_info[ 'pintuan_price_2' ];//二级参团价
|
||||
break;
|
||||
case $pintuan_info[ 'pintuan_num_3' ]:
|
||||
$goods_pintuan_price = $pintuan_goods_info[ 'pintuan_price_3' ];//三级参团价
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// $goods_pintuan_price = $pintuan_goods_info[ 'pintuan_price' ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
if (empty($goods_info[ 'template_id' ]) || empty($template_info) || $template_info[ 'template_status' ] == 0) {
|
||||
$poster_width = 720;
|
||||
$poster_height = 1280;
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 背景图
|
||||
'data' => [
|
||||
img('upload/poster/bg/promotion_pintuan.png'),
|
||||
0,
|
||||
0,
|
||||
720,
|
||||
1280,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 商品图
|
||||
'data' => [
|
||||
$goods_info['sku_image'],
|
||||
86,
|
||||
174,
|
||||
548,
|
||||
548,
|
||||
'square',
|
||||
5,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 二维码
|
||||
'data' => [
|
||||
$qrcode_info['data']['path'],
|
||||
273,
|
||||
916,
|
||||
175,
|
||||
175,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'原价 ¥ '. $goods_info['price'] .' 参团价 ¥ ' . $goods_pintuan_price,
|
||||
18,
|
||||
[51, 51, 51],
|
||||
86,
|
||||
828,
|
||||
548,
|
||||
1,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info['sku_name'],
|
||||
25,
|
||||
[34, 34, 34],
|
||||
86,
|
||||
780,
|
||||
548,
|
||||
1,
|
||||
true,
|
||||
1
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
if (!empty($member_info)) {
|
||||
$member_option = [
|
||||
[
|
||||
'action' => 'imageCircularCopy', // 写入用户头像
|
||||
'data' => [
|
||||
!empty($member_info['headimg']) ? $member_info['headimg'] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
|
||||
86,
|
||||
40,
|
||||
101,
|
||||
101
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
$member_info['nickname'],
|
||||
24,
|
||||
[51, 51, 51],
|
||||
210,
|
||||
85,
|
||||
420,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
]
|
||||
]
|
||||
];
|
||||
$option = array_merge($option, $member_option);
|
||||
}
|
||||
} else {
|
||||
$condition = [
|
||||
[ 'template_id', '=', $goods_info[ 'template_id' ] ],
|
||||
[ 'site_id', '=', $site_id ]
|
||||
];
|
||||
$poster_template_model = new PosterTemplate();
|
||||
$poster_data = $poster_template_model->getPosterTemplateInfo($condition);
|
||||
$poster_data[ 'data' ][ 'template_json' ] = json_decode($poster_data[ 'data' ][ 'template_json' ], true);
|
||||
$poster_width = 720;
|
||||
$poster_height = 1280;
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$fontRate = 0.725; // 20px 等于 14.5磅,换算比率 1px = 0.725磅
|
||||
if (!empty($poster_data[ 'data' ][ 'background' ])) {
|
||||
list($width, $height, $type, $attr) = getimagesize(img($poster_data[ 'data' ][ 'background' ]));
|
||||
$back_ground = [
|
||||
'action' => 'imageCopy', // 写入背景图
|
||||
'data' => [
|
||||
img($poster_data[ 'data' ][ 'background' ]),
|
||||
0,
|
||||
0,
|
||||
$poster_width,
|
||||
$poster_height,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$back_ground = [
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [ 255, 255, 255 ]
|
||||
];
|
||||
}
|
||||
|
||||
$option = [
|
||||
$back_ground,
|
||||
[
|
||||
'action' => 'imageText', // 写入店铺名称
|
||||
'data' => [
|
||||
$site_info[ 'data' ][ 'site_name' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'store_name_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'store_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 店铺logo
|
||||
'data' => [
|
||||
!empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : getUrl() . '/app/shop/view/public/img/shop_logo.png',
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_height' ] * 2,
|
||||
'square',
|
||||
1,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品图
|
||||
'data' => [
|
||||
img($goods_img, 'mid'),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_name,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_name_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_width' ] * 2,
|
||||
1,//文本行数 $poster_data['data']['template_json']['goods_name_height']*2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品二维码
|
||||
'data' => [
|
||||
$qrcode_info[ 'data' ][ 'path' ],
|
||||
$poster_data[ 'data' ][ 'qrcode_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_height' ] * 2,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'¥' . $goods_pintuan_price,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_price_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
if ($goods_info['price'] ==0 ){
|
||||
$line = '一一一';
|
||||
}else{
|
||||
$line = '一一一一';
|
||||
}
|
||||
$market_price = [
|
||||
[
|
||||
'action' => 'imageText', // 写入商品划线价格
|
||||
'data' => [
|
||||
'¥' . $goods_info[ 'price' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ] ?? 0
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入线
|
||||
'data' => [
|
||||
$line,
|
||||
$poster_data['data']['template_json']['goods_market_price_font_size']*$fontRate*2,
|
||||
hex2rgb($poster_data['data']['template_json']['goods_market_price_color']),
|
||||
$poster_data['data']['template_json']['goods_market_price_left']*2-5,
|
||||
($poster_data['data']['template_json']['goods_market_price_top']+$poster_data['data']['template_json']['goods_market_price_font_size'])*2,
|
||||
$poster_data['data']['template_json']['goods_market_price_width']*2,
|
||||
$poster_data['data']['template_json']['goods_market_price_height']*2,
|
||||
true,
|
||||
$poster_data['data']['template_json']['goods_market_price_is_show']
|
||||
]
|
||||
],
|
||||
];
|
||||
$option = array_merge($option, $market_price);
|
||||
|
||||
if (!empty($member_info)) {
|
||||
$member_option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入用户头像
|
||||
'data' => [
|
||||
!empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
$member_info[ 'nickname' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_left' ] * 2,
|
||||
( $poster_data[ 'data' ][ 'template_json' ][ 'nickname_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] ) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_height' ] * 2,
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
$ground = [
|
||||
[
|
||||
'action' => 'setBackground',
|
||||
'data' => [ 255, 255, 255 ]
|
||||
]
|
||||
];
|
||||
$option = array_merge($ground, $option, $member_option);
|
||||
}
|
||||
|
||||
}
|
||||
$option_res = $poster->create($option);
|
||||
if (is_array($option_res)) return $option_res;
|
||||
|
||||
$res = $option_res->jpeg('upload/poster/goods', 'goods_' . $promotion_type . '_' . $goods_info[ 'pintuan_id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . time() . '_' . $app_type);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$upload = new Upload($site_id);
|
||||
$cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
|
||||
if ($cloud_res[ 'code' ] >= 0) {
|
||||
return $this->success([ "path" => $cloud_res[ 'data' ] ]);
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param unknown $member_id
|
||||
*/
|
||||
private function getMemberInfo($member_id)
|
||||
{
|
||||
$info = model('member')->getInfo([ 'member_id' => $member_id ], 'nickname,headimg');
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品信息
|
||||
* @param unknown
|
||||
*/
|
||||
private function getGoodsInfo($id, $group_id = 0)
|
||||
{
|
||||
$alias = 'nppg';
|
||||
$join = [
|
||||
[ 'goods_sku ngs', 'nppg.sku_id = ngs.sku_id', 'inner' ],
|
||||
[ 'promotion_pintuan pp', 'pp.pintuan_id = nppg.pintuan_id', 'left' ]
|
||||
];
|
||||
$field = 'ngs.sku_name,ngs.introduction,ngs.sku_image,ngs.sku_id,nppg.pintuan_price,nppg.pintuan_id,ngs.template_id,ngs.price,nppg.pintuan_price_2,nppg.pintuan_price_3,pp.pintuan_num,pp.pintuan_num_2,pp.pintuan_num_3';
|
||||
$info = model('promotion_pintuan_goods')->getInfo([ 'nppg.pintuan_id' => $id ], $field, $alias, $join);
|
||||
// 按参团人数获取拼团价
|
||||
if (!empty($group_id)) {
|
||||
$group_info = model('promotion_pintuan_group')->getInfo([ [ 'group_id', '=', $group_id ] ], 'pintuan_num');
|
||||
if (!empty($group_info)) {
|
||||
if ($info[ 'pintuan_num_2' ] == $group_info[ 'pintuan_num' ]) $info[ 'pintuan_price' ] = $info[ 'pintuan_price_2' ];
|
||||
else if ($info[ 'pintuan_num_3' ] == $group_info[ 'pintuan_num' ]) $info[ 'pintuan_price' ] = $info[ 'pintuan_price_3' ];
|
||||
$info[ 'pintuan_num' ] = $group_info[ 'pintuan_num' ];
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品二维码
|
||||
* @param unknown $app_type 请求类型
|
||||
* @param unknown $page uniapp页面路径
|
||||
* @param unknown $qrcode_param 二维码携带参数
|
||||
* @param string $promotion_type 活动类型 null为无活动
|
||||
*/
|
||||
private function getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id)
|
||||
{
|
||||
$res = event('Qrcode', [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => $app_type,
|
||||
'type' => 'create',
|
||||
'data' => $qrcode_param,
|
||||
'page' => $page,
|
||||
'qrcode_path' => 'upload/qrcode/goods',
|
||||
'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . $site_id,
|
||||
], true);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报信息
|
||||
* @param unknown $template_id
|
||||
*/
|
||||
private function getTemplateInfo($template_id)
|
||||
{
|
||||
$info = model('poster_template')->getInfo([ 'template_id' => $template_id ], 'template_id,template_status');
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享图片
|
||||
* @param $page
|
||||
* @param $qrcode_param
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function shareImg($page, $qrcode_param, $site_id)
|
||||
{
|
||||
try {
|
||||
$goods_info = $this->getGoodsInfo($qrcode_param[ 'id' ], $qrcode_param[ 'group_id' ] ?? 0);
|
||||
if (empty($goods_info)) return $this->error('未获取到商品信息');
|
||||
|
||||
$file_path = 'upload/share_img/pintuan_' . $goods_info[ 'pintuan_id' ] . '/sku_' . $goods_info[ 'sku_id' ] . '_' . $goods_info[ 'pintuan_num' ] . '.jpg';
|
||||
if (file_exists($file_path)) return $this->success([ 'path' => $file_path ]);
|
||||
|
||||
$poster_width = 600;
|
||||
$poster_height = 480;
|
||||
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$option = [
|
||||
[
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [ 255, 255, 255 ]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 商品图
|
||||
'data' => [
|
||||
img($goods_info[ 'sku_image' ], 'mid'),
|
||||
30,
|
||||
145,
|
||||
200,
|
||||
200,
|
||||
'square',
|
||||
50,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info[ 'sku_name' ],
|
||||
22,
|
||||
[ 51, 51, 51 ],
|
||||
250,
|
||||
190,
|
||||
330,
|
||||
2,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'拼团价:¥',
|
||||
15,
|
||||
[ 255, 0, 0 ],
|
||||
250,
|
||||
300,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
$goods_info[ 'pintuan_price' ],
|
||||
30,
|
||||
[ 255, 0, 0 ],
|
||||
345,
|
||||
300,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1,
|
||||
PUBLIC_PATH . 'static/font/custom.ttf'
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品原价
|
||||
'data' => [
|
||||
'原 价:¥',
|
||||
15,
|
||||
[ 153, 153, 153 ],
|
||||
250,
|
||||
340,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品原价
|
||||
'data' => [
|
||||
$goods_info[ 'price' ],
|
||||
16,
|
||||
[ 153, 153, 153 ],
|
||||
345,
|
||||
338,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1,
|
||||
PUBLIC_PATH . 'static/font/custom.ttf',
|
||||
]
|
||||
],
|
||||
// 划线(两条线)
|
||||
[
|
||||
'action' => 'imageline',
|
||||
'data' => [
|
||||
325,
|
||||
330,
|
||||
325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
|
||||
330,
|
||||
[ 153, 153, 153 ],
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageline',
|
||||
'data' => [
|
||||
325,
|
||||
331,
|
||||
325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
|
||||
331,
|
||||
[ 153, 153, 153 ],
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 背景图
|
||||
'data' => [
|
||||
img('upload/share_img/bg/pintuan_1.png'),
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
480,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
$option_res = $poster->create($option);
|
||||
if (is_array($option_res)) {
|
||||
return $option_res;
|
||||
}
|
||||
|
||||
$res = $option_res->jpeg('upload/share_img/pintuan_' . $goods_info[ 'pintuan_id' ],
|
||||
'sku_' . $goods_info[ 'sku_id' ] . '_' . $goods_info[ 'pintuan_num' ]);
|
||||
return $res;
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分享图片
|
||||
* @param int $pintuan_id
|
||||
*/
|
||||
public function clearShareImg(int $pintuan_id)
|
||||
{
|
||||
$dir = 'upload/share_img/pintuan_' . $pintuan_id;
|
||||
@deleteDir($dir);
|
||||
}
|
||||
}
|
||||
134
addon/pintuan/model/share/WchatShare.php
Executable file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\model\share;
|
||||
|
||||
use addon\pintuan\model\Pintuan;
|
||||
use app\model\share\WchatShareBase as BaseModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WchatShare extends BaseModel
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '拼团分享',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_PINTUAN_PROMOTE',
|
||||
'path' => [ '/pages_promotion/pintuan/detail' ],
|
||||
'method_prefix' => 'goodsDetail',
|
||||
],
|
||||
[
|
||||
'title' => '拼团列表',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_PINTUAN_LIST_PROMOTE',
|
||||
'path' => [ '/pages_promotion/pintuan/list' ],
|
||||
'method_prefix' => 'goodsList',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 6;
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsListShareData($param)
|
||||
{
|
||||
//跳转路径
|
||||
$link = $this->getShareLink($param);
|
||||
$config_data = $this->goodsListShareConfig($param)[ 'value' ];
|
||||
|
||||
$data = [
|
||||
'link' => $link,
|
||||
'desc' => $config_data[ 'desc' ],
|
||||
'imgUrl' => $config_data[ 'imgUrl' ],
|
||||
'title' => $config_data[ 'title' ]
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团列表分享配置
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function goodsListShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => "拼团列表",
|
||||
'desc' => "拼实惠\n团惊喜",
|
||||
'imgUrl' => ''
|
||||
];
|
||||
}
|
||||
if (empty($data[ 'value' ][ 'imgUrl' ])) {
|
||||
$data[ 'value' ][ 'imgUrl' ] = img('addon/pintuan/icon.png');
|
||||
}
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsDetailShareData($param)
|
||||
{
|
||||
$url = $param[ 'url' ];
|
||||
|
||||
$parse_res = parse_url($url);
|
||||
parse_str($parse_res[ 'query' ] ?? '', $query);
|
||||
|
||||
if (isset($query[ 'pintuan_id' ]) || isset($query[ 'id' ])) {
|
||||
$pintuan_id = $query['pintuan_id'] ?? $query['id'];
|
||||
$goods = new Pintuan();
|
||||
$sku_info = $goods->getPintuanGoodsDetail([ [ 'ppg.pintuan_id', '=', $pintuan_id ] ])[ 'data' ];
|
||||
if (!empty($sku_info)) {
|
||||
$config_model = new \app\model\share\WchatShare();
|
||||
$config_data = $config_model->goodsDetailShareConfig($param);
|
||||
|
||||
$title = str_replace('{goods_name}', $sku_info[ 'sku_name' ], $config_data[ 'value' ][ 'title' ]);
|
||||
$desc = str_replace('{price}', $sku_info[ 'pintuan_price' ], $config_data[ 'value' ][ 'desc' ]);
|
||||
$link = $this->getShareLink($param);
|
||||
$image_url = $sku_info[ 'sku_image' ];
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
'link' => $link,
|
||||
'imgUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
addon/pintuan/model/share/WeappShare.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\model\share;
|
||||
|
||||
use app\model\share\WeappShareBase;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WeappShare extends WeappShareBase
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '拼团列表',
|
||||
'config_key' => 'WEAPP_SHARE_CONFIG_PINTUAN_LIST',
|
||||
'path' => [ '/pages_promotion/pintuan/list' ],
|
||||
'method_prefix' => 'pintuanList',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 7;
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function pintuanListShareData($param)
|
||||
{
|
||||
//获取和替换配置数据
|
||||
$config_data = $this->pintuanListShareConfig($param);
|
||||
$title = $config_data[ 'value' ][ 'title' ];
|
||||
$image_url = $config_data[ 'value' ][ 'imageUrl' ] ? img($config_data[ 'value' ][ 'imageUrl' ]) : '';
|
||||
$path = $this->getSharePath($param);
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'path' => $path,
|
||||
'imageUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'onShareAppMessage' => true,
|
||||
'onShareTimeline' => true,
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团列表
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function pintuanListShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'app_module', '=', 'shop' ],
|
||||
[ 'config_key', '=', $config[ 'config_key' ] ],
|
||||
])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => '跟我一起来拼团吧!',
|
||||
'imageUrl' => '',
|
||||
];
|
||||
}
|
||||
$variable = [];
|
||||
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
'variable' => $variable,
|
||||
];
|
||||
}
|
||||
}
|
||||
343
addon/pintuan/shop/controller/Pintuan.php
Executable file
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pintuan\shop\controller;
|
||||
|
||||
use addon\pintuan\model\PintuanGroup;
|
||||
use addon\pintuan\model\PintuanOrder;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\pintuan\model\Pintuan as PintuanModel;
|
||||
use addon\pintuan\model\PintuanGroup as PintuanGroupModel;
|
||||
|
||||
/**
|
||||
* 拼团控制器
|
||||
*/
|
||||
class Pintuan extends BaseShop
|
||||
{
|
||||
|
||||
/*
|
||||
* 拼团活动列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$model = new PintuanModel();
|
||||
$condition = [
|
||||
[ 'p.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
$status = input('status', '');//拼团状态
|
||||
if ($status) {
|
||||
if ($status == 6) {
|
||||
$condition[] = [ 'p.status', '=', 0 ];
|
||||
} else {
|
||||
$condition[] = [ 'p.status', '=', $status ];
|
||||
}
|
||||
}
|
||||
$goods_name = input('goods_name', '');
|
||||
if ($goods_name) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $goods_name . '%' ];
|
||||
}
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'p.end_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'p.start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$start_timestamp = date_to_time($start_time);
|
||||
$end_timestamp = date_to_time($end_time);
|
||||
$sql = "p.start_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or p.end_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or (p.start_time <= {$start_timestamp} and p.end_time >= {$end_timestamp})";
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
|
||||
}
|
||||
|
||||
//排序
|
||||
$order = input('order', 'create_time');
|
||||
$sort = input('sort', 'desc');
|
||||
if ($order == 'create_time') {
|
||||
$order_by = 'p.' . $order . ' ' . $sort;
|
||||
} else {
|
||||
$order_by = 'p.' . $order . ' ' . $sort . ',p.create_time desc';
|
||||
}
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$list = $model->getPintuanPageList($condition, $page, $page_size, $order_by);
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
return $this->fetch("pintuan/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pintuan_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'site_name' => '',
|
||||
'pintuan_name' => input('pintuan_name', ''),//活动名称
|
||||
'is_virtual_goods' => input('is_virtual_goods', ''),//是否是虚拟商品
|
||||
'pintuan_num' => input('pintuan_num', ''),//参团人数
|
||||
'pintuan_time' => input('pintuan_time', ''),//拼团有效期
|
||||
'remark' => input('remark', ''),// 活动规则
|
||||
'is_recommend' => input('is_recommend', ''),//是否推荐
|
||||
'start_time' => date_to_time(input('start_time', '')),//开始时间
|
||||
'end_time' => date_to_time(input('end_time', '')),//结束时间
|
||||
'buy_num' => input('buy_num', ''),//拼团限制购买
|
||||
'is_single_buy' => input('is_single_buy', ''),//是否单独购买
|
||||
'is_virtual_buy' => input('is_virtual_buy', ''),//是否虚拟成团
|
||||
'is_promotion' => input('is_promotion', ''),//是否团长优惠
|
||||
'pintuan_type' => input('pintuan_type', ''),
|
||||
'pintuan_num_2' => input('pintuan_num_2', 0),
|
||||
'pintuan_num_3' => input('pintuan_num_3', 0),
|
||||
];
|
||||
$goods = [
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
];
|
||||
$sku_list = input('sku_list', '');
|
||||
$pintuan_model = new PintuanModel();
|
||||
return $pintuan_model->addPintuan($pintuan_data, $goods, $sku_list);
|
||||
} else {
|
||||
$pintuan_name = '拼团 ' . date('Y-m-d');
|
||||
$this->assign('pintuan_name', $pintuan_name);
|
||||
return $this->fetch("pintuan/add");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$pintuan_model = new PintuanModel();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$pintuan_data = [
|
||||
'pintuan_id' => input('pintuan_id', ''),
|
||||
'site_id' => $this->site_id,
|
||||
'pintuan_name' => input('pintuan_name', ''),//活动名称
|
||||
'goods_id' => input('goods_id', ''),//商品ID
|
||||
'is_virtual_goods' => input('is_virtual_goods', ''),//是否是虚拟商品
|
||||
'pintuan_num' => input('pintuan_num', ''),//参团人数
|
||||
'pintuan_time' => input('pintuan_time', ''),//拼团有效期
|
||||
'remark' => input('remark', ''),//活动规则
|
||||
'is_recommend' => input('is_recommend', ''),//是否推荐
|
||||
'start_time' => date_to_time(input('start_time', '')),//开始时间
|
||||
'end_time' => date_to_time(input('end_time', '')),//结束时间
|
||||
'buy_num' => input('buy_num', ''),//拼团限制购买
|
||||
'is_single_buy' => input('is_single_buy', ''),//是否单独购买
|
||||
'is_virtual_buy' => input('is_virtual_buy', ''),//是否虚拟成团
|
||||
'is_promotion' => input('is_promotion', ''),//是否团长优惠
|
||||
'pintuan_num_2' => input('pintuan_num_2', 0),
|
||||
'pintuan_num_3' => input('pintuan_num_3', 0),
|
||||
];
|
||||
|
||||
$sku_list = input('sku_list', '');
|
||||
$goods = [
|
||||
'goods_id' => input('goods_id', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
];
|
||||
return $pintuan_model->editPintuan($pintuan_data, $goods, $sku_list);
|
||||
} else {
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
//获取拼团信息
|
||||
$pintuan_info = $pintuan_model->getPintuanDetail($pintuan_id, $this->site_id);
|
||||
if (empty($pintuan_info[ 'data' ])) $this->error('未获取到活动数据', href_url('pintuan://shop/pintuan/lists'));
|
||||
$this->assign('pintuan_info', $pintuan_info);
|
||||
return $this->fetch("pintuan/edit");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 拼团详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$pintuan_model = new PintuanModel();
|
||||
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
//获取拼团信息
|
||||
$pintuan_info = $pintuan_model->getPintuanJoinGoodsList($pintuan_id, $this->site_id)[ 'data' ] ?? [];
|
||||
if (empty($pintuan_info)) $this->error('未获取到活动数据', href_url('pintuan://shop/pintuan/lists'));
|
||||
$this->assign('info', $pintuan_info);
|
||||
return $this->fetch("pintuan/detail");
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除拼团活动
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
$pintuan_model = new PintuanModel();
|
||||
return $pintuan_model->deletePintuan($pintuan_id, $this->site_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 拼团活动失效
|
||||
*/
|
||||
public function invalid()
|
||||
{
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
$pintuan_model = new PintuanModel();
|
||||
return $pintuan_model->invalidPintuanTo($pintuan_id, $this->site_id);
|
||||
}
|
||||
|
||||
/********************************** 开团团队 ******************************************************/
|
||||
|
||||
/*
|
||||
* 开团团队列表
|
||||
*/
|
||||
public function group()
|
||||
{
|
||||
$model = new PintuanGroupModel();
|
||||
|
||||
$condition[] = [ 'pg.site_id', '=', $this->site_id ];
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
if ($pintuan_id) {
|
||||
$condition[] = [ 'pg.pintuan_id', '=', $pintuan_id ];
|
||||
}
|
||||
//获取续签信息
|
||||
if (request()->isJson()) {
|
||||
$goods_name = input('goods_name', '');
|
||||
$nickname = input('nickname', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$status = input('status', '');//拼团状态
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
if ($goods_name) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $goods_name . '%' ];
|
||||
}
|
||||
|
||||
if ($nickname) {
|
||||
$condition[] = [ 'm.nickname', 'like', '%' . $nickname . '%' ];
|
||||
}
|
||||
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'pg.create_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'pg.create_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$condition[] = [ 'pg.create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
if ($status == 6) {
|
||||
$condition[] = [ 'pg.status', '=', 0 ];
|
||||
} else {
|
||||
$condition[] = [ 'pg.status', '=', $status ];
|
||||
}
|
||||
}
|
||||
|
||||
$list = $model->getPintuanGroupPageList($condition, $page, $page_size, 'pg.group_id desc');
|
||||
return $list;
|
||||
} else {
|
||||
$this->assign('pintuan_id', $pintuan_id);
|
||||
|
||||
return $this->fetch("pintuan/group");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 拼团组成员订单列表
|
||||
*/
|
||||
public function groupOrder()
|
||||
{
|
||||
$model = new PintuanOrder();
|
||||
|
||||
$condition = [];
|
||||
$condition[] = [ 'ppo.pintuan_status', 'in', '2,3' ];
|
||||
$group_id = input('group_id', '');
|
||||
if ($group_id) {
|
||||
$condition[] = [ 'ppo.group_id', '=', $group_id ];
|
||||
}
|
||||
//获取续签信息
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getPintuanOrderPageList($condition, $page, $page_size, 'ppo.id desc');
|
||||
return $list;
|
||||
|
||||
} else {
|
||||
$this->assign('group_id', $group_id);
|
||||
//获取团长信息
|
||||
$pintuan_group_model = new PintuanGroupModel();
|
||||
$info = $pintuan_group_model->getPintuanGroupDetail([ [ 'pg.group_id', '=', $group_id ], [ 'pg.site_id', '=', $this->site_id ] ]);
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到成团数据', href_url('pintuan://shop/pintuan/group'));
|
||||
$this->assign('info', $info[ 'data' ]);
|
||||
return $this->fetch("pintuan/group_order");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @return array
|
||||
*/
|
||||
public function getSkuList()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$pintuan_model = new PintuanModel();
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
$pintuan_info = $pintuan_model->getPintuanGoodsList($pintuan_id, $this->site_id);
|
||||
return $pintuan_info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼团推广
|
||||
*/
|
||||
public function pintuanUrl()
|
||||
{
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
$app_type = input('app_type', '');
|
||||
$pintuan_model = new PintuanModel();
|
||||
$res = $pintuan_model->urlQrcode('/pages_promotion/pintuan/detail', [ 'id' => $pintuan_id ], 'pintuan', $app_type, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
public function deleteAll(){
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
$pintuan_model = new PintuanModel();
|
||||
foreach ($pintuan_id as $k => $v){
|
||||
$res = $pintuan_model->deletePintuan($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量关闭
|
||||
*/
|
||||
public function invalidAll(){
|
||||
$pintuan_id = input('pintuan_id', '');
|
||||
$pintuan_model = new PintuanModel();
|
||||
foreach ($pintuan_id as $k => $v){
|
||||
$res = $pintuan_model->invalidPintuanTo($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
755
addon/pintuan/shop/view/pintuan/add.html
Executable file
@@ -0,0 +1,755 @@
|
||||
<style>
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.goods_list .layui-table-body{max-height: 480px !important;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;width: 0;white-space: break-spaces;}
|
||||
.form-wrap {position: relative;}
|
||||
.examples {cursor: pointer; margin-left: 5px;}
|
||||
.layui-carousel>[carousel-item]>* {background: #fff !important;}
|
||||
.layui-carousel {position: absolute; top: 10px; left: 1330px; width: 300px !important; height: 610px !important; background: #fff;}
|
||||
.goods_num {padding-left: 20px;}
|
||||
.ladder .layui-form-label + .layui-input-block {display: flex}
|
||||
.ladder .layui-form-label + .layui-input-block .layui-form-mid.right {margin-left: 10px}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block" style="display: inline-block; margin-left: 0px;">
|
||||
<input type="text" name="pintuan_name" value="{$pintuan_name}" lay-verify="required" autocomplete="off" class="layui-input len-long" maxlength="40">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>活动名称将显示在活动列表中,方便商家管理</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="start_time" name="start_time" lay-verify="required" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="end_time" name="end_time" lay-verify="required|time" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">拼团类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="pintuan_type" value="ordinary" title="普通拼团" checked lay-filter="pintuan_type">
|
||||
<input type="radio" name="pintuan_type" value="ladder" title="阶梯拼团" lay-filter="pintuan_type">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pintuan-type ordinary">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>参团人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="pintuan_num" value="2" lay-verify="required|sum" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>最少两人成团</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pintuan-type ladder" style="display: none">
|
||||
<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"><span class="required">*</span>参团人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第一级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_1" value="" lay-verify="ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第二级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_2" value="" lay-verify="ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn add-ladder">添加拼团阶梯</button>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>最少两人成团,最多支持三级阶梯</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>拼团有效期:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline len-short">
|
||||
<select class="pintuan-day"></select>
|
||||
</div>
|
||||
<div class="layui-form-mid">日</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<select class="pintuan-hour"></select>
|
||||
</div>
|
||||
<div class="layui-form-mid">时</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<select class="pintuan-minute"></select>
|
||||
</div>
|
||||
<div class="layui-form-mid">分</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>提交订单后,在该时间范围内拼团成功才可购买</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制购买:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="buy_num" value="1" lay-verify="num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>本次活动中一次最多可购买的商品数量,默认为1</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pintuan-type ordinary layui-form-item">
|
||||
<label class="layui-form-label">团长优惠:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_promotion" title="团长享受优惠价" lay-skin="primary" lay-filter="is_promotion">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>开启团长(开团人)优惠后,团长将享受更优惠价格,有助于提高开团率和成团率</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label">活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></table>
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button>
|
||||
<span class="goods_num">已选商品(<span id="goods_num" style="color: red">0</span>)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否单独购买:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_single_buy" value="1" title="是">
|
||||
<input type="radio" name="is_single_buy" value="0" title="否" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="word-aux">
|
||||
<p>说明:设置单独购买,是可以选择不走拼团,直接提交订单购买商品 <a onclick="showDemo()" class="examples text-color">查看示例</a></p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否虚拟成团:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_virtual_buy" value="1" title="是">
|
||||
<input type="radio" name="is_virtual_buy" value="0" title="否" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="word-aux">
|
||||
<p>说明:虚拟成团则代表在拼团时间结束后,如果还未拼单成功,那么系统将会默认拼团成功。</p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">是否推荐:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_recommend" value="1" title="是">
|
||||
<input type="radio" name="is_recommend" value="0" title="否" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="is_virtual_goods" value="0">
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">活动规则:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="300"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPintuanList()">返回</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="pintuan-price">拼团价格</button>
|
||||
</script>
|
||||
<script type="text/html" id="toolbarOperationOne">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="pintuan-price">拼团价格</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="pintuan-discounts-price">团长优惠价</button>
|
||||
</script>
|
||||
<script>
|
||||
var goodsId = {}, selectedGoodsId = [], sku_list = [],is_promotion=0,table;
|
||||
layui.use(['form', 'laydate','carousel'], function() {
|
||||
var form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false,
|
||||
currentDate = new Date(),
|
||||
minDate = "";
|
||||
|
||||
var carousel = layui.carousel;
|
||||
currentDate.setDate(currentDate.getDate() + 30);
|
||||
carousel.render({
|
||||
elem: '#carousel',
|
||||
width: '100%',
|
||||
arrow: 'always'
|
||||
});
|
||||
form.render();
|
||||
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
for (var i = 0; i <= 30; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
if (i == 1) {
|
||||
var html = '<option value="' + i + '" selected>0' + i + '</option>';
|
||||
}
|
||||
$(".pintuan-day").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 23; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
$(".pintuan-hour").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 59; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
$(".pintuan-minute").append(html);
|
||||
}
|
||||
|
||||
form.render('select');
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(currentDate)
|
||||
});
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender() {
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class = "layui-input" autocomplete="off" readonly><i class=" iconrili iconfont calendar"></i> ');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (value < 1 || value % 1 != 0) {
|
||||
return '请输入大于0的正整数!';
|
||||
}
|
||||
},
|
||||
sum: function(value) {
|
||||
if ($('[name="pintuan_type"]:checked').val() == 'ordinary') {
|
||||
if (value < 2 || value % 1 != 0) {
|
||||
return '参团人数不能小于2,且必须是整数!';
|
||||
}
|
||||
}
|
||||
},
|
||||
ladderNum: function(value, item){
|
||||
if ($('[name="pintuan_type"]:checked').val() == 'ladder') {
|
||||
if (value < 2 || value % 1 != 0) {
|
||||
return '参团人数不能小于2,且必须是整数!';
|
||||
}
|
||||
var prevVal = $(item).parents('.pintuan-ladder').prev('.pintuan-ladder').find('input').val();
|
||||
if (prevVal != undefined && parseInt(prevVal) >= parseInt(value)) {
|
||||
return '参团人数不能小于等于上一个阶梯的人数';
|
||||
}
|
||||
}
|
||||
},
|
||||
pintuan_price: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".goods-price").text();
|
||||
if (Number(value) > Number(price)) {
|
||||
return '拼团价格不能大于商品价格';
|
||||
}
|
||||
if (value.trim() == "") {
|
||||
return '拼团价格不能为空';
|
||||
}
|
||||
if (Number(value) <= 0) {
|
||||
return '拼团价格必须大于0';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '拼团价格最多保留两位小数';
|
||||
}
|
||||
},
|
||||
promotion_price: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".goods-price").text();
|
||||
if (Number(value) > Number(price)) {
|
||||
return '团长优惠价不能大于商品价格';
|
||||
}
|
||||
if (value.trim() == "") {
|
||||
return '团长优惠价不能为空';
|
||||
}
|
||||
if (Number(value) <= 0) {
|
||||
return '团长优惠价必须大于0';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '团长优惠价最多保留两位小数';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听团长优惠是否被选中
|
||||
*/
|
||||
form.on('checkbox(is_promotion)', function(data){
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
form.on('radio(pintuan_type)', function(data){
|
||||
$('.pintuan-type').hide();
|
||||
$('.pintuan-type.' + data.value).show();
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
$('.add-ladder').click(function () {
|
||||
if ($('.pintuan-ladder').length >= 3) {
|
||||
layer.msg('最多添加三个阶梯');
|
||||
return;
|
||||
}
|
||||
var h = `<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第三级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_3" value="" lay-verify="required|ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
<a href="javascript:;" class="text-color delete">删除</a>
|
||||
</div>
|
||||
</div>`;
|
||||
$(this).parents('.layui-form-item').before(h);
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
$('body').off('click', '.pintuan-ladder .delete').on('click', '.pintuan-ladder .delete', function () {
|
||||
$(this).parents('.layui-form-item').remove();
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
|
||||
if (!Object.keys(goodsId).length) {
|
||||
layer.msg("请选择活动商品!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
data.field.goods_ids = selectedGoodsId.split(',');
|
||||
|
||||
var skuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
Object.values(item.sku_id).forEach(function (skuItem,skuIndex) {
|
||||
skuId.push(skuItem.sku);
|
||||
});
|
||||
});
|
||||
data.field.sku_ids = skuId;
|
||||
|
||||
if (data.field.pintuan_type == 'ladder') {
|
||||
data.field.pintuan_num = data.field.pintuan_num_1;
|
||||
}
|
||||
|
||||
var skuLisArr = [];
|
||||
sku_list.forEach(function(item,index) {
|
||||
var sku_detail = {};
|
||||
sku_detail.sku_id = item.sku_id;
|
||||
sku_detail.goods_id = item.goods_id;
|
||||
sku_detail.pintuan_price = item.pintuan_price || 0;
|
||||
sku_detail.pintuan_price_2 = item.pintuan_price_2 || 0;
|
||||
sku_detail.pintuan_price_3 = item.pintuan_price_3 || 0;
|
||||
sku_detail.promotion_price = item.promotion_price || 0;
|
||||
skuLisArr.push(sku_detail);
|
||||
});
|
||||
data.field.sku_list = skuLisArr;
|
||||
|
||||
var day = $(".pintuan-day option:selected").text(),
|
||||
hour = $(".pintuan-hour option:selected").text(),
|
||||
minute = $(".pintuan-minute option:selected").text();
|
||||
|
||||
var pintuan_time = Number(day) * 24 * 60 + Number(hour) * 60 + Number(minute);
|
||||
data.field.pintuan_time = pintuan_time;
|
||||
|
||||
var time = new Date(data.field.end_time).getTime() - new Date(data.field.start_time).getTime();
|
||||
if (time == 0) {
|
||||
layer.msg("拼团有效期不能为0!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
if (time < (pintuan_time * 60 * 1000)) {
|
||||
layer.msg("拼团有效期不能大于活动时长!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.is_promotion = data.field.is_promotion == undefined ? 0 : 1;
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("pintuan://shop/pintuan/add"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
var cols = [[
|
||||
{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},
|
||||
{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '30%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += ` <div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span class="goods-price">' + data.price +'</span ></p>';
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation ',
|
||||
width: '7% ',
|
||||
align: 'right',
|
||||
unresize: 'false '
|
||||
}]
|
||||
];
|
||||
if ($('[name="pintuan_type"]:checked').val() == 'ordinary') {
|
||||
let col = [
|
||||
{
|
||||
title: '拼团价 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price',
|
||||
width: $('[name="is_promotion"]').is(':checked') ? '25%' : '45%'
|
||||
}
|
||||
];
|
||||
if ($('[name="is_promotion"]').is(':checked')) {
|
||||
col.push({
|
||||
title: '团长价(元)',
|
||||
unresize: 'false',
|
||||
align: 'center',
|
||||
templet: '#promotion_price',
|
||||
width: '20%'
|
||||
})
|
||||
}
|
||||
cols[0].splice(3, 0, ...col);
|
||||
} else if ($('[name="pintuan_type"]:checked').val() == 'ladder') {
|
||||
let col = [
|
||||
{
|
||||
title: '阶梯一 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price',
|
||||
width: $('.pintuan-ladder').length == 3 ? '15%' : '25%'
|
||||
},
|
||||
{
|
||||
title: '阶梯二 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price_2',
|
||||
width: $('.pintuan-ladder').length == 3 ? '15%' : '20%'
|
||||
}
|
||||
];
|
||||
if ($('.pintuan-ladder').length == 3) {
|
||||
col.push({
|
||||
title: '阶梯三 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price_3',
|
||||
width: '15%'
|
||||
})
|
||||
}
|
||||
cols[0].splice(3, 0, ...col);
|
||||
}
|
||||
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page:false,
|
||||
limit:Number.MAX_VALUE,
|
||||
cols: cols,
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*/
|
||||
table.toolbar(function(obj) {
|
||||
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "pintuan-price":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "pintuan-discounts-price":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '拼团价格',
|
||||
value: 'pintuan_price'
|
||||
},{
|
||||
name: '团长优惠价',
|
||||
value: 'promotion_price'
|
||||
}];
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_edit_input" lay-verify="required" autocomplete="off" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='bargain_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
*/
|
||||
function addGoods(){
|
||||
goodsSelect(function (data) {
|
||||
|
||||
let newGoodsId = {};
|
||||
let new_sku_list = [];
|
||||
|
||||
for (var key in data) {
|
||||
|
||||
newGoodsId['goods_'+ data[key].goods_id] = {};
|
||||
newGoodsId['goods_'+ data[key].goods_id].sku_id = {};
|
||||
newGoodsId['goods_'+ data[key].goods_id].spu_id = data[key].goods_id;
|
||||
|
||||
for (var sku in data[key].sku_list) {
|
||||
var item = data[key].sku_list[sku];
|
||||
|
||||
newGoodsId['goods_'+ data[key].goods_id].sku_id['sku_'+item.sku_id]={};
|
||||
newGoodsId['goods_'+ data[key].goods_id].sku_id['sku_'+item.sku_id].sku = item.sku_id;
|
||||
sku_list.forEach((old_item)=>{
|
||||
if(item.sku_id == old_item.sku_id){
|
||||
item.pintuan_price = old_item.pintuan_price;
|
||||
item.pintuan_price_2 = old_item.pintuan_price_2;
|
||||
item.pintuan_price_3 = old_item.pintuan_price_3;
|
||||
item.promotion_price = old_item.promotion_price;
|
||||
}
|
||||
})
|
||||
new_sku_list.push(item);
|
||||
}
|
||||
}
|
||||
goodsId = newGoodsId;
|
||||
sku_list = new_sku_list;
|
||||
renderTable(sku_list);
|
||||
|
||||
$("input[name='sku_ids']").val(JSON.stringify(goodsId));
|
||||
|
||||
var spuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
spuId.push(item.spu_id);
|
||||
});
|
||||
selectedGoodsId = spuId.toString();
|
||||
$("#goods_num").html(sku_list.length)
|
||||
|
||||
}, selectedGoodsId);
|
||||
}
|
||||
|
||||
function delRow(obj,id) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == parseInt(id)){
|
||||
sku_list.splice(i,1);
|
||||
}
|
||||
}
|
||||
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
delete item.sku_id['sku_'+id];
|
||||
if (!Object.keys(item.sku_id).length){
|
||||
delete goodsId['goods_'+item.spu_id];
|
||||
}
|
||||
});
|
||||
|
||||
var spuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
spuId.push(item.spu_id);
|
||||
});
|
||||
selectedGoodsId = spuId.toString();
|
||||
$(obj).parents("tr").remove();
|
||||
$("#goods_num").html(sku_list.length)
|
||||
}
|
||||
|
||||
function bargainPintuanPrice(index,event, key) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index)
|
||||
sku_list[i][key] = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
|
||||
function backPintuanList() {
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/lists");
|
||||
}
|
||||
|
||||
function showDemo(){
|
||||
layer.open({
|
||||
title: '查看示例',
|
||||
type: 1,
|
||||
area: ['600px', '660px'],
|
||||
content: '<img style="margin:20px 45px;" src="__STATIC__/img/single_buy.png" >',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="pintuan_price">
|
||||
<input type="number" class="layui-input len-short pintuan-price" value="{{d.pintuan_price ? d.pintuan_price : '' }}" lay-verify="pintuan_price" min="0.00" oninput="bargainPintuanPrice({{ d.sku_id }},event, 'pintuan_price')" onporpertychange="bargainPintuanPrice({{ d.sku_id }},event, 'pintuan_price')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="pintuan_price_2">
|
||||
<input type="number" class="layui-input len-short pintuan-price" value="{{d.pintuan_price_2 ? d.pintuan_price_2 : '' }}" lay-verify="pintuan_price" min="0.00" oninput="bargainPintuanPrice({{ d.sku_id }},event, 'pintuan_price_2')" onporpertychange="bargainPintuanPrice({{ d.sku_id }},event, 'pintuan_price_2')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="pintuan_price_3">
|
||||
<input type="number" class="layui-input len-short pintuan-price" value="{{d.pintuan_price_3 ? d.pintuan_price_3 : '' }}" lay-verify="pintuan_price" min="0.00" oninput="bargainPintuanPrice({{ d.sku_id }},event, 'pintuan_price_3')" onporpertychange="bargainPintuanPrice({{ d.sku_id }},event, 'pintuan_price_3')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="promotion_price">
|
||||
<input type="number" class="layui-input len-short promotion-price" value="{{d.promotion_price ? d.promotion_price : '' }}" lay-verify="promotion_price" min="0.00" oninput="bargainPintuanPrice({{ d.sku_id }},event, 'promotion_price')" onporpertychange="bargainPromotionPrice({{ d.sku_id }},event, 'promotion_price')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delRow(this,{{d.sku_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
168
addon/pintuan/shop/view/pintuan/detail.html
Executable file
@@ -0,0 +1,168 @@
|
||||
<link rel="stylesheet" href="STATIC_CSS/promotion_detail.css">
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item">
|
||||
<label>活动名称:</label>
|
||||
<span>{$info.pintuan_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>活动状态:</label>
|
||||
<span>{if condition="$info.status == 0"}未开始{/if}{if condition="$info.status == 1"}进行中{/if}{if condition="$info.status == 2"}已结束{/if}{if condition="$info.status == 3"}已失效{/if}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>拼团类型:</label>
|
||||
<span>{$info.pintuan_type == 'ordinary' ? '普通拼团' : '阶梯拼团'}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>拼团人数:</label>
|
||||
<span>{$info.pintuan_num}人团</span>
|
||||
{if $info.pintuan_type == 'ladder'}<span> {$info.pintuan_num_2}人团</span>{/if}
|
||||
{if $info.pintuan_type == 'ladder' && $info.pintuan_num_3 > 0}<span> {$info.pintuan_num_3}人团</span>{/if}
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.end_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>单人限制购买数量:</label>
|
||||
<span>{$info.buy_num}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否是单独购买:</label>
|
||||
<span>{$info.is_single_buy == 0 ? '否' : '是'}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否是虚拟成团:</label>
|
||||
<span>{$info.is_virtual_buy == 0 ? '否' : '是'}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否有团长优惠:</label>
|
||||
<span>{$info.is_promotion == 0 ? '否' : '是'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">数据统计</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="promotion-stat-view todo-list">
|
||||
<div class="promotion-stat-item" >
|
||||
<div class="promotion-stat-item-title">开团数</div>
|
||||
<div class="promotion-stat-item-value">{$info.group_num}</div>
|
||||
</div>
|
||||
<div class="promotion-stat-item" >
|
||||
<div class="promotion-stat-item-title">成团数</div>
|
||||
<div class="promotion-stat-item-value">{$info.success_group_num}</div>
|
||||
</div>
|
||||
|
||||
<div class="promotion-stat-item" >
|
||||
<div class="promotion-stat-item-title">订单数</div>
|
||||
<div class="promotion-stat-item-value">{$info.order_num}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">活动商品</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class='promotion-view-list'>
|
||||
<table id="promotion_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type='text/html' id="promotion_list_item_box_html">
|
||||
<div class="promotion-list-item-title">
|
||||
<div class="promotion-list-item-title-icon">
|
||||
<img src="{{ ns.img(d.sku_image) }}" alt="">
|
||||
</div>
|
||||
<p class="promotion-list-item-title-name multi-line-hiding">{{ d.sku_name }}</p>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var list = {:json_encode($info.sku_list, JSON_UNESCAPED_UNICODE)};
|
||||
layui.use('table', function() {
|
||||
new Table({
|
||||
elem: '#promotion_list',
|
||||
cols: [
|
||||
[{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '26%',
|
||||
unresize: 'false',
|
||||
templet: "#promotion_list_item_box_html"
|
||||
}, {
|
||||
title: '商品价格(元)',
|
||||
unresize: 'false',
|
||||
align: 'left',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}
|
||||
{if $info.pintuan_type == 'ordinary'}
|
||||
, {
|
||||
title: '拼团价格(元)',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.pintuan_price;
|
||||
}
|
||||
},
|
||||
{if condition="$info.is_promotion == 1"}
|
||||
{
|
||||
title: '团长优惠价(元)',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return '¥' + data.promotion_price;
|
||||
}
|
||||
}
|
||||
{/if}
|
||||
{/if}
|
||||
{if $info.pintuan_type == 'ladder'}
|
||||
,{
|
||||
title: '{$info.pintuan_num}人团(元)',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.pintuan_price;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '{$info.pintuan_num_2}人团(元)',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return '¥' + data.pintuan_price_2;
|
||||
}
|
||||
}
|
||||
{if condition="$info.pintuan_num_3 > 0"}
|
||||
,{
|
||||
title: '{$info.pintuan_num_3}人团(元)',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return '¥' + data.pintuan_price_3;
|
||||
}
|
||||
}
|
||||
{/if}
|
||||
{/if}
|
||||
]
|
||||
],
|
||||
data: list
|
||||
});
|
||||
});
|
||||
</script>
|
||||
758
addon/pintuan/shop/view/pintuan/edit.html
Executable file
@@ -0,0 +1,758 @@
|
||||
<style>
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.goods_list .layui-table-body{max-height: 480px !important;}
|
||||
.forbidden{cursor:not-allowed;background-color: #eee;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.form-wrap {position: relative;}
|
||||
.examples {cursor: pointer; margin-left: 5px; line-height: 36px;}
|
||||
.layui-carousel>[carousel-item]>* {background: #fff !important;}
|
||||
.layui-carousel {position: absolute; top: 10px; left: 1330px; width: 300px !important; height: 610px !important; background: #fff;}
|
||||
.ladder .layui-form-label + .layui-input-block {display: flex}
|
||||
.ladder .layui-form-label + .layui-input-block .layui-form-mid.right {margin-left: 10px}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="pintuan_name" value="{$pintuan_info.data.pintuan_name}" lay-verify="required" autocomplete="off" class="layui-input len-long" maxlength="40">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>活动名称将显示在活动列表中,方便商家管理</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="start_time" name="start_time" value="{:date('Y-m-d H:i:s', $pintuan_info.data.start_time)}" lay-verify="required" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="end_time" name="end_time" value="{:date('Y-m-d H:i:s', $pintuan_info.data.end_time)}" lay-verify="required|time" class="layui-input" autocomplete="off" readonly>
|
||||
<input type="hidden" value="{$pintuan_info.data.end_time}" id="old_end_time">
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">拼团类型:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="pintuan_type" value="ordinary" disabled title="普通拼团" {if $pintuan_info.data.pintuan_type eq 'ordinary'}checked{/if} lay-filter="pintuan_type">
|
||||
<input type="radio" name="pintuan_type" value="ladder" disabled title="阶梯拼团" {if $pintuan_info.data.pintuan_type eq 'ladder'}checked{/if} lay-filter="pintuan_type">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pintuan-type ordinary" {if $pintuan_info.data.pintuan_type neq 'ordinary'}style="display: none"{/if}>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>参团人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="pintuan_num" value="{$pintuan_info.data.pintuan_num}" lay-verify="required|sum" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>最少两人成团</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pintuan-type ladder" {if $pintuan_info.data.pintuan_type neq 'ladder'}style="display: none"{/if}>
|
||||
<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"><span class="required">*</span>参团人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第一级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_1" disabled value="{$pintuan_info.data.pintuan_num}" lay-verify="required|ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第二级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_2" disabled value="{$pintuan_info.data.pintuan_num_2}" lay-verify="required|ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
</div>
|
||||
</div>
|
||||
{if $pintuan_info.data.pintuan_num_3 > 0}
|
||||
<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第二级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_3" disabled value="{$pintuan_info.data.pintuan_num_3}" lay-verify="required|ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn add-ladder">添加拼团阶梯</button>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>最少两人成团,最多支持三级阶梯</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>拼团有效期:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline len-short">
|
||||
<select class="pintuan-day"></select>
|
||||
</div>
|
||||
<div class="layui-form-mid">日</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<select class="pintuan-hour"></select>
|
||||
</div>
|
||||
<div class="layui-form-mid">时</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<select class="pintuan-minute"></select>
|
||||
</div>
|
||||
<div class="layui-form-mid">分</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>提交订单后,在该时间范围内拼团成功才可购买</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制购买:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="buy_num" value="{$pintuan_info.data.buy_num}" lay-verify="num" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>本次活动中一次最多可购买的商品数量</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item pintuan-type ordinary" {if $pintuan_info.data.pintuan_type neq 'ordinary'}style="display: none"{/if}>
|
||||
<label class="layui-form-label">团长优惠:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_promotion" {$pintuan_info.data.is_promotion == 1 ? 'checked' : ''} value="{$pintuan_info.data.is_promotion}" title="团长享受优惠价" lay-skin="primary" lay-filter="is_promotion">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>开启团长(开团人)优惠后,团长将享受更优惠价格,有助于提高开团率和成团率</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label">活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否单独购买:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_single_buy" value="1" title="是" {$pintuan_info.data.is_single_buy == 1 ? 'checked' : ''}>
|
||||
<input type="radio" name="is_single_buy" value="0" title="否" {$pintuan_info.data.is_single_buy == 0 ? 'checked' : ''}>
|
||||
</div>
|
||||
<a onclick="showDemo()" class="examples text-color">查看示例</a>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否虚拟成团:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_virtual_buy" value="1" title="是" {$pintuan_info.data.is_virtual_buy == 1 ? 'checked' : ''}>
|
||||
<input type="radio" name="is_virtual_buy" value="0" title="否" {$pintuan_info.data.is_virtual_buy == 0 ? 'checked' : ''}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">是否推荐:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="radio" name="is_recommend" value="1" title="是" {$pintuan_info.data.is_recommend == 1 ? 'checked' : ''}>
|
||||
<input type="radio" name="is_recommend" value="0" title="否" {$pintuan_info.data.is_recommend == 0 ? 'checked' : ''}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">活动规则:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="300">{$pintuan_info.data.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPintuanList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="pintuan_id" value="{$pintuan_info.data.pintuan_id}" />
|
||||
<input type="hidden" class="pintuan-time" value="{$pintuan_info.data.pintuan_time}" />
|
||||
<input type="hidden" name="goods_id" class="goods-id" value="{$pintuan_info.data.goods_id}" />
|
||||
<input type="hidden" name="is_virtual_goods" class="is-virtual-goods" value="{$pintuan_info.data.is_virtual_goods}" />
|
||||
<input type="hidden" class="start-time-pri" value="{$pintuan_info.data.start_time}" />
|
||||
<input type="hidden" class="end-time-pri" value="{$pintuan_info.data.end_time}" />
|
||||
|
||||
<!-- <div class="layui-carousel" id="carousel">
|
||||
<div carousel-item>
|
||||
<img src="__STATIC__/img/pintuan.png" >
|
||||
<img src="__STATIC__/img/pintuan_detail.png" >
|
||||
</div>
|
||||
</div>-->
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="pintuan-price">拼团价格</button>
|
||||
</script>
|
||||
<script type="text/html" id="toolbarOperationOne">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="pintuan-price">拼团价格</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="pintuan-discounts-price">团长优惠价</button>
|
||||
</script>
|
||||
<script>
|
||||
var start_time_pri = ns.time_to_date($(".start-time-pri").val()),
|
||||
end_time_pri = ns.time_to_date($(".end-time-pri").val());
|
||||
var pintuan_time = $(".pintuan-time").val(), //总分钟数
|
||||
day_time = pintuan_time / (24 * 60), //天数
|
||||
houe_time = (pintuan_time % (24 * 60)) / 60, //小时
|
||||
second_time = (pintuan_time % (24 * 60)) % 60; //分钟
|
||||
|
||||
var sku_list = [];
|
||||
sku_list = {:json_encode($pintuan_info.data.sku_list, JSON_UNESCAPED_UNICODE)};
|
||||
|
||||
var pintuan_info = {:json_encode($pintuan_info.data,JSON_UNESCAPED_UNICODE)},is_promotion = 0;
|
||||
sku_list.forEach(function (item,index) {
|
||||
item.is_delete = item.pintuan_price ? 1 : 2;
|
||||
});
|
||||
|
||||
var is_virtual = [];
|
||||
layui.use(['form', 'laydate','carousel'], function() {
|
||||
var form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false,
|
||||
minDate = "";
|
||||
var carousel = layui.carousel;
|
||||
|
||||
carousel.render({
|
||||
elem: '#carousel'
|
||||
,width: '100%'
|
||||
,arrow: 'always'
|
||||
});
|
||||
|
||||
form.render();
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
for (var i = 0; i <= 30; i++) {
|
||||
if (i < 10) {
|
||||
if (i == day_time) {
|
||||
var html = '<option value="' + i + '" selected>0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
}
|
||||
} else {
|
||||
if (i == day_time) {
|
||||
var html = '<option value="' + i + '" selected>' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
}
|
||||
$(".pintuan-day").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 23; i++) {
|
||||
if (i < 10) {
|
||||
if (i == houe_time) {
|
||||
var html = '<option value="' + i + '" selected>0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
}
|
||||
} else {
|
||||
if (i == houe_time) {
|
||||
var html = '<option value="' + i + '" selected>' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
}
|
||||
$(".pintuan-hour").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 59; i++) {
|
||||
if (i < 10) {
|
||||
if (i == second_time) {
|
||||
var html = '<option value="' + i + '" selected>0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
}
|
||||
} else {
|
||||
if (i == second_time) {
|
||||
var html = '<option value="' + i + '" selected>' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
}
|
||||
$(".pintuan-minute").append(html);
|
||||
}
|
||||
form.render('select');
|
||||
|
||||
var now_time = ((new Date()).getTime())/1000;
|
||||
var start_time = ((new Date($("#start_time").val())).getTime())/1000;
|
||||
var old_end_time = ((new Date($("#end_time").val())).getTime())/1000;
|
||||
if(now_time <= start_time){
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: start_time_pri,
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
}
|
||||
if(now_time <= old_end_time){
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: end_time_pri
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender() {
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class ="layui-input" autocomplete="off" readonly><i class=" iconrili iconfont calendar"></i> ');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
time: function(value) {
|
||||
var now_time = ((new Date()).getTime())/1000;
|
||||
var start_time = ((new Date($("#start_time").val())).getTime())/1000;
|
||||
var end_time = ((new Date(value)).getTime())/1000;
|
||||
var old_end_time = $("#old_end_time").val();
|
||||
|
||||
if(old_end_time > end_time){
|
||||
return '结束时间不能小于之前设置的结束时间!'
|
||||
}
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (value < 1 || value % 1 != 0) {
|
||||
return '请输入大于0的正整数!';
|
||||
}
|
||||
},
|
||||
sum: function(value) {
|
||||
if ($('[name="pintuan_type"]:checked').val() == 'ordinary') {
|
||||
if (value < 2 || value % 1 != 0) {
|
||||
return '参团人数不能小于2,且必须是整数!';
|
||||
}
|
||||
}
|
||||
},
|
||||
ladderNum: function(value, item){
|
||||
if ($('[name="pintuan_type"]:checked').val() == 'ladder') {
|
||||
if (value < 2 || value % 1 != 0) {
|
||||
return '参团人数不能小于2,且必须是整数!';
|
||||
}
|
||||
var prevVal = $(item).parents('.pintuan-ladder').prev('.pintuan-ladder').find('input').val();
|
||||
if (prevVal != undefined && parseInt(prevVal) >= parseInt(value)) {
|
||||
return '参团人数不能小于等于上一个阶梯的人数';
|
||||
}
|
||||
}
|
||||
},
|
||||
pintuan_price: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".goods-price").text();
|
||||
if (Number(value) > Number(price)) {
|
||||
return '拼团价格不能大于商品价格';
|
||||
}
|
||||
if (value.trim() == "") {
|
||||
return '拼团价格不能为空';
|
||||
}
|
||||
if (Number(value) <= 0) {
|
||||
return '拼团价格必须大于0';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '拼团价格最多保留两位小数';
|
||||
}
|
||||
},
|
||||
promotion_price: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".goods-price").text();
|
||||
if (Number(value) > Number(price)) {
|
||||
return '团长优惠价不能大于商品价格';
|
||||
}
|
||||
if (value.trim() == "") {
|
||||
return '团长优惠价不能为空';
|
||||
}
|
||||
if (Number(value) <= 0) {
|
||||
return '团长优惠价必须大于0';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '团长优惠价最多保留两位小数';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听团长优惠是否被选中
|
||||
*/
|
||||
form.on('checkbox(is_promotion)', function(data){
|
||||
if (data.elem.checked) {
|
||||
$(".team-leader").removeClass("layui-hide");
|
||||
$(".goods-empty").attr("colspan", 4);
|
||||
$("input[name='is_promotion']").val(1);
|
||||
is_promotion = 1;
|
||||
} else {
|
||||
$(".team-leader").addClass("layui-hide");
|
||||
$(".goods-empty").attr("colspan", 3);
|
||||
$("input[name='is_promotion']").val(0);
|
||||
is_promotion = 0;
|
||||
}
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
$('.add-ladder').click(function () {
|
||||
if ($('.pintuan-ladder').length >= 3) {
|
||||
layer.msg('最多添加三个阶梯');
|
||||
return;
|
||||
}
|
||||
var h = `<div class="layui-form-item pintuan-ladder">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-form-mid">第三级阶梯人数</div>
|
||||
<input type="number" name="pintuan_num_3" value="" lay-verify="required|ladderNum" autocomplete="off" class="layui-input len-short">
|
||||
<div class="layui-form-mid right">人</div>
|
||||
<a href="javascript:;" class="text-color delete">删除</a>
|
||||
</div>
|
||||
</div>`;
|
||||
$(this).parents('.layui-form-item').before(h);
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
$('body').off('click', '.pintuan-ladder .delete').on('click', '.pintuan-ladder .delete', function () {
|
||||
$(this).parents('.layui-form-item').remove();
|
||||
renderTable(sku_list);
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
data.field.sku_ids = [];
|
||||
data.field.goods_id = sku_list[0].goods_id;
|
||||
sku_list.forEach(function (item,index) {
|
||||
if (item.is_delete == 2) return false;
|
||||
data.field.sku_ids.push(item.sku_id);
|
||||
});
|
||||
if (data.field.sku_ids.length == 0) {
|
||||
layer.msg("请选择参与活动商品!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
var skuLisArr = [];
|
||||
sku_list.forEach(function(item,index) {
|
||||
var sku_detail = {};
|
||||
sku_detail.sku_id = item.sku_id;
|
||||
sku_detail.goods_id = item.goods_id;
|
||||
sku_detail.pintuan_price = item.pintuan_price || 0;
|
||||
sku_detail.pintuan_price_2 = item.pintuan_price_2 || 0;
|
||||
sku_detail.pintuan_price_3 = item.pintuan_price_3 || 0;
|
||||
sku_detail.promotion_price = item.promotion_price || 0;
|
||||
sku_detail.is_delete = item.is_delete || 1;
|
||||
skuLisArr.push(sku_detail);
|
||||
});
|
||||
data.field.sku_list = skuLisArr;
|
||||
|
||||
var day = $(".pintuan-day option:selected").text(),
|
||||
hour = $(".pintuan-hour option:selected").text(),
|
||||
minute = $(".pintuan-minute option:selected").text();
|
||||
|
||||
var pintuan_time = Number(day) * 24 * 60 + Number(hour) * 60 + Number(minute);
|
||||
data.field.pintuan_time = pintuan_time;
|
||||
|
||||
var time = new Date(data.field.end_time).getTime() - new Date(data.field.start_time).getTime();
|
||||
if (time < (pintuan_time * 60 * 1000)) {
|
||||
layer.msg("拼团有效期不能大于活动时长!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.is_promotion = data.field.is_promotion == undefined ? 0 : 1;
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("pintuan://shop/pintuan/edit"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续操作'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/lists");
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
var cols = [[
|
||||
{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},
|
||||
{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '30%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += ` <div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span class="goods-price">' + data.price +'</span ></p>';
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation ',
|
||||
width: '7% ',
|
||||
align: 'right',
|
||||
unresize: 'false '
|
||||
}]
|
||||
];
|
||||
if ($('[name="pintuan_type"]:checked').val() == 'ordinary') {
|
||||
let col = [
|
||||
{
|
||||
title: '拼团价 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price',
|
||||
width: $('[name="is_promotion"]').is(':checked') ? '25%' : '45%'
|
||||
}
|
||||
];
|
||||
if ($('[name="is_promotion"]').is(':checked')) {
|
||||
col.push({
|
||||
title: '团长价(元)',
|
||||
unresize: 'false',
|
||||
align: 'center',
|
||||
templet: '#promotion_price',
|
||||
width: '20%'
|
||||
})
|
||||
}
|
||||
cols[0].splice(3, 0, ...col);
|
||||
} else if ($('[name="pintuan_type"]:checked').val() == 'ladder') {
|
||||
let col = [
|
||||
{
|
||||
title: '阶梯一 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price',
|
||||
width: $('.pintuan-ladder').length == 3 ? '15%' : '25%'
|
||||
},
|
||||
{
|
||||
title: '阶梯二 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price_2',
|
||||
width: $('.pintuan-ladder').length == 3 ? '15%' : '20%'
|
||||
}
|
||||
];
|
||||
if ($('.pintuan-ladder').length == 3) {
|
||||
col.push({
|
||||
title: '阶梯三 (元)',
|
||||
unresize: 'false ',
|
||||
align: 'center',
|
||||
templet: '#pintuan_price_3',
|
||||
width: '15%'
|
||||
})
|
||||
}
|
||||
cols[0].splice(3, 0, ...col);
|
||||
}
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page:false,
|
||||
limit:Number.MAX_VALUE,
|
||||
cols: cols,
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
/**
|
||||
* 批量操作
|
||||
*/
|
||||
table.toolbar(function(obj) {
|
||||
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "pintuan-price":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "pintuan-discounts-price":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '拼团价格',
|
||||
value: 'pintuan_price'
|
||||
},{
|
||||
name: '团长优惠价',
|
||||
value: 'promotion_price'
|
||||
}];
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_edit_input" lay-verify="required" autocomplete="off" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='bargain_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bargainPintuanPrice(index,event,field) {
|
||||
sku_list[index][field] = event.srcElement.value;
|
||||
}
|
||||
|
||||
$("body").off("click",".no-participation").on("click",".no-participation",function(){
|
||||
$(this).text("参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",true);
|
||||
$(item).attr("disabled",true);
|
||||
$(item).addClass("forbidden");
|
||||
$(item).attr("lay-verify","");
|
||||
});
|
||||
|
||||
$(this).addClass("participation").removeClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_delete = 2;
|
||||
});
|
||||
|
||||
$("body").off("click",".participation").on("click",".participation",function(){
|
||||
$(this).text("不参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",false);
|
||||
$(item).attr("disabled",false);
|
||||
$(item).removeClass("forbidden");
|
||||
if($(item).hasClass(".pintuan-price")){
|
||||
$(item).attr("lay-verify","pintuan_price");
|
||||
}else{
|
||||
$(item).attr("lay-verify","promotion_price");
|
||||
}
|
||||
});
|
||||
|
||||
$(this).removeClass("participation").addClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_delete = 1;
|
||||
});
|
||||
|
||||
function backPintuanList() {
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/lists");
|
||||
}
|
||||
function showDemo(){
|
||||
layer.open({
|
||||
title: '查看示例',
|
||||
type: 1,
|
||||
area: ['600px', '660px'],
|
||||
content: '<img style="margin:20px 45px;" src="__STATIC__/img/single_buy.png" >',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="pintuan_price">
|
||||
<input type="number" class="layui-input len-short pintuan-price" value="{{d.pintuan_price ? d.pintuan_price : '' }}" lay-verify="pintuan_price" min="0.00" oninput="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'pintuan_price')" onporpertychange="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'pintuan_price')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="pintuan_price_2">
|
||||
<input type="number" class="layui-input len-short pintuan-price" value="{{d.pintuan_price_2 ? d.pintuan_price_2 : '' }}" lay-verify="pintuan_price" min="0.00" oninput="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'pintuan_price_2')" onporpertychange="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'pintuan_price_2')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="pintuan_price_3">
|
||||
<input type="number" class="layui-input len-short pintuan-price" value="{{d.pintuan_price_3 ? d.pintuan_price_3 : '' }}" lay-verify="pintuan_price" min="0.00" oninput="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'pintuan_price_3')" onporpertychange="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'pintuan_price_3')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="promotion_price">
|
||||
<input type="number" class="layui-input len-short promotion-price" value="{{d.promotion_price ? d.promotion_price : '' }}" lay-verify="promotion_price" min="0.00" oninput="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'promotion_price')" onporpertychange="bargainPintuanPrice({{ d.LAY_TABLE_INDEX }},event, 'promotion_price')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
{{# if(!d.pintuan_price){ }}
|
||||
<a class="layui-btn participation">参与</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn no-participation">不参与</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
242
addon/pintuan/shop/view/pintuan/group.html
Executable file
@@ -0,0 +1,242 @@
|
||||
<style>
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
.layui-layout-admin .screen{margin-bottom: 15px;}
|
||||
</style>
|
||||
|
||||
{if condition="$pintuan_id"}
|
||||
<input type="hidden" class="pintuan-id" value="{$pintuan_id}" />
|
||||
{else/}
|
||||
<input type="hidden" class="pintuan-id" value="" />
|
||||
{/if}
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-form layui-colla-content layui-form layui-show" lay-filter="order_list">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="goods_name">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">团长昵称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="nickname">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">拼团状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="status" lay-filter="status">
|
||||
<option value="">全部</option>
|
||||
<option value="3">拼团成功</option>
|
||||
<option value="2">组团中</option>
|
||||
<option value="1">拼团失败</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">开团时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(7, this);return false;">近7天</button>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(30, this);return false;">近30天</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="team_list" lay-filter="team_list"></table>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.goods_image){ }}
|
||||
<img layer-src src="{{ns.img(d.goods_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.goods_name}}">{{d.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 会员 -->
|
||||
<script type="text/html" id="member_info">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.headimg){ }}
|
||||
<img layer-src src="{{ns.img(d.headimg)}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.nickname}}">{{d.nickname}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 1){ }}
|
||||
拼团失败
|
||||
{{# }else if(d.status == 2){ }}
|
||||
组团中
|
||||
{{# }else if(d.status == 3){ }}
|
||||
拼团成功
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="check">详情</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'element', 'laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
laydate = layui.laydate;
|
||||
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#team_list',
|
||||
url: ns.url("pintuan://shop/pintuan/group"),
|
||||
where: {
|
||||
"pintuan_id": $(".pintuan-id").val()
|
||||
},
|
||||
cols: [
|
||||
[ {
|
||||
title: '团长信息',
|
||||
unresize: 'false',
|
||||
width: '17%',
|
||||
templet: '#member_info'
|
||||
},{
|
||||
title: '拼团商品',
|
||||
unresize: 'false',
|
||||
width: '22%',
|
||||
templet: '#goods'
|
||||
}, {
|
||||
title: '开团时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet:function(data){
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}, {
|
||||
title: '成团人数/当前人数',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return data.pintuan_num + ' / ' + data.pintuan_count;
|
||||
}
|
||||
}, {
|
||||
title: '结束时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.end_time);
|
||||
}
|
||||
}, {
|
||||
title: '拼团状态',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: '#status'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'check': //查看
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/grouporder?group_id="+ data.group_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//监听筛选事件
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function datePick(date_num,event_obj){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
$(event_obj).addClass('selected');
|
||||
|
||||
Date.prototype.Format = function (fmt,date_num) { //author: meizz
|
||||
this.setDate(this.getDate()-date_num);
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"H+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
||||
var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
|
||||
var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
|
||||
$("input[name=start_time]").val(before_time,0);
|
||||
$("input[name=end_time]").val(now_time,date_num-1);
|
||||
}
|
||||
</script>
|
||||
193
addon/pintuan/shop/view/pintuan/group_order.html
Executable file
@@ -0,0 +1,193 @@
|
||||
<style>
|
||||
.layui-table[lay-skin=line] {margin-top: 15px; border-width: 0;}
|
||||
.title-pic {
|
||||
flex-shrink: 0;
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
line-height: 50px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layui-form tips-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">团长信息:</label>
|
||||
<div class="table-title layui-input-inline">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{:img($info['headimg'])}"/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{$info['nickname']}">{$info['nickname']}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品信息:</label>
|
||||
<div class="table-title layui-input-inline">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{:img($info['sku_image'])}"/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{$info['sku_name']}">{$info['sku_name']}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">拼团价格:</label>
|
||||
<div class="layui-input-inline">¥{$info.pintuan_price}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">开团时间:</label>
|
||||
<div class="layui-input-inline">{:time_to_date($info.create_time)}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">成团人数/当前人数:</label>
|
||||
<div class="layui-input-inline">{$info.pintuan_num} / {$info.pintuan_count}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否虚拟成团:</label>
|
||||
<div class="layui-input-inline">{if $info.is_virtual_buy == 1} 是 {else/} 否 {/if}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">结束时间:</label>
|
||||
<div class="layui-input-inline">{:time_to_date($info.end_time)}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">拼团状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
{if $info.status == 1}
|
||||
拼团失败
|
||||
{elseif $info.status == 2}
|
||||
组团中
|
||||
{else/}
|
||||
拼团成功
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<table id="order_list" lay-filter="order_list"></table>
|
||||
|
||||
<!-- 参与人 -->
|
||||
<script type="text/html" id="member_info">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.member_img){ }}
|
||||
<img layer-src src="{{ns.img(d.member_img)}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{{d.nickname}}">{{d.nickname}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.sku_image){ }}
|
||||
<img layer-src src="{{ns.img(d.sku_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color">{{d.sku_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 信息标签 -->
|
||||
<script type="text/html" id="information">
|
||||
<p class="layui-elip">支付方式:{{d.pay_type_name}}</p>
|
||||
<p class="layui-elip">来源:{{d.order_from_name}}</p>
|
||||
</script>
|
||||
|
||||
<!-- 余额标签 -->
|
||||
<script type="text/html" id="money">
|
||||
<p class="layui-elip">¥{{d.order_money}}</p>
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<a class="layui-btn" lay-event="check">详情</a>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var group_id = "{$group_id}";
|
||||
layui.use(['form'], function() {
|
||||
var table, form = layui.form;
|
||||
form.render();
|
||||
|
||||
table = new Table({
|
||||
elem: '#order_list',
|
||||
url: ns.url("pintuan://shop/pintuan/groupOrder"),
|
||||
where: {
|
||||
"group_id": group_id
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
title: '参与人',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet:'#member_info'
|
||||
},{
|
||||
field: 'order_no',
|
||||
title: '订单号',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet:'#goods'
|
||||
}, {
|
||||
title: '下单时间',
|
||||
unresize: 'false',
|
||||
width: '17%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.pay_time);
|
||||
}
|
||||
}, {
|
||||
title: '下单金额',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: '#money'
|
||||
}, {
|
||||
field: 'order_status_name',
|
||||
title: '订单状态',
|
||||
unresize: 'false',
|
||||
width: '8%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
align: 'right',
|
||||
unresize: 'false',
|
||||
}]
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
|
||||
switch (obj.event) {
|
||||
case 'check': //查看
|
||||
var newWin = window.open('about:blank');
|
||||
newWin.location.href = ns.href("shop/order/detail", {"order_id": data.order_id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
504
addon/pintuan/shop/view/pintuan/lists.html
Executable file
@@ -0,0 +1,504 @@
|
||||
<style>
|
||||
.screen{margin-bottom: 15px;}
|
||||
.contraction span {cursor: pointer;display: inline-block;width: 17px;height: 17px;text-align: center;line-height: 14px;user-select: none;}
|
||||
.sku-list {overflow: hidden;padding: 0 45px;}
|
||||
.sku-list li .img-wrap {vertical-align: middle;margin-right: 8px;width: 20%;height: 80px;text-align: center;line-height: 70px;}
|
||||
.sku-list li .img-wrap img {max-width: 100%;max-height: 100%;}
|
||||
.sku-list li .info-wrap span.sku-name {-webkit-line-clamp: 2;margin-bottom: 5px;}
|
||||
.sku-list li .info-wrap span {display: -webkit-box;margin-bottom: 5px;overflow: hidden;text-overflow: ellipsis;white-space: normal;word-break: break-all;-webkit-box-orient: vertical;-webkit-line-clamp: 1;}
|
||||
.sku-list li {float: left;display: flex;padding: 10px;margin-right: 10px;margin-bottom: 10px;border: 1px solid #EFEFEF;width: 294px;height: 110px;align-items: center;}
|
||||
.body-content {padding-top: 15px!important;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
</style>
|
||||
|
||||
<!-- 按钮容器 -->
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加拼团商品</button>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="goods_name" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">活动时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button type="button" class="layui-btn" lay-filter="search" lay-submit>筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="pintuan_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" lay-id="">全部</li>
|
||||
<li lay-id="6">未开始</li>
|
||||
<li lay-id="1">进行中</li>
|
||||
<li lay-id="2">已结束</li>
|
||||
<li lay-id="3">已关闭</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="pintuan_list" lay-filter="pintuan_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 推广 -->
|
||||
{include file="app/shop/view/component/promote_show.html"}
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
|
||||
<div class="contraction" data-id="{{d.pintuan_id}}" data-open="0">
|
||||
<span>+</span>
|
||||
</div>
|
||||
|
||||
<div class="title-pic">
|
||||
{{# if(d.goods_image){ }}
|
||||
<img layer-src="{{ns.img(d.goods_image.split(',')[0],'big')}}" src="{{ns.img(d.goods_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub">{{d.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 时间 -->
|
||||
<script id="time" type="text/html">
|
||||
<div class="layui-elip">开始时间:{{ns.time_to_date(d.start_time)}}</div>
|
||||
<div class="layui-elip">结束时间:{{ns.time_to_date(d.end_time)}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
未开始
|
||||
{{# }else if(d.status == 1){ }}
|
||||
进行中
|
||||
{{# }else if(d.status == 2){ }}
|
||||
已结束
|
||||
{{# }else if(d.status == 3){ }}
|
||||
已关闭
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="operation-wrap" data-pintuan-id="{{d.pintuan_id}}">
|
||||
<div class="popup-qrcode-wrap" style="display: none"><img class="popup-qrcode-loadimg" src="__STATIC__/loading/loading.gif"/></div>
|
||||
<div class="table-btn">
|
||||
{{# if(d.status == 1){ }}
|
||||
<a class="layui-btn text-color" lay-event="select">推广</a>
|
||||
{{# } }}
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
{{# if(d.status == 0){ }}
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
{{# }else if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="team">拼团列表</a>
|
||||
<a class="layui-btn" lay-event="invalid">关闭</a>
|
||||
{{# }else if(d.status == 2){ }}
|
||||
<a class="layui-btn" lay-event="team">拼团列表</a>
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
{{# }else if(d.status == 3){ }}
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="invalid">批量关闭</button>
|
||||
</script>
|
||||
|
||||
<!-- 商品sku -->
|
||||
<script type="text/html" id="skuList">
|
||||
<tr class="js-list-{{d.index}}" id="sku_img_{{d.index}}">
|
||||
<td colspan="9">
|
||||
<ul class="sku-list">
|
||||
{{# for(var i=0; i<d.list.length; i++){ }}
|
||||
<li>
|
||||
<div class="img-wrap">
|
||||
<img layer-src src="{{ns.img(d.list[i].sku_image)}}">
|
||||
</div>
|
||||
<div class="info-wrap">
|
||||
<span class="sku-name" title="{{d.list[i].sku_name}}">{{d.list[i].sku_name}}</span>
|
||||
<span class="price">商品价格:¥{{d.list[i].price}}</span>
|
||||
<span class="price">拼团价:¥{{d.list[i].pintuan_price}}</span>
|
||||
</div>
|
||||
</li>
|
||||
{{# } }}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var laytpl;
|
||||
$(function () {
|
||||
$("body").off("click", ".contraction").on("click", ".contraction", function () {
|
||||
|
||||
var pintuan_id = $(this).attr("data-id");
|
||||
var open = $(this).attr("data-open");
|
||||
var tr = $(this).parent().parent().parent().parent();
|
||||
var index = tr.attr("data-index");
|
||||
if (open == 1) {
|
||||
$(this).children("span").text("+");
|
||||
$(".js-list-" + index).remove();
|
||||
} else {
|
||||
$(this).children("span").text("-");
|
||||
$.ajax({
|
||||
url: ns.url("pintuan://shop/pintuan/getSkuList"),
|
||||
data: {pintuan_id: pintuan_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
|
||||
var sku_list = $("#skuList").html();
|
||||
var data = {
|
||||
list: res.data,
|
||||
index: index
|
||||
};
|
||||
laytpl(sku_list).render(data, function (html) {
|
||||
tr.after(html);
|
||||
});
|
||||
layer.photos({
|
||||
photos: '.img-wrap',
|
||||
anim: 5
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(this).attr("data-open", (open == 0 ? 1 : 0));
|
||||
});
|
||||
layui.use(['form', 'element','laytpl', 'laydate'], function () {
|
||||
laytpl = layui.laytpl;
|
||||
var table,
|
||||
form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
element = layui.element,
|
||||
pingtuanAll = [],
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
element.on('tab(pintuan_tab)', function () {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('lay-id')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#pintuan_list',
|
||||
url: ns.url("pintuan://shop/pintuan/lists"),
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox',
|
||||
width: '3%',
|
||||
}, {
|
||||
title: '拼团商品',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: '#goods'
|
||||
}, {
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
templet: function (data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field:'pintuan_price',
|
||||
title: '拼团价格',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
sort:true,
|
||||
templet: function (data) {
|
||||
return '¥' + data.pintuan_price;
|
||||
}
|
||||
}, {
|
||||
field: 'group_num',
|
||||
title: '开团组数',
|
||||
unresize: 'false',
|
||||
sort:true,
|
||||
width: '8%'
|
||||
}, {
|
||||
field: 'success_group_num',
|
||||
title: '成团组数',
|
||||
unresize: 'false',
|
||||
sort:true,
|
||||
width: '8%'
|
||||
}, {
|
||||
field: 'order_num',
|
||||
title: '购买人数',
|
||||
unresize: 'false',
|
||||
sort:true,
|
||||
width: '8%'
|
||||
}, {
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
templet: '#status'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
toolbar: '#toolbarOperation',
|
||||
});
|
||||
|
||||
table.on("sort",function (obj) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
order:obj.field,
|
||||
sort:obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 监听工具栏操作
|
||||
table.toolbar(function (obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'delete':
|
||||
deletePintuanAll(data)
|
||||
break;
|
||||
case 'invalid':
|
||||
invalidPintuanAll(data)
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
//批量关闭
|
||||
function invalidPintuanAll(data){
|
||||
if(data.length <= 0) return;
|
||||
var pintuanIdAll = [];
|
||||
for (var i in data){
|
||||
pintuanIdAll.push(data[i].pintuan_id);
|
||||
}
|
||||
|
||||
layer.confirm('确定要关闭拼团活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pintuan://shop/pintuan/invalidAll"),
|
||||
data: {
|
||||
pintuan_id: pintuanIdAll
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload();
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
//批量删除
|
||||
function deletePintuanAll(data){
|
||||
if(data.length <= 0) return;
|
||||
var pintuanIdAll = [];
|
||||
for (var i in data){
|
||||
pintuanIdAll.push(data[i].pintuan_id);
|
||||
}
|
||||
layer.confirm('确定要删除拼团活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pintuan://shop/pintuan/deleteAll"),
|
||||
data: {
|
||||
pintuan_id: pintuanIdAll
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function (data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function (obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/edit", {"pintuan_id": data.pintuan_id});
|
||||
break;
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/detail", {"pintuan_id": data.pintuan_id});
|
||||
break;
|
||||
case 'team': //开团团队
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/group", {"pintuan_id": data.pintuan_id});
|
||||
break;
|
||||
case 'delete': //删除
|
||||
deletePintuan(data.pintuan_id);
|
||||
break;
|
||||
case 'select': //推广
|
||||
pintuanUrl(data);
|
||||
break;
|
||||
case 'invalid': //使失效
|
||||
invalidPintuan(data.pintuan_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deletePintuan(pintuan_id) {
|
||||
layer.confirm('确定要删除该拼团活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pintuan://shop/pintuan/delete"),
|
||||
data: {
|
||||
pintuan_id: pintuan_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
//使失效
|
||||
function invalidPintuan(pintuan_id) {
|
||||
|
||||
layer.confirm('确定要关闭拼团活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pintuan://shop/pintuan/invalid"),
|
||||
data: {
|
||||
pintuan_id: pintuan_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
function pintuanUrl(data){
|
||||
new PromoteShow({
|
||||
url:ns.url("pintuan://shop/pintuan/pintuanUrl"),
|
||||
param:{pintuan_id:data.pintuan_id},
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("pintuan://shop/pintuan/add");
|
||||
}
|
||||
</script>
|
||||
BIN
addon/pintuan/shop/view/public/img/zone_preview.png
Executable file
|
After Width: | Height: | Size: 152 KiB |