初始上传

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

448
addon/topic/model/Poster.php Executable file
View File

@@ -0,0 +1,448 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\topic\model;
use addon\postertemplate\model\PosterTemplate as PosterTemplateModel;
use app\model\BaseModel;
use app\model\system\Site;
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 {
$goods_info = $this->getGoodsInfo($qrcode_param[ '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);
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);
if (empty($goods_info[ 'template_id' ]) || empty($template_info) || $template_info[ 'template_status' ] == 0) {
$poster_width = 720;
$poster_height = 1150;
$poster = new PosterExtend($poster_width, $poster_height);
$option = [
[
'action' => 'setBackground', // 设背景色
'data' => [255, 255, 255]
],
[
'action' => 'imageCopy', // 写入商品图
'data' => [
$goods_info['sku_image'],
50,
165,
620,
620,
'square',
true,
1
]
],
[
'action' => 'imageText', // 写入商品名称
'data' => [
$goods_info['sku_name'],
22,
[35, 35, 35],
50,
915,
360,
2,
true,
1
]
],
[
'action' => 'imageCopy', // 写入商品二维码
'data' => [
$qrcode_info['data']['path'],
435,
825,
240,
240,
'square',
0,
1
]
],
[
'action' => 'imageText', // 写入提示
'data' => [
'长按识别二维码',
19,
[102, 102, 102],
465,
1110,
490,
1,
1,
1
]
],
[
'action' => 'imageText', // 写入商品价格单位
'data' => [
'¥',
27,
[255, 0, 0],
50,
860,
490,
2,
true,
1
]
],
[
'action' => 'imageText', // 写入商品价格
'data' => [
$goods_info[ 'topic_price' ],
30,
[255, 0, 0],
78,
862,
490,
2,
true,
1
]
],
];
if (isset($member_info) && !empty($member_info)) {
$member_option = [
[
'action' => 'imageCircularCopy', // 写入用户头像
'data' => [
!empty($member_info['headimg']) ? $member_info['headimg'] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
50,
30,
100,
100
]
],
[
'action' => 'imageText', // 写入分享人昵称
'data' => [
$member_info['nickname'],
22,
[10, 10, 10],
170,
80,
580,
1,
1,
1
]
],
[
'action' => 'imageText', // 写入分享人昵称
'data' => [
'分享给你一个商品',
18,
[102, 102, 102],
170,
115,
580,
1,
1,
1
]
]
];
$option = array_merge($option, $member_option);
}
} else {
$condition = [
[ 'template_id', '=', $goods_info[ 'template_id' ] ],
[ 'site_id', '=', $site_id ]
];
$poster_template_model = new PosterTemplateModel();
$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,
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,
1,
$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' => [
$goods_info[ 'sku_image' ],
$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_info[ 'sku_name' ],
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] * $fontRate,
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_info[ 'topic_price' ],
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] * $fontRate,
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,
1,
$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,
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,
1,
$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' ] : 'public/static/img/default_img/head.png',
$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,
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 . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . time() . '_' . $app_type);
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 $sku_id
*/
private function getGoodsInfo($id)
{
$alias = 'nptg';
$join = [
[ 'goods_sku ngs', 'nptg.sku_id = ngs.sku_id', 'inner' ]
];
$field = 'ngs.sku_name,ngs.introduction,ngs.sku_image,ngs.sku_id,nptg.topic_price,ngs.template_id,ngs.price';
$info = model('promotion_topic_goods')->getInfo([ 'nptg.id' => $id ], $field, $alias, $join);
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;
}
}

301
addon/topic/model/Topic.php Executable file
View File

@@ -0,0 +1,301 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\topic\model;
use app\model\BaseModel;
use app\model\goods\Goods;
use app\model\system\Cron;
use app\model\upload\Upload;
/**
* 专题活动
*/
class Topic extends BaseModel
{
/**
* 添加专题活动
* @param unknown $data
*/
public function addTopic($data)
{
try {
if (empty($data[ 'goods' ])) return $this->error('', '请选择活动商品');
$topic_goods = $data[ 'goods' ];
unset($data[ 'goods' ]);
model('promotion_topic')->startTrans();
$data[ 'status' ] = 1;
if (time() > $data[ 'start_time' ] && time() < $data[ 'end_time' ]) {
$data[ 'status' ] = 2;
}
$topic_id = model('promotion_topic')->add($data);
$sku_list = [];
$goods = new Goods();
foreach ($topic_goods as $good_item) {
if (count($good_item) > 1) array_multisort(array_column($good_item, 'topic_price'), SORT_ASC, $good_item);
foreach ($good_item as $k => $sku_item) {
$sku_list[] = [
'topic_id' => $topic_id,
'start_time' => $data['start_time'],
'end_time' => $data['end_time'],
'site_id' => $data['site_id'],
'sku_id' => $sku_item['sku_id'],
'topic_price' => $sku_item['topic_price'],
'goods_id' => $sku_item['goods_id'],
'default' => $k == 0 ? 1 : 0
];
}
$goods->modifyPromotionAddon($sku_item[ 'goods_id' ], [ 'topic' => $topic_id ]);
}
model('promotion_topic_goods')->addList($sku_list);
$cron = new Cron();
if ($data[ 'status' ] == 2) {
$cron->addCron(1, 0, "专题活动关闭", "CloseTopic", $data[ 'end_time' ], $topic_id);
} else {
$cron->addCron(1, 0, "专题活动开启", "OpenTopic", $data[ 'start_time' ], $topic_id);
$cron->addCron(1, 0, "专题活动关闭", "CloseTopic", $data[ 'end_time' ], $topic_id);
}
model('promotion_topic')->commit();
return $this->success($topic_id);
} catch (\Exception $e) {
model('promotion_topic')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 修改专题活动
* @param $data
* @param $site_id
* @param $del_id
* @return array
*/
public function editTopic($data, $site_id, $del_id)
{
try {
if (empty($data[ 'goods' ])) return $this->error('', '请选择活动商品');
$topic_goods = $data[ 'goods' ];
unset($data[ 'goods' ]);
model('promotion_topic')->startTrans();
$data[ 'status' ] = 1;
if (time() > $data[ 'start_time' ] && time() < $data[ 'end_time' ]) {
$data[ 'status' ] = 2;
}
$topic_info = model('promotion_topic')->getInfo([ [ 'topic_id', '=', $data[ 'topic_id' ] ], [ 'site_id', '=', $site_id ] ]);
if (!empty($topic_info[ 'topic_adv' ]) && !empty($data[ 'topic_adv' ]) && $topic_info[ 'topic_adv' ] != $data[ 'topic_adv' ]) {
$upload_model = new Upload();
$upload_model->deletePic($topic_info[ 'topic_adv' ], $site_id);
}
$res = model('promotion_topic')->update($data, [ [ 'topic_id', '=', $data[ 'topic_id' ] ], [ 'site_id', '=', $site_id ] ]);
if (!empty($del_id)) {
model('promotion_topic_goods')->delete([ [ 'id', 'in', explode(',', $del_id) ], [ 'topic_id', '=', $data[ 'topic_id' ] ], [ 'site_id', '=', $site_id ] ]);
}
$sku_list = [];
foreach ($topic_goods as $good_item) {
if (count($good_item) > 1) array_multisort(array_column($good_item, 'topic_price'), SORT_ASC, $good_item);
foreach ($good_item as $k => $sku_item) {
if (!empty($sku_item[ 'id' ])) {
model('promotion_topic_goods')->update([
'topic_price' => $sku_item[ 'topic_price' ],
'start_time' => $data[ 'start_time' ],
'end_time' => $data[ 'end_time' ]
], [
[ 'topic_id', '=', $data[ 'topic_id' ] ],
[ 'id', '=', $sku_item[ 'id' ] ],
[ 'goods_id', '=', $sku_item[ 'goods_id' ] ],
[ 'sku_id', '=', $sku_item[ 'sku_id' ] ],
]);
} else {
$sku_list[] = [
'topic_id' => $data['topic_id'],
'start_time' => $data['start_time'],
'end_time' => $data['end_time'],
'site_id' => $site_id,
'sku_id' => $sku_item['sku_id'],
'topic_price' => $sku_item['topic_price'],
'goods_id' => $sku_item['goods_id'],
'default' => $k == 0 ? 1 : 0
];
}
}
}
model('promotion_topic_goods')->addList($sku_list);
$cron = new Cron();
if ($data[ 'status' ] == 2) {
//活动商品启动
$this->cronOpenTopic($data[ 'topic_id' ]);
$cron->deleteCron([ [ 'event', '=', 'OpenTopic' ], [ 'relate_id', '=', $data[ 'topic_id' ] ] ]);
$cron->deleteCron([ [ 'event', '=', 'CloseTopic' ], [ 'relate_id', '=', $data[ 'topic_id' ] ] ]);
$cron->addCron(1, 0, "专题活动关闭", "CloseTopic", $data[ 'end_time' ], $data[ 'topic_id' ]);
} else {
$cron->deleteCron([ [ 'event', '=', 'OpenTopic' ], [ 'relate_id', '=', $data[ 'topic_id' ] ] ]);
$cron->deleteCron([ [ 'event', '=', 'CloseTopic' ], [ 'relate_id', '=', $data[ 'topic_id' ] ] ]);
$cron->addCron(1, 0, "专题活动开启", "OpenTopic", $data[ 'start_time' ], $data[ 'topic_id' ]);
$cron->addCron(1, 0, "专题活动关闭", "CloseTopic", $data[ 'end_time' ], $data[ 'topic_id' ]);
}
model('promotion_topic')->commit();
return $this->success($res);
} catch (\Exception $e) {
model('promotion_topic')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 删除专题活动
* @param unknown $topic_id
*/
public function deleteTopic($topic_id, $site_id)
{
try {
model('promotion_topic')->startTrans();
$topic_info = model('promotion_topic')->getInfo([ [ 'topic_id', '=', $topic_id ], [ 'site_id', '=', $site_id ] ]);
if (!empty($topic_info[ 'topic_adv' ])) {
$upload_model = new Upload();
$upload_model->deletePic($topic_info[ 'topic_adv' ], $site_id);
}
$topic_list = model("promotion_topic_goods")->getList([ [ 'topic_id', '=', $topic_id ], [ 'site_id', '=', $site_id ] ]);
$goods = new Goods();
foreach ($topic_list as $k => $v) {
$goods->modifyPromotionAddon($v[ 'goods_id' ], [ 'topic' => $topic_id ], true);
}
$res = model('promotion_topic')->delete([ [ 'topic_id', '=', $topic_id ], [ 'site_id', '=', $site_id ] ]);
model('promotion_topic_goods')->delete([ [ 'topic_id', '=', $topic_id ], [ 'site_id', '=', $site_id ] ]);
model('promotion_topic')->commit();
return $this->success($res);
} catch (\Exception $e) {
model('promotion_topic')->rollback();
return $this->error('', $e->getMessage());
}
}
/**
* 获取专题活动信息
* @param array $condition
* @param string $field
*/
public function getTopicInfo($condition, $field = '*')
{
$res = model('promotion_topic')->getInfo($condition, $field);
return $this->success($res);
}
/**
* 获取专题活动详情
* @param array $condition
* @param string $field
*/
public function getTopicDetail($condition)
{
$res = model('promotion_topic')->getInfo($condition, '*');
if (!empty($res)) {
$alias = 'nptg';
$join = [
[ 'goods g', 'nptg.goods_id = g.goods_id', 'inner' ],
[ 'goods_sku ngs', 'nptg.sku_id = ngs.sku_id', 'inner' ],
];
$field = 'nptg.id,nptg.sku_id,nptg.topic_price,nptg.goods_id,ngs.price,ngs.stock,ngs.sku_name,ngs.sku_image';
$res[ 'goods_list' ] = model('promotion_topic_goods')->getList([ [ 'nptg.topic_id', '=', $res[ 'topic_id' ] ], [ 'g.goods_state', '=', 1 ], [ 'g.is_delete', '=', 0 ] ], $field, 'id asc', $alias, $join);
foreach ($res[ 'goods_list' ] as $k => $v) {
$res[ 'goods_list' ][ $k ][ 'stock' ] = numberFormat($res[ 'goods_list' ][ $k ][ 'stock' ]);
}
$res[ 'goods_list_count' ] = count($res[ 'goods_list' ]);
}
return $this->success($res);
}
/**
* 获取专题活动列表
* @param array $condition
* @param string $field
* @param string $order
* @param string $limit
*/
public function getTopicList($condition = [], $field = '*', $order = '', $limit = null)
{
$list = model('promotion_topic')->getList($condition, $field, $order, '', '', '', $limit);
return $this->success($list);
}
/**
* 获取专题分页列表
* @param array $condition
* @param number $page
* @param string $page_size
* @param string $order
* @param string $field
*/
public function getTopicPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'modify_time desc,create_time desc', $field = '*')
{
$list = model('promotion_topic')->pageList($condition, $field, $order, $page, $page_size);
return $this->success($list);
}
/**
* 开启专题活动
* @param $groupbuy_id
* @return array|\multitype
*/
public function cronOpenTopic($topic_id)
{
$topic_info = model('promotion_topic')->getInfo([ [ 'topic_id', '=', $topic_id ] ], 'start_time,status');
if (!empty($topic_info)) {
if ($topic_info[ 'start_time' ] <= time() && $topic_info[ 'status' ] == 1) {
$res = model('promotion_topic')->update([ 'status' => 2 ], [ [ 'topic_id', '=', $topic_id ] ]);
return $this->success($res);
} else {
return $this->error("", "专题活动已开启或者关闭");
}
} else {
return $this->error("", "专题活动不存在");
}
}
/**
* 关闭专题活动
* @param $groupbuy_id
* @return array|\multitype
*/
public function cronCloseTopic($topic_id)
{
$topic_info = model('promotion_topic')->getInfo([ [ 'topic_id', '=', $topic_id ] ], 'start_time,status');
if (!empty($topic_info)) {
if ($topic_info[ 'status' ] != 3) {
$res = model('promotion_topic')->update([ 'status' => 3 ], [ [ 'topic_id', '=', $topic_id ] ]);
return $this->success($res);
} else {
return $this->error("", "该活动已结束");
}
} else {
return $this->error("", "专题活动不存在");
}
}
}

216
addon/topic/model/TopicGoods.php Executable file
View File

@@ -0,0 +1,216 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\topic\model;
use app\model\BaseModel;
use app\model\goods\Goods;
/**
* 专题活动
*/
class TopicGoods extends BaseModel
{
/**
* 添加专题商品
* @param $topic_id
* @param $site_id
* @param $sku_ids
* @return array
*/
public function addTopicGoods($topic_id, $site_id, $sku_ids)
{
$sku_list = model('goods_sku')->getList([
[ 'sku_id', 'in', $sku_ids ],
[ 'site_id', '=', $site_id ],
], 'goods_id, sku_id, price');
$topic_info = model("promotion_topic")->getInfo([ [ 'topic_id', '=', $topic_id ] ], 'start_time, end_time');
$data = [];
$goods = new Goods();
foreach ($sku_list as $val) {
$goods_count = model("promotion_topic_goods")->getCount([ 'topic_id' => $topic_id, 'sku_id' => $val[ 'sku_id' ] ]);
if (empty($goods_count)) {
$data[] = [
'topic_id' => $topic_id,
'site_id' => $site_id,
'sku_id' => $val[ 'sku_id' ],
'topic_price' => $val[ 'price' ],
'start_time' => $topic_info[ 'start_time' ],
'end_time' => $topic_info[ 'end_time' ]
];
$goods->modifyPromotionAddon($val[ 'goods_id' ], [ 'topic' => $topic_id ]);
}
}
model("promotion_topic_goods")->addList($data);
return $this->success();
}
/**
* 修改专题商品
* @param $topic_id
* @param $site_id
* @param $sku_id
* @param $price
* @return array
*/
public function editTopicGoods($topic_id, $site_id, $sku_id, $price)
{
$data = [
'topic_id' => $topic_id,
'site_id' => $site_id,
'sku_id' => $sku_id,
'topic_price' => $price
];
model("promotion_topic_goods")->update($data, [ [ 'topic_id', '=', $topic_id ], [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $site_id ] ]);
return $this->success();
}
/**
* 删除专题商品
* @param $topic_id
* @param $site_id
* @param $sku_id
* @return array
*/
public function deleteTopicGoods($topic_id, $site_id, $sku_id)
{
$goods_sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $sku_id ] ], 'goods_id');
$goods = new Goods();
$goods->modifyPromotionAddon($goods_sku_info[ 'goods_id' ], [ 'topic' => $topic_id ], true);
model("promotion_topic_goods")->delete([ [ 'topic_id', '=', $topic_id ], [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $site_id ] ]);
return $this->success();
}
public function getTopicIdByGoodsId($topic_id, $sku_id)
{
$info = model("promotion_topic_goods")->getInfo([ [ 'topic_id', '=', $topic_id ], [ 'sku_id', '=', $sku_id ]], 'id');
return $info;
}
/**
* 获取专题商品详情
* @param $condition
* @param string $field
* @return array
*/
public function getTopicGoodsDetail($condition, $field = '')
{
if (empty($field)) {
$field = 'sku.goods_id,sku.sku_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,sku.stock,sku.click_num,
(g.sale_num + g.virtual_sale) as sale_num,sku.collect_num,sku.sku_image,sku.sku_images,sku.site_id,sku.goods_content,
sku.goods_state,sku.is_virtual,sku.is_free_shipping,sku.goods_spec_format,sku.goods_attr_format,sku.introduction,
sku.support_trade_type,sku.unit,sku.video_url,sku.evaluate,sku.goods_service_ids,ptg.id,ptg.topic_id,ptg.start_time,
ptg.end_time,ptg.topic_price,pt.topic_name,g.goods_image,g.goods_stock,g.goods_name,sku.qr_id,sku.market_price,
g.stock_show,g.sale_show,g.market_price_show,g.barrage_show,g.label_name,pt.remark';
}
$alias = 'ptg';
$join = [
[ 'goods_sku sku', 'ptg.sku_id = sku.sku_id', 'inner' ],
[ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
[ 'promotion_topic pt', 'pt.topic_id = ptg.topic_id', 'inner' ],
];
$info = model('promotion_topic_goods')->getInfo($condition, $field, $alias, $join);
if (!empty($info)) {
if (isset($info[ 'sale_num' ])) {
$info[ 'sale_num' ] = numberFormat($info[ 'sale_num' ]);
}
if (isset($info[ 'stock' ])) {
$info[ 'stock' ] = numberFormat($info[ 'stock' ]);
}
if (isset($info[ 'goods_stock' ])) {
$info[ 'goods_stock' ] = numberFormat($info[ 'goods_stock' ]);
}
}
return $this->success($info);
}
/**
* 获取专题商品详情
* @param $condition
* @param string $field
* @return array
*/
public function getTopicGoodsSkuList($condition)
{
$field = 'sku.sku_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.stock,sku.sku_image,sku.sku_images,sku.goods_spec_format,ptg.id,ptg.topic_id,ptg.start_time,ptg.end_time,ptg.topic_price,pt.topic_name,g.goods_image';
$alias = 'ptg';
$join = [
[ 'goods_sku sku', 'ptg.sku_id = sku.sku_id', 'inner' ],
[ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
[ 'promotion_topic pt', 'pt.topic_id = ptg.topic_id', 'inner' ],
];
$list = model('promotion_topic_goods')->getList($condition, $field, 'ptg.id asc', $alias, $join);
foreach ($list as $k => $v) {
$list[ $k ][ 'stock' ] = numberFormat($list[ $k ][ 'stock' ]);
}
return $this->success($list);
}
/**
* 获取专题商品列表
* @param array $condition
* @param int $page
* @param int $page_size
* @param string $order
* @param string $field
* @return mixed
*/
public function getTopicGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '')
{
$alias = 'nptg';
if (empty($field)) {
$field = 'ngs.sku_id, ngs.sku_name, ngs.sku_no, ngs.sku_spec_format, ngs.price, ngs.market_price,
ngs.cost_price, ngs.discount_price, ngs.promotion_type, ngs.stock,
ngs.weight, ngs.volume, ngs.click_num, (g.sale_num + g.virtual_sale) as sale_num, ngs.collect_num, ngs.sku_image,
ngs.sku_images, ngs.goods_id, ngs.goods_class, ngs.goods_class_name, ngs.goods_attr_class,
ngs.goods_attr_name, ngs.goods_name,ngs.goods_state,
ngs.is_virtual, ngs.virtual_indate, ngs.is_free_shipping, ngs.shipping_template, ngs.goods_spec_format,
ngs.goods_attr_format, ngs.is_delete, ngs.introduction, ngs.keywords, ngs.unit, ngs.sort,npt.topic_name,
npt.topic_adv, npt.status, nptg.id,nptg.start_time, nptg.end_time, nptg.topic_price, npt.topic_id, g.stock_show,g.sale_show,g.market_price_show';
}
$join = [
[ 'goods g', 'nptg.goods_id = g.goods_id', 'inner' ],
[ 'goods_sku ngs', 'nptg.sku_id = ngs.sku_id', 'inner' ],
[ 'promotion_topic npt', 'nptg.topic_id = npt.topic_id', 'inner' ],
];
$res = model('promotion_topic_goods')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
foreach ($res[ 'list' ] as $k => $v) {
if (isset($v[ 'stock' ])) {
$res[ 'list' ][ $k ][ 'stock' ] = numberFormat($res[ 'list' ][ $k ][ 'stock' ]);
}
if (isset($v[ 'sale_num' ])) {
$res[ 'list' ][ $k ][ 'sale_num' ] = numberFormat($res[ 'list' ][ $k ][ 'sale_num' ]);
}
}
return $this->success($res);
}
/**
* 判断规格值是否禁用
* @param $topic_id
* @param $site_id
* @param string $goods_spec_format
* @param int $sku_id
* @return int|mixed
*/
public function getGoodsSpecFormat($topic_id, $site_id, $goods_spec_format = '')
{
//获取活动参与的商品sku_ids
$sku_ids = model('promotion_topic_goods')->getColumn([ [ 'topic_id', '=', $topic_id ], [ 'site_id', '=', $site_id ] ], 'sku_id');
$goods_model = new Goods();
$res = $goods_model->getGoodsSpecFormat($sku_ids, $goods_spec_format);
return $res;
}
}

View File

@@ -0,0 +1,255 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\topic\model;
use app\model\BaseModel;
use app\model\order\OrderCreate;
use app\model\goods\GoodsStock;
use app\model\order\OrderCreateTool;
use app\model\store\Store;
use extend\exception\OrderException;
use think\facade\Cache;
use app\model\express\Express;
use app\model\system\Pay;
use app\model\express\Config as ExpressConfig;
use app\model\order\Config;
use app\model\express\Local;
/**
* 订单创建(专题)
*
* @author Administrator
*
*/
class TopicOrderCreate extends BaseModel
{
use OrderCreateTool;
public $topic_id = 0;
public $topic_info = [];
public function __construct()
{
$this->promotion_type = 'topic';
$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);
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);
//扣除余额(统一扣除)
$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', '', $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->initMemberAddress();
//初始化会员账户
$this->initMemberAccount();
//商品列表信息
$this->getOrderGoodsCalculate();
//查询专题信息
$topic_model = new Topic();
$this->topic_info = $topic_model->getTopicInfo([ [ 'topic_id', '=', $this->topic_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
if (empty($this->topic_info)) throw new OrderException('找不到可用的专题活动!');
//判断时间段是否符合
$time = time();//当日时间戳
if ($this->topic_info[ 'status' ] != 2 || ($time < $this->topic_info[ 'start_time' ] || $time > $this->topic_info[ 'end_time' ])) {
$this->error = 1;
$this->error_msg = '当前商品专题活动未开启!';
}
$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->getTopicGoodsInfo();
return true;
}
/**
* 获取专题商品信息
* @return array
*/
public function getTopicGoodsInfo()
{
$id = $this->param[ 'id' ];
$num = $this->param[ 'num' ];
//组装商品列表
$field = 'ptg.sku_id,ptg.id,ptg.topic_id,ptg.topic_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';
$alias = 'ptg';
$join = [
[
'goods_sku ngs',
'ptg.sku_id = ngs.sku_id',
'inner'
],
[
'site ns',
'ngs.site_id = ns.site_id',
'inner'
]
];
$info = model('promotion_topic_goods')->getInfo([ [ 'ptg.id', '=', $id ], [ 'ptg.site_id', '=', $this->site_id ] ], $field, $alias, $join);
if (empty($info)) throw new OrderException('商品不存在!');
//判断是否是虚拟订单
if ($info[ 'is_virtual' ]) {
$this->is_virtual = 1;
} else {
$this->is_virtual = 0;
}
$this->topic_id = $info[ 'topic_id' ];
$info[ 'stock' ] = numberFormat($info[ 'stock' ]);
$info[ 'num' ] = $num;
$price = $info[ 'topic_price' ];
$info[ 'price' ] = $price;
$goods_money = $price * $info[ 'num' ];
$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;
}
}

View File

@@ -0,0 +1,181 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\topic\model\share;
use addon\topic\model\Topic as TopicModel;
use app\model\share\WchatShareBase as BaseModel;
use addon\topic\model\TopicGoods as TopicGoodsModel;
use app\model\system\Config as ConfigModel;
/**
* 分享
*/
class WchatShare extends BaseModel
{
protected $config = [
[
'title' => '专题列表',
'config_key' => 'WCHAT_SHARE_CONFIG_TOPIC_LIST',
'path' => [ '/pages_promotion/topics/list' ],
'method_prefix' => 'topicList',
],
[
'title' => '专题详情',
'config_key' => 'WCHAT_SHARE_CONFIG_TOPIC_DETAIL',
'path' => [ '/pages_promotion/topics/detail' ],
'method_prefix' => 'topicDetail',
],
[
'title' => '专题商品详情',
'config_key' => 'WCHAT_SHARE_CONFIG_TOPIC_GOODS_DETAIL',
'path' => [ '/pages_promotion/topics/goods_detail' ],
'method_prefix' => 'goodsDetail',
],
];
protected $sort = 9;
/**
* 专题列表
* @param $param
* @return array
*/
protected function topicListShareData($param)
{
//跳转路径
$link = $this->getShareLink($param);
$config_data = $this->topicListShareConfig($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 topicListShareConfig($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/topic/icon.png');
}
return [
'value' => $data[ 'value' ],
];
}
/**
* 专题详情
* @param $param
* @return array
*/
protected function topicDetailShareData($param)
{
$site_id = $param[ 'site_id' ];
//链接参数
parse_str(parse_url($param[ 'url' ])[ 'query' ] ?? '', $query);
if (isset($query[ 'topic_id' ])) {
$topic_model = new TopicModel();
$topic_detail = $topic_model->getTopicDetail([
[ 'topic_id', '=', $query[ 'topic_id' ] ],
[ 'site_id', '=', $site_id ],
])[ 'data' ];
if (!empty($topic_detail)) {
//跳转路径
$link = $this->getShareLink($param);
$data = [
'link' => $link,
'desc' => $topic_detail[ 'remark' ],
'imgUrl' => img($topic_detail[ 'topic_adv' ]),
'title' => $topic_detail[ 'topic_name' ],
];
return [
'permission' => [
'hideOptionMenu' => false,
'hideMenuItems' => [],
],
'data' => $data,//分享内容
];
}
}
}
/**
* 专题分享数据
* @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[ 'id' ]) || isset($query[ 'topic_id' ])) {
$id = $query['id'] ?? $query['topic_id'];
$goods = new TopicGoodsModel();
$condition = [
[ 'ptg.id', '=', $id ],
[ 'pt.status', '=', 2 ]
];
$sku_info = $goods->getTopicGoodsDetail($condition)[ '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[ 'topic_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,//分享内容
];
}
}
}
}

View File

@@ -0,0 +1,90 @@
<?php
/**
* Niushop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.niushop.com
* =========================================================
*/
namespace addon\topic\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_TOPIC_LIST',
'path' => ['/pages_promotion/topics/list'],
'method_prefix' => 'topicList',
],
];
protected $sort = 10;
/**
* 专题列表
* @param $param
* @return array
*/
protected function topicListShareData($param)
{
//获取和替换配置数据
$config_data = $this->topicListShareConfig($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 topicListShareConfig($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,
];
}
}