chore(src): 所有代码上传

This commit is contained in:
2025-12-02 15:36:42 +08:00
parent ce8e59902c
commit eb79ad260c
669 changed files with 86838 additions and 87639 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,64 +1,56 @@
<?php
/**
*/
namespace addon\coupon\model;
use app\model\BaseModel;
use app\model\system\Stat;
/**
* 优惠券统计
*/
class CouponStat extends BaseModel
{
/**
* 领取优惠券统计
* @param $params
* @return array
*/
public function addReceiveCouponStat($params)
{
$coupon_id = $params[ 'coupon_id' ];
$site_id = $params[ 'site_id' ] ?? 0;
$order_condition = array (
[ 'coupon_id', '=', $coupon_id ],
[ 'site_id', '=', $site_id ]
);
$info = model('promotion_coupon')->getInfo($order_condition);
if (empty($info))
return $this->error();
$stat_data = array (
'site_id' => $site_id,
'coupon_count' => 1
);
$member_id = $info[ 'member_id' ];
//如果是第一笔订单才能累加下单会员数
$time_region = getDayStartAndEndTime();
$today_start_time = $time_region[ 'start_time' ];
$today_end_time = $time_region[ 'end_time' ];
$today_order_condition = array (
[ 'member_id', '=', $member_id ],
[ 'fetch_time', 'between', [ $today_start_time, $today_end_time ] ],
[ 'coupon_id', '<>', $coupon_id ]
);
$count = model('promotion_coupon')->getCount($today_order_condition);
if ($count == 0) {
$stat_data[ 'coupon_member_count' ] = 1;
}
//发布统计
$stat_model = new Stat();
$result = $stat_model->addShopStat($stat_data);
return $result;
}
<?php
namespace addon\coupon\model;
use app\model\BaseModel;
use app\model\system\Stat;
/**
* 优惠券统计
*/
class CouponStat extends BaseModel
{
/**
* 领取优惠券统计
* @param $params
* @return array
*/
public function addReceiveCouponStat($params)
{
$coupon_id = $params[ 'coupon_id' ];
$site_id = $params[ 'site_id' ] ?? 0;
$order_condition = array (
[ 'coupon_id', '=', $coupon_id ],
[ 'site_id', '=', $site_id ]
);
$info = model('promotion_coupon')->getInfo($order_condition);
if (empty($info))
return $this->error();
$stat_data = array (
'site_id' => $site_id,
'coupon_count' => 1
);
$member_id = $info[ 'member_id' ];
//如果是第一笔订单才能累加下单会员数
$time_region = getDayStartAndEndTime();
$today_start_time = $time_region[ 'start_time' ];
$today_end_time = $time_region[ 'end_time' ];
$today_order_condition = array (
[ 'member_id', '=', $member_id ],
[ 'fetch_time', 'between', [ $today_start_time, $today_end_time ] ],
[ 'coupon_id', '<>', $coupon_id ]
);
$count = model('promotion_coupon')->getCount($today_order_condition);
if ($count == 0) {
$stat_data[ 'coupon_member_count' ] = 1;
}
//发布统计
$stat_model = new Stat();
$result = $stat_model->addShopStat($stat_data);
return $result;
}
}

View File

@@ -1,336 +1,328 @@
<?php
/**
*/
namespace addon\coupon\model;
use app\model\BaseModel;
use app\model\system\Config as ConfigModel;
use app\model\system\Cron;
use app\model\upload\Upload;
/**
* 优惠券活动
*/
class CouponType extends BaseModel
{
//优惠券类型状态
private $coupon_type_status = [
1 => '进行中',
2 => '已结束',
-1 => '已关闭',
];
public function getCouponTypeStatus()
{
return $this->coupon_type_status;
}
/**
* 添加优惠券活动
* @param $data
* @return array
*/
public function addCouponType($data)
{
//只要创建了就是进行中
$data[ 'status' ] = 1;
$data[ 'create_time' ] = time();
//获取商品id
if ($data[ 'goods_type' ] == 1) {//全部商品参与
$data[ 'goods_ids' ] = '';
}
$data[ 'goods_ids' ] = ',' . $data[ 'goods_ids' ] . ',';
$res = model('promotion_coupon_type')->add($data);
if ($data[ 'validity_type' ] == 0) {
$cron = new Cron();
$cron->addCron(1, 1, '优惠券活动定时结束', 'CronCouponTypeEnd', $data[ 'end_time' ], $res);
}
$this->qrcode($res, 'all', $data[ 'site_id' ]);
return $this->success($res);
}
/**
* 编辑优惠券活动
* @param $data
* @param $coupon_type_id
* @return array
*/
public function editCouponType($data, $coupon_type_id)
{
$data[ 'update_time' ] = time();
//获取商品id
if ($data[ 'goods_type' ] == 1) {//全部商品参与
$data[ 'goods_ids' ] = '';
}
$coupon_info = model('promotion_coupon_type')->getInfo([ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
if (!empty($coupon_info[ 'image' ]) && !empty($data[ 'image' ]) && $coupon_info[ 'image' ] != $data[ 'image' ]) {
$upload_model = new Upload();
$upload_model->deletePic($coupon_info[ 'image' ], $coupon_info[ 'site_id' ]);
}
$data[ 'goods_ids' ] = ',' . $data[ 'goods_ids' ] . ',';
$res = model('promotion_coupon_type')->update($data, [ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
model('promotion_coupon')->update([ 'goods_ids' => $data[ 'goods_ids' ], 'goods_type' => $data[ 'goods_type' ] ], [ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'state', '=', 1 ] ]);
$cron = new Cron();
$cron->deleteCron([ [ 'event', '=', 'CronCouponTypeEnd' ], [ 'relate_id', '=', $coupon_type_id ] ]);
if ($data[ 'validity_type' ] == 0) {
$cron->addCron(1, 1, '优惠券活动定时结束', 'CronCouponTypeEnd', $data[ 'end_time' ], $coupon_type_id);
}
return $this->success($res);
}
/**
* 关闭优惠券
* @param $coupon_type_id
* @param $site_id
* @return array
*/
public function closeCouponType($coupon_type_id, $site_id)
{
$res = model('promotion_coupon_type')->update([ 'status' => -1 ], [ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'site_id', '=', $site_id ] ]);
// if ($res) {
// model("promotion_coupon")->update(['state' => 3], [['coupon_type_id', '=', $coupon_type_id], ['site_id', '=', $site_id]]);
// }
$cron = new Cron();
$cron->deleteCron([ [ 'event', '=', 'CronCouponTypeEnd' ], [ 'relate_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
/**
* 删除优惠券活动
* @param $coupon_type_id
* @param $site_id
* @return array
*/
public function deleteCouponType($coupon_type_id, $site_id)
{
$coupon_info = model('promotion_coupon_type')->getInfo([ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
if ($coupon_info['status'] == 1) return $this->error('', '进行中的优惠卷无法删除,请先关闭');
if (!empty($coupon_info[ 'image' ])) {
$upload_model = new Upload();
$upload_model->deletePic($coupon_info[ 'image' ], $coupon_info[ 'site_id' ]);
}
$res = model('promotion_coupon_type')->delete([ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'site_id', '=', $site_id ] ]);
if ($res) {
model('promotion_coupon')->delete([ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
}
$cron = new Cron();
$cron->deleteCron([ [ 'event', '=', 'CronCouponTypeEnd' ], [ 'relate_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
/**
* 获取优惠券活动详情
* @param $coupon_type_id
* @param $site_id
* @return array
*/
public function getCouponTypeInfo($coupon_type_id, $site_id)
{
$res = model('promotion_coupon_type')->getList([ [ 'coupon_type_id', 'in', $coupon_type_id ], [ 'site_id', '=', $site_id ] ]);
if (!empty($res)) {
foreach ($res as $k => $v) {
if ($v[ 'goods_type' ] == 2 || $v[ 'goods_type' ] == 3) {
$field[ $k ] = 'goods_id,goods_name,FLOOR(goods_stock) as goods_stock,goods_image,price,sort';
$goods_ids[ $k ] = substr($v[ 'goods_ids' ], '1', '-1');
$goods_list[ $k ] = model('goods')->getList([ [ 'goods_id', 'in', $goods_ids[ $k ] ] ], $field[ $k ]);
}
$res[ $k ][ 'goods_list' ] = $goods_list[$k] ?? [];
$res[ $k ][ 'goods_list_count' ] = count($res[ $k ][ 'goods_list' ]);
}
}
return $this->success($res);
}
/**
* 获取优惠券活动信息
* @param array $where
* @param bool $field
* @param string $alias
* @param null $join
* @param null $data
* @return array
*/
public function getInfo($where = [], $field = true, $alias = 'a', $join = null, $data = null)
{
$res = model('promotion_coupon_type')->getInfo($where, $field, $alias, $join, $data);
return $this->success($res);
}
/**
* 获取优惠券类型列表
* @param array $condition
* @param string $field
* @param string $order
* @param null $limit
* @return array
*/
public function getCouponTypeList($condition = [], $field = '*', $order = 'create_time desc', $limit = null)
{
$res = model('promotion_coupon_type')->getList($condition, $field, $order, '', '', '', $limit);
return $this->success($res);
}
/**
* 获取优惠券活动分页列表
* @param array $condition
* @param int $page
* @param int $page_size
* @param string $order
* @param string $field
* @return array
*/
public function getCouponTypePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
{
$condition[] = [ 'promotion_type', '=', 0 ];
$list = model('promotion_coupon_type')->pageList($condition, $field, $order, $page, $page_size);
return $this->success($list);
}
/**
* 排序
* @param $coupon_type_id
* @param $sort
* @return array
*/
public function couponSort($coupon_type_id, $sort)
{
$res = model('promotion_coupon_type')->update([ 'sort' => $sort ], [ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
/**
* 生成优惠券二维码
* @param $coupon_type_id
* @param string $app_type all为全部
* @param string $type 类型 create创建 get获取
* @return mixed|array
*/
public function qrcode($coupon_type_id, $app_type, $site_id, $type = 'create')
{
$res = event('Qrcode', [
'site_id' => $site_id,
'app_type' => $app_type,
'type' => $type,
'data' => [
'coupon_type_id' => $coupon_type_id
],
'page' => '/pages_tool/goods/coupon_receive',
'qrcode_path' => 'upload/qrcode/coupon',
'qrcode_name' => 'coupon_type_code_' . $coupon_type_id . '_' . $site_id,
], true);
return $res;
}
/**
* 优惠券定时结束
* @param $coupon_type_id
* @return array
*/
public function couponCronEnd($coupon_type_id)
{
$res = model('promotion_coupon_type')->update([ 'status' => 2 ], [ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
public function spread($coupon_type_id, $name, $site_id, $type = 'create')
{
$data = [
'site_id' => $site_id,
'app_type' => 'all', // all为全部
'type' => $type, // 类型 create创建 get获取
'data' => [
'coupon_type_id' => $coupon_type_id
],
'page' => '/pages_tool/goods/coupon_receive',
'qrcode_path' => 'upload/qrcode/coupon',
'qrcode_name' => 'coupon_type_code_' . $coupon_type_id . '_' . $site_id,
];
event('Qrcode', $data, true);
$app_type_list = config('app_type');
$path = [];
foreach ($app_type_list as $k => $v) {
switch ( $k ) {
case 'h5':
$wap_domain = getH5Domain();
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ] . '?coupon_type_id=' . $coupon_type_id;
$path[ $k ][ 'img' ] = 'upload/qrcode/coupon/coupon_type_code_' . $coupon_type_id . '_' . $site_id . '_' . $k . '.png';
break;
case 'weapp' :
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
if (!empty($res[ 'data' ])) {
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信小程序';
} else {
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
}
} else {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信小程序';
}
break;
case 'wechat' :
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
if (!empty($res[ 'data' ])) {
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信公众号';
} else {
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
}
} else {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信公众号';
}
break;
}
}
$return = [
'path' => $path,
'name' => $name,
];
return $this->success($return);
}
public function urlQrcode($page, $qrcode_param, $promotion_type, $app_type, $site_id)
{
$params = [
'site_id' => $site_id,
'data' => $qrcode_param,
'page' => $page,
'promotion_type' => $promotion_type,
'app_type' => $app_type,
'h5_path' => $page . '?coupon_type_id=' . $qrcode_param[ 'coupon_type_id' ],
'qrcode_path' => 'upload/qrcode/coupon',
'qrcode_name' => 'coupon_type_code_' . $promotion_type . '_' . $qrcode_param[ 'coupon_type_id' ] . '_' . $site_id,
];
$solitaire = event('PromotionQrcode', $params, true);
return $this->success($solitaire);
}
<?php
namespace addon\coupon\model;
use app\model\BaseModel;
use app\model\system\Config as ConfigModel;
use app\model\system\Cron;
use app\model\upload\Upload;
/**
* 优惠券活动
*/
class CouponType extends BaseModel
{
//优惠券类型状态
private $coupon_type_status = [
1 => '进行中',
2 => '已结束',
-1 => '已关闭',
];
public function getCouponTypeStatus()
{
return $this->coupon_type_status;
}
/**
* 添加优惠券活动
* @param $data
* @return array
*/
public function addCouponType($data)
{
//只要创建了就是进行中
$data[ 'status' ] = 1;
$data[ 'create_time' ] = time();
//获取商品id
if ($data[ 'goods_type' ] == 1) {//全部商品参与
$data[ 'goods_ids' ] = '';
}
$data[ 'goods_ids' ] = ',' . $data[ 'goods_ids' ] . ',';
$res = model('promotion_coupon_type')->add($data);
if ($data[ 'validity_type' ] == 0) {
$cron = new Cron();
$cron->addCron(1, 1, '优惠券活动定时结束', 'CronCouponTypeEnd', $data[ 'end_time' ], $res);
}
$this->qrcode($res, 'all', $data[ 'site_id' ]);
return $this->success($res);
}
/**
* 编辑优惠券活动
* @param $data
* @param $coupon_type_id
* @return array
*/
public function editCouponType($data, $coupon_type_id)
{
$data[ 'update_time' ] = time();
//获取商品id
if ($data[ 'goods_type' ] == 1) {//全部商品参与
$data[ 'goods_ids' ] = '';
}
$coupon_info = model('promotion_coupon_type')->getInfo([ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
if (!empty($coupon_info[ 'image' ]) && !empty($data[ 'image' ]) && $coupon_info[ 'image' ] != $data[ 'image' ]) {
$upload_model = new Upload();
$upload_model->deletePic($coupon_info[ 'image' ], $coupon_info[ 'site_id' ]);
}
$data[ 'goods_ids' ] = ',' . $data[ 'goods_ids' ] . ',';
$res = model('promotion_coupon_type')->update($data, [ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
model('promotion_coupon')->update([ 'goods_ids' => $data[ 'goods_ids' ], 'goods_type' => $data[ 'goods_type' ] ], [ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'state', '=', 1 ] ]);
$cron = new Cron();
$cron->deleteCron([ [ 'event', '=', 'CronCouponTypeEnd' ], [ 'relate_id', '=', $coupon_type_id ] ]);
if ($data[ 'validity_type' ] == 0) {
$cron->addCron(1, 1, '优惠券活动定时结束', 'CronCouponTypeEnd', $data[ 'end_time' ], $coupon_type_id);
}
return $this->success($res);
}
/**
* 关闭优惠券
* @param $coupon_type_id
* @param $site_id
* @return array
*/
public function closeCouponType($coupon_type_id, $site_id)
{
$res = model('promotion_coupon_type')->update([ 'status' => -1 ], [ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'site_id', '=', $site_id ] ]);
// if ($res) {
// model("promotion_coupon")->update(['state' => 3], [['coupon_type_id', '=', $coupon_type_id], ['site_id', '=', $site_id]]);
// }
$cron = new Cron();
$cron->deleteCron([ [ 'event', '=', 'CronCouponTypeEnd' ], [ 'relate_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
/**
* 删除优惠券活动
* @param $coupon_type_id
* @param $site_id
* @return array
*/
public function deleteCouponType($coupon_type_id, $site_id)
{
$coupon_info = model('promotion_coupon_type')->getInfo([ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
if ($coupon_info['status'] == 1) return $this->error('', '进行中的优惠卷无法删除,请先关闭');
if (!empty($coupon_info[ 'image' ])) {
$upload_model = new Upload();
$upload_model->deletePic($coupon_info[ 'image' ], $coupon_info[ 'site_id' ]);
}
$res = model('promotion_coupon_type')->delete([ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'site_id', '=', $site_id ] ]);
if ($res) {
model('promotion_coupon')->delete([ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
}
$cron = new Cron();
$cron->deleteCron([ [ 'event', '=', 'CronCouponTypeEnd' ], [ 'relate_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
/**
* 获取优惠券活动详情
* @param $coupon_type_id
* @param $site_id
* @return array
*/
public function getCouponTypeInfo($coupon_type_id, $site_id)
{
$res = model('promotion_coupon_type')->getList([ [ 'coupon_type_id', 'in', $coupon_type_id ], [ 'site_id', '=', $site_id ] ]);
if (!empty($res)) {
foreach ($res as $k => $v) {
if ($v[ 'goods_type' ] == 2 || $v[ 'goods_type' ] == 3) {
$field[ $k ] = 'goods_id,goods_name,FLOOR(goods_stock) as goods_stock,goods_image,price,sort';
$goods_ids[ $k ] = substr($v[ 'goods_ids' ], '1', '-1');
$goods_list[ $k ] = model('goods')->getList([ [ 'goods_id', 'in', $goods_ids[ $k ] ] ], $field[ $k ]);
}
$res[ $k ][ 'goods_list' ] = $goods_list[$k] ?? [];
$res[ $k ][ 'goods_list_count' ] = count($res[ $k ][ 'goods_list' ]);
}
}
return $this->success($res);
}
/**
* 获取优惠券活动信息
* @param array $where
* @param bool $field
* @param string $alias
* @param null $join
* @param null $data
* @return array
*/
public function getInfo($where = [], $field = true, $alias = 'a', $join = null, $data = null)
{
$res = model('promotion_coupon_type')->getInfo($where, $field, $alias, $join, $data);
return $this->success($res);
}
/**
* 获取优惠券类型列表
* @param array $condition
* @param string $field
* @param string $order
* @param null $limit
* @return array
*/
public function getCouponTypeList($condition = [], $field = '*', $order = 'create_time desc', $limit = null)
{
$res = model('promotion_coupon_type')->getList($condition, $field, $order, '', '', '', $limit);
return $this->success($res);
}
/**
* 获取优惠券活动分页列表
* @param array $condition
* @param int $page
* @param int $page_size
* @param string $order
* @param string $field
* @return array
*/
public function getCouponTypePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
{
$condition[] = [ 'promotion_type', '=', 0 ];
$list = model('promotion_coupon_type')->pageList($condition, $field, $order, $page, $page_size);
return $this->success($list);
}
/**
* 排序
* @param $coupon_type_id
* @param $sort
* @return array
*/
public function couponSort($coupon_type_id, $sort)
{
$res = model('promotion_coupon_type')->update([ 'sort' => $sort ], [ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
/**
* 生成优惠券二维码
* @param $coupon_type_id
* @param string $app_type all为全部
* @param string $type 类型 create创建 get获取
* @return mixed|array
*/
public function qrcode($coupon_type_id, $app_type, $site_id, $type = 'create')
{
$res = event('Qrcode', [
'site_id' => $site_id,
'app_type' => $app_type,
'type' => $type,
'data' => [
'coupon_type_id' => $coupon_type_id
],
'page' => '/pages_tool/goods/coupon_receive',
'qrcode_path' => 'upload/qrcode/coupon',
'qrcode_name' => 'coupon_type_code_' . $coupon_type_id . '_' . $site_id,
], true);
return $res;
}
/**
* 优惠券定时结束
* @param $coupon_type_id
* @return array
*/
public function couponCronEnd($coupon_type_id)
{
$res = model('promotion_coupon_type')->update([ 'status' => 2 ], [ [ 'coupon_type_id', '=', $coupon_type_id ] ]);
return $this->success($res);
}
public function spread($coupon_type_id, $name, $site_id, $type = 'create')
{
$data = [
'site_id' => $site_id,
'app_type' => 'all', // all为全部
'type' => $type, // 类型 create创建 get获取
'data' => [
'coupon_type_id' => $coupon_type_id
],
'page' => '/pages_tool/goods/coupon_receive',
'qrcode_path' => 'upload/qrcode/coupon',
'qrcode_name' => 'coupon_type_code_' . $coupon_type_id . '_' . $site_id,
];
event('Qrcode', $data, true);
$app_type_list = config('app_type');
$path = [];
foreach ($app_type_list as $k => $v) {
switch ( $k ) {
case 'h5':
$wap_domain = getH5Domain();
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ] . '?coupon_type_id=' . $coupon_type_id;
$path[ $k ][ 'img' ] = 'upload/qrcode/coupon/coupon_type_code_' . $coupon_type_id . '_' . $site_id . '_' . $k . '.png';
break;
case 'weapp' :
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
if (!empty($res[ 'data' ])) {
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信小程序';
} else {
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
}
} else {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信小程序';
}
break;
case 'wechat' :
$config = new ConfigModel();
$res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
if (!empty($res[ 'data' ])) {
if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信公众号';
} else {
$path[ $k ][ 'status' ] = 1;
$path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
}
} else {
$path[ $k ][ 'status' ] = 2;
$path[ $k ][ 'message' ] = '未配置微信公众号';
}
break;
}
}
$return = [
'path' => $path,
'name' => $name,
];
return $this->success($return);
}
public function urlQrcode($page, $qrcode_param, $promotion_type, $app_type, $site_id)
{
$params = [
'site_id' => $site_id,
'data' => $qrcode_param,
'page' => $page,
'promotion_type' => $promotion_type,
'app_type' => $app_type,
'h5_path' => $page . '?coupon_type_id=' . $qrcode_param[ 'coupon_type_id' ],
'qrcode_path' => 'upload/qrcode/coupon',
'qrcode_name' => 'coupon_type_code_' . $promotion_type . '_' . $qrcode_param[ 'coupon_type_id' ] . '_' . $site_id,
];
$solitaire = event('PromotionQrcode', $params, true);
return $this->success($solitaire);
}
}

View File

@@ -1,243 +1,235 @@
<?php
/**
*/
namespace addon\coupon\model;
use addon\coupon\dict\CouponDict;
use app\model\BaseModel;
/**
* 优惠券
*/
class MemberCoupon extends BaseModel
{
/**
* 获取会员已领取优惠券
* @param $member_id
* @param $state
* @param int $site_id
* @param string $order
* @return array
*/
public function getMemberCouponList($member_id, $state, $site_id = 0, $order = "fetch_time desc")
{
$condition = array (
[ "member_id", "=", $member_id ],
[ "state", "=", $state ],
);
if ($site_id > 0) {
$condition[] = [ "site_id", "=", $site_id ];
}
$list = model("promotion_coupon")->getList($condition, "*", $order, '', '', '', 0);
return $this->success($list);
}
/**
* 使用优惠券
* @param $coupon_id
* @param $member_id
* @param int $order_id
* @return array
*/
public function useMemberCoupon($coupon_id, $member_id, $order_id = 0)
{
//优惠券处理方案
$result = model('promotion_coupon')->update([ 'use_order_id' => $order_id, 'state' => 2, 'use_time' => time() ], [ [ 'coupon_id', '=', $coupon_id ], [ "member_id", "=", $member_id ], [ 'state', '=', 1 ] ]);
if ($result === false) {
return $this->error();
}
return $this->success();
}
/**
* 获取会员已领取优惠券数量
* @param $member_id
* @param $state
* @param int $site_id
* @return array
*/
public function getMemberCouponNum($member_id, $state, $site_id = 0)
{
$condition = array (
[ "member_id", "=", $member_id ],
[ "state", "=", $state ],
);
if ($site_id > 0) {
$condition[] = [ "site_id", "=", $site_id ];
}
$num = model("promotion_coupon")->getCount($condition);
return $this->success($num);
}
/**
* 会员是否可领取该优惠券
* @param $coupon_type_id
* @param $member_id
* @return array
*/
public function receivedNum($coupon_type_id, $member_id)
{
$received_num = model('promotion_coupon')->getCount([ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'member_id', '=', $member_id ] ]);
return $this->success($received_num);
}
/**
* 获取编码
*/
public function getCode()
{
return random_keys(8);
}
/**
* 会员批量发放优惠券
* @param $coupon_type_ids
* @param $site_id
* @param $member_id
* @param int $get_type
* @param int $is_stock
* @param int $related_id
* @return array
*/
public function sendCoupon($coupon_type_ids, $site_id, $member_id, $get_type = 4, $is_stock = 0, $related_id = 0)
{
//已选优惠券提交数组
if (!empty($coupon_type_ids)) {
$res = 0;
foreach ($coupon_type_ids as $coupon_type_id) {
$coupon_type_info = model('promotion_coupon_type')->getInfo([ 'coupon_type_id' => $coupon_type_id, 'site_id' => $site_id, 'status' => 1 ]);
if (!empty($coupon_type_info)) {
if ($coupon_type_info[ 'count' ] != -1 || $is_stock == 0) {
if ($coupon_type_info[ 'count' ] == $coupon_type_info[ 'lead_count' ]) {
return $this->error('', '来迟了该优惠券已被领取完了');
}
}
if ($coupon_type_info[ 'max_fetch' ] != 0 && $get_type == 2) {
//限制领取
$member_receive_num = model('promotion_coupon')->getCount([
'coupon_type_id' => $coupon_type_id,
'member_id' => $member_id,
'get_type' => 2
]);
if ($member_receive_num >= $coupon_type_info[ 'max_fetch' ] ) {
return $this->error('', '该优惠券领取已达到上限');
}
}
$data = [
'coupon_type_id' => $coupon_type_id,
'site_id' => $site_id,
'coupon_code' => $this->getCode(),
'member_id' => $member_id,
'money' => $coupon_type_info[ 'money' ],
'state' => 1,
'get_type' => $get_type,
'goods_type' => $coupon_type_info[ 'goods_type' ],
'fetch_time' => time(),
'coupon_name' => $coupon_type_info[ 'coupon_name' ],
'at_least' => $coupon_type_info[ 'at_least' ],
'type' => $coupon_type_info[ 'type' ],
'discount' => $coupon_type_info[ 'discount' ],
'discount_limit' => $coupon_type_info[ 'discount_limit' ],
'goods_ids' => $coupon_type_info[ 'goods_ids' ],
'related_id' => $related_id
];
if ($coupon_type_info[ 'validity_type' ] == 0) {
$data[ 'end_time' ] = $coupon_type_info[ 'end_time' ];
} elseif ($coupon_type_info[ 'validity_type' ] == 1) {
$data[ 'end_time' ] = ( time() + $coupon_type_info[ 'fixed_term' ] * 86400 );
}
$res = model('promotion_coupon')->add($data);
if ($is_stock == 0) {
model('promotion_coupon_type')->setInc([ [ 'coupon_type_id', '=', $coupon_type_id ] ], 'lead_count');
}
}
}
if ($res) {
return $this->success($res);
} else {
return $this->error();
}
} else {
return $this->error();
}
}
/**
* 回收优惠券
* @param array $coupon_list
* @param $site_id
* @return array
*/
public function recoveryCoupon(array $coupon_list, $site_id)
{
$coupon = [];
foreach ($coupon_list as $coupon_item) {
if (isset($coupon[ $coupon_item[ 'coupon_type_id' ] ])) {
$coupon[$coupon_item['coupon_type_id']][] = $coupon_item['coupon_id'];
} else {
$coupon[ $coupon_item[ 'coupon_type_id' ] ] = [ $coupon_item[ 'coupon_id' ] ];
}
}
if (!count($coupon)) return $this->error();
model('promotion_coupon')->startTrans();
try {
foreach ($coupon as $coupon_type_id => $coupon_ids) {
$num = model('promotion_coupon')->delete([ [ 'coupon_id', 'in', $coupon_ids ], [ 'site_id', '=', $site_id ], [ 'state', '=', 1 ] ]);
if ($num) model('promotion_coupon_type')->setDec([ [ 'coupon_type_id', '=', $coupon_type_id ] ], 'lead_count', $num);
}
model('promotion_coupon')->commit();
return $this->success();
} catch (\Exception $e) {
model('promotion_coupon')->rollback();
return $this->error('', '回收失败');
}
}
/**
* 专用于撤回活动赠送的优惠券
* @return void
*/
public function cancelByPromotion($data){
$member_id = $data['member_id'];
$coupon_data = $data['coupon_data'];//优惠券id相关项
$coupon_ids = array_column($coupon_data, 'coupon_type_id');
$member_coupon_list = model('promotion_coupon')->getList([
['member_id', '=', $member_id],
['coupon_type_id', 'in', $coupon_ids],
['state', '=', CouponDict::normal]
], '*');
$member_coupon_type_group_list = [];
foreach($member_coupon_list as $v){
$member_coupon_type_group_list[$v['coupon_type_id']][] = $v['coupon_id'];
}
$cancel_ids = [];
foreach ($coupon_data as $item) {
$coupon_type_id = $item['coupon_type_id'];
$num = $item['num'];
$item_coupon_type_group = $member_coupon_type_group_list[$coupon_type_id] ?? [];
if($item_coupon_type_group){
if(count($item_coupon_type_group) > $num){
$cancel_ids = array_merge($cancel_ids, array_slice($item_coupon_type_group, 0, $num));
}else{
$cancel_ids = array_merge($cancel_ids, $item_coupon_type_group);
}
}
}
model('promotion_coupon')->update(['state' => CouponDict::close], [['coupon_id', 'in', $cancel_ids]]);
return $this->success();
}
<?php
namespace addon\coupon\model;
use addon\coupon\dict\CouponDict;
use app\model\BaseModel;
/**
* 优惠券
*/
class MemberCoupon extends BaseModel
{
/**
* 获取会员已领取优惠券
* @param $member_id
* @param $state
* @param int $site_id
* @param string $order
* @return array
*/
public function getMemberCouponList($member_id, $state, $site_id = 0, $order = "fetch_time desc")
{
$condition = array (
[ "member_id", "=", $member_id ],
[ "state", "=", $state ],
);
if ($site_id > 0) {
$condition[] = [ "site_id", "=", $site_id ];
}
$list = model("promotion_coupon")->getList($condition, "*", $order, '', '', '', 0);
return $this->success($list);
}
/**
* 使用优惠券
* @param $coupon_id
* @param $member_id
* @param int $order_id
* @return array
*/
public function useMemberCoupon($coupon_id, $member_id, $order_id = 0)
{
//优惠券处理方案
$result = model('promotion_coupon')->update([ 'use_order_id' => $order_id, 'state' => 2, 'use_time' => time() ], [ [ 'coupon_id', '=', $coupon_id ], [ "member_id", "=", $member_id ], [ 'state', '=', 1 ] ]);
if ($result === false) {
return $this->error();
}
return $this->success();
}
/**
* 获取会员已领取优惠券数量
* @param $member_id
* @param $state
* @param int $site_id
* @return array
*/
public function getMemberCouponNum($member_id, $state, $site_id = 0)
{
$condition = array (
[ "member_id", "=", $member_id ],
[ "state", "=", $state ],
);
if ($site_id > 0) {
$condition[] = [ "site_id", "=", $site_id ];
}
$num = model("promotion_coupon")->getCount($condition);
return $this->success($num);
}
/**
* 会员是否可领取该优惠券
* @param $coupon_type_id
* @param $member_id
* @return array
*/
public function receivedNum($coupon_type_id, $member_id)
{
$received_num = model('promotion_coupon')->getCount([ [ 'coupon_type_id', '=', $coupon_type_id ], [ 'member_id', '=', $member_id ] ]);
return $this->success($received_num);
}
/**
* 获取编码
*/
public function getCode()
{
return random_keys(8);
}
/**
* 会员批量发放优惠券
* @param $coupon_type_ids
* @param $site_id
* @param $member_id
* @param int $get_type
* @param int $is_stock
* @param int $related_id
* @return array
*/
public function sendCoupon($coupon_type_ids, $site_id, $member_id, $get_type = 4, $is_stock = 0, $related_id = 0)
{
//已选优惠券提交数组
if (!empty($coupon_type_ids)) {
$res = 0;
foreach ($coupon_type_ids as $coupon_type_id) {
$coupon_type_info = model('promotion_coupon_type')->getInfo([ 'coupon_type_id' => $coupon_type_id, 'site_id' => $site_id, 'status' => 1 ]);
if (!empty($coupon_type_info)) {
if ($coupon_type_info[ 'count' ] != -1 || $is_stock == 0) {
if ($coupon_type_info[ 'count' ] == $coupon_type_info[ 'lead_count' ]) {
return $this->error('', '来迟了该优惠券已被领取完了');
}
}
if ($coupon_type_info[ 'max_fetch' ] != 0 && $get_type == 2) {
//限制领取
$member_receive_num = model('promotion_coupon')->getCount([
'coupon_type_id' => $coupon_type_id,
'member_id' => $member_id,
'get_type' => 2
]);
if ($member_receive_num >= $coupon_type_info[ 'max_fetch' ] ) {
return $this->error('', '该优惠券领取已达到上限');
}
}
$data = [
'coupon_type_id' => $coupon_type_id,
'site_id' => $site_id,
'coupon_code' => $this->getCode(),
'member_id' => $member_id,
'money' => $coupon_type_info[ 'money' ],
'state' => 1,
'get_type' => $get_type,
'goods_type' => $coupon_type_info[ 'goods_type' ],
'fetch_time' => time(),
'coupon_name' => $coupon_type_info[ 'coupon_name' ],
'at_least' => $coupon_type_info[ 'at_least' ],
'type' => $coupon_type_info[ 'type' ],
'discount' => $coupon_type_info[ 'discount' ],
'discount_limit' => $coupon_type_info[ 'discount_limit' ],
'goods_ids' => $coupon_type_info[ 'goods_ids' ],
'related_id' => $related_id
];
if ($coupon_type_info[ 'validity_type' ] == 0) {
$data[ 'end_time' ] = $coupon_type_info[ 'end_time' ];
} elseif ($coupon_type_info[ 'validity_type' ] == 1) {
$data[ 'end_time' ] = ( time() + $coupon_type_info[ 'fixed_term' ] * 86400 );
}
$res = model('promotion_coupon')->add($data);
if ($is_stock == 0) {
model('promotion_coupon_type')->setInc([ [ 'coupon_type_id', '=', $coupon_type_id ] ], 'lead_count');
}
}
}
if ($res) {
return $this->success($res);
} else {
return $this->error();
}
} else {
return $this->error();
}
}
/**
* 回收优惠券
* @param array $coupon_list
* @param $site_id
* @return array
*/
public function recoveryCoupon(array $coupon_list, $site_id)
{
$coupon = [];
foreach ($coupon_list as $coupon_item) {
if (isset($coupon[ $coupon_item[ 'coupon_type_id' ] ])) {
$coupon[$coupon_item['coupon_type_id']][] = $coupon_item['coupon_id'];
} else {
$coupon[ $coupon_item[ 'coupon_type_id' ] ] = [ $coupon_item[ 'coupon_id' ] ];
}
}
if (!count($coupon)) return $this->error();
model('promotion_coupon')->startTrans();
try {
foreach ($coupon as $coupon_type_id => $coupon_ids) {
$num = model('promotion_coupon')->delete([ [ 'coupon_id', 'in', $coupon_ids ], [ 'site_id', '=', $site_id ], [ 'state', '=', 1 ] ]);
if ($num) model('promotion_coupon_type')->setDec([ [ 'coupon_type_id', '=', $coupon_type_id ] ], 'lead_count', $num);
}
model('promotion_coupon')->commit();
return $this->success();
} catch (\Exception $e) {
model('promotion_coupon')->rollback();
return $this->error('', '回收失败');
}
}
/**
* 专用于撤回活动赠送的优惠券
* @return void
*/
public function cancelByPromotion($data){
$member_id = $data['member_id'];
$coupon_data = $data['coupon_data'];//优惠券id相关项
$coupon_ids = array_column($coupon_data, 'coupon_type_id');
$member_coupon_list = model('promotion_coupon')->getList([
['member_id', '=', $member_id],
['coupon_type_id', 'in', $coupon_ids],
['state', '=', CouponDict::normal]
], '*');
$member_coupon_type_group_list = [];
foreach($member_coupon_list as $v){
$member_coupon_type_group_list[$v['coupon_type_id']][] = $v['coupon_id'];
}
$cancel_ids = [];
foreach ($coupon_data as $item) {
$coupon_type_id = $item['coupon_type_id'];
$num = $item['num'];
$item_coupon_type_group = $member_coupon_type_group_list[$coupon_type_id] ?? [];
if($item_coupon_type_group){
if(count($item_coupon_type_group) > $num){
$cancel_ids = array_merge($cancel_ids, array_slice($item_coupon_type_group, 0, $num));
}else{
$cancel_ids = array_merge($cancel_ids, $item_coupon_type_group);
}
}
}
model('promotion_coupon')->update(['state' => CouponDict::close], [['coupon_id', 'in', $cancel_ids]]);
return $this->success();
}
}

View File

@@ -1,103 +1,94 @@
<?php
/**
*/
namespace addon\coupon\model\share;
use app\model\share\WchatShareBase as BaseModel;
use app\model\system\Config as ConfigModel;
use app\model\system\Site as SiteModel;
/**
* 分享
*/
class WchatShare extends BaseModel
{
protected $config = [
[
'title' => '领券中心',
'config_key' => 'WCHAT_SHARE_CONFIG_COUPON_LIST',
'path' => [ '/pages_tool/goods/coupon' ],
'method_prefix' => 'couponList',
],
];
/**
* 商品列表分享数据
* @param $param
* @return array
*/
protected function couponListShareData($param)
{
$site_id = $param[ 'site_id' ] ?? 0;
//站点设置
$site_model = new SiteModel();
$site_info = $site_model->getSiteInfo([ [ 'site_id', '=', $site_id ] ])[ 'data' ];
//跳转路径
$link = $this->getShareLink($param);
//获取和替换配置数据
$config_method = preg_replace('/Data$/', 'Config', __FUNCTION__);
$config_data = $this->$config_method($param);
$title = $config_data[ 'value' ][ 'title' ];
$desc = $config_data[ 'value' ][ 'desc' ];
$image_url = $config_data[ 'value' ][ 'imgUrl' ] ?: $site_info[ 'logo_square' ];
$data = [
'title' => $title,
'desc' => $desc,
'link' => $link,
'imgUrl' => $image_url,
];
return [
'permission' => [
'hideOptionMenu' => false,
'hideMenuItems' => [],
],
'data' => $data,//分享内容
];
}
/**
* 商品列表分享配置
* @param $param
* @return array
*/
protected function couponListShareConfig($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/coupon/icon.png');
}
$variable = [];
return [
'value' => $data[ 'value' ],
'variable' => $variable,
];
}
}
<?php
namespace addon\coupon\model\share;
use app\model\share\WchatShareBase as BaseModel;
use app\model\system\Config as ConfigModel;
use app\model\system\Site as SiteModel;
/**
* 分享
*/
class WchatShare extends BaseModel
{
protected $config = [
[
'title' => '领券中心',
'config_key' => 'WCHAT_SHARE_CONFIG_COUPON_LIST',
'path' => [ '/pages_tool/goods/coupon' ],
'method_prefix' => 'couponList',
],
];
/**
* 商品列表分享数据
* @param $param
* @return array
*/
protected function couponListShareData($param)
{
$site_id = $param[ 'site_id' ] ?? 0;
//站点设置
$site_model = new SiteModel();
$site_info = $site_model->getSiteInfo([ [ 'site_id', '=', $site_id ] ])[ 'data' ];
//跳转路径
$link = $this->getShareLink($param);
//获取和替换配置数据
$config_method = preg_replace('/Data$/', 'Config', __FUNCTION__);
$config_data = $this->$config_method($param);
$title = $config_data[ 'value' ][ 'title' ];
$desc = $config_data[ 'value' ][ 'desc' ];
$image_url = $config_data[ 'value' ][ 'imgUrl' ] ?: $site_info[ 'logo_square' ];
$data = [
'title' => $title,
'desc' => $desc,
'link' => $link,
'imgUrl' => $image_url,
];
return [
'permission' => [
'hideOptionMenu' => false,
'hideMenuItems' => [],
],
'data' => $data,//分享内容
];
}
/**
* 商品列表分享配置
* @param $param
* @return array
*/
protected function couponListShareConfig($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/coupon/icon.png');
}
$variable = [];
return [
'value' => $data[ 'value' ],
'variable' => $variable,
];
}
}

View File

@@ -1,91 +1,82 @@
<?php
/**
*/
namespace addon\coupon\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_COUPON_LIST',
'path' => [ '/pages_tool/goods/coupon' ],
'method_prefix' => 'couponList',
],
];
protected $sort = 2;
/***************************** 领券中心 ***************************/
/**
* 首页分享数据
* @param $param
* @return array
*/
protected function couponListShareData($param)
{
//获取和替换配置数据
$config_data = $this->couponListShareConfig($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 couponListShareConfig($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,
];
}
}
<?php
namespace addon\coupon\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_COUPON_LIST',
'path' => [ '/pages_tool/goods/coupon' ],
'method_prefix' => 'couponList',
],
];
protected $sort = 2;
/***************************** 领券中心 ***************************/
/**
* 首页分享数据
* @param $param
* @return array
*/
protected function couponListShareData($param)
{
//获取和替换配置数据
$config_data = $this->couponListShareConfig($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 couponListShareConfig($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,
];
}
}