增加核销券的功能
This commit is contained in:
parent
cc882b1b33
commit
e0f3665d26
|
|
@ -38,6 +38,10 @@ class AgentDao extends BaseDao{
|
|||
->when(isset($params['agent_type']) && $params['agent_type'] !== '',function($query) use ($params){
|
||||
$query->where('agent_type', (int)$params['agent_type']);
|
||||
})
|
||||
->when(isset($params['is_invite_supplier']) && $params['is_invite_supplier'] !== '',function($query) use ($params){
|
||||
// 仅获取拥有【供应商】邀请权限的代理人员 类型:1=发起人,2=省公司,3=省合伙人(外勤),4=省合伙人(内勤),5=区县运营商
|
||||
$query->whereIn('agent_type',[1,2,3,4,5]);
|
||||
})
|
||||
->with([
|
||||
'user' => function($query){
|
||||
$query->field('uid,nickname,avatar');
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ class StoreCouponRepository extends BaseRepository
|
|||
//平台跨店券
|
||||
const TYPE_PLATFORM_STORE = 12;
|
||||
|
||||
const TYPE_PLATFORM_WRITE = 13;
|
||||
|
||||
//获取方式
|
||||
const GET_COUPON_TYPE_RECEIVE = 0;
|
||||
//消费满赠
|
||||
|
|
@ -382,6 +384,7 @@ class StoreCouponRepository extends BaseRepository
|
|||
['value' => self::TYPE_PLATFORM_ALL, 'label' => '通用券'],
|
||||
['value' => self::TYPE_PLATFORM_CATE, 'label' => '品类券'],
|
||||
['value' => self::TYPE_PLATFORM_STORE, 'label' => '跨店券'],
|
||||
['value' => self::TYPE_PLATFORM_WRITE, 'label' => '核销券'],
|
||||
])->control([
|
||||
[
|
||||
'value' => self::TYPE_PLATFORM_CATE,
|
||||
|
|
@ -430,8 +433,12 @@ class StoreCouponRepository extends BaseRepository
|
|||
]
|
||||
],
|
||||
]),
|
||||
|
||||
|
||||
]
|
||||
],
|
||||
[
|
||||
'value' => self::TYPE_PLATFORM_WRITE,
|
||||
'rule' => [
|
||||
Elm::textarea('description', '使用说明'),
|
||||
]
|
||||
],
|
||||
]),
|
||||
|
|
@ -519,7 +526,6 @@ class StoreCouponRepository extends BaseRepository
|
|||
])->setTitle('发布优惠券');
|
||||
}
|
||||
|
||||
|
||||
public function create($data)
|
||||
{
|
||||
if (isset($data['total_count'])) $data['remain_count'] = $data['total_count'];
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use app\common\dao\BaseDao;
|
|||
use app\common\dao\system\groupData\GroupDataDao;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\product\ProductLabelRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\StoreCategoryRepository;
|
||||
use FormBuilder\Exception\FormBuilderException;
|
||||
use FormBuilder\Factory\Elm;
|
||||
|
|
@ -380,6 +381,9 @@ class GroupDataRepository extends BaseRepository
|
|||
'innerHTML' => '试用期每个用户只能购买一次,购买过付费会员之后将不在展示,不可购买',
|
||||
]
|
||||
]),
|
||||
Elm::select('coupon', '优惠券')->options(function () {
|
||||
return app()->make(StoreCouponRepository::class)->getSearch(['mer_id' => request()->merId(), 'status' => 1, 'send_type' => 5])->column('title as label,coupon_id as value');
|
||||
})->multiple(true)->filterable(true)->appendValidate(Elm::validateArr()->message('请选择优惠券')),
|
||||
Elm::number('cost_price','原价')->required()->col(12)->min(0),
|
||||
Elm::number('price','优惠价')->required()->col(12)->min(0),
|
||||
Elm::number('sort','排序')->col(12)->min(0),
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Agent extends BaseController{
|
|||
*/
|
||||
public function agentList(){
|
||||
[$page, $limit] = $this->getPage();
|
||||
$params = $this->request->params(['uid','agent_type','contact_name','contact_phone']);
|
||||
$params = $this->request->params(['uid','agent_type','contact_name','contact_phone','is_invite_supplier']);
|
||||
$data = app()->make(AgentRepository::class)->getList((array)$params,(int)$page,(int)$limit);
|
||||
|
||||
return app('json')->success($data);
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class Coupon extends BaseController
|
|||
} else unset($data['use_start_time']);
|
||||
unset($data['range_date']);
|
||||
if ($data['is_limited'] == 0) $data['total_count'] = 0;
|
||||
if (!in_array($data['type'], [10, 11, 12])) {
|
||||
if (!in_array($data['type'], [10, 11, 12, 13])) {
|
||||
throw new ValidateException('请选择有效的优惠券类型');
|
||||
}
|
||||
return $data;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ return [
|
|||
// 会员卡开通 支付成功
|
||||
'user.vipPay' => [
|
||||
// 酒卡额度相关处理
|
||||
'app\listener\exchangeQuota\OrderVipPayEvent'
|
||||
'app\listener\exchangeQuota\OrderVipPayEvent',
|
||||
//开卡成功送优惠券
|
||||
'app\listener\giveCoupon\CardOpeningEvent',
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace app\listener\giveCoupon;
|
||||
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use think\facade\Log;
|
||||
|
||||
class CardOpeningEvent
|
||||
{
|
||||
public function handle($data)
|
||||
{
|
||||
try {
|
||||
$order = $data[0] ?? [];
|
||||
$vipInfo = json_decode($order->order_info, TRUE);
|
||||
|
||||
// 会员卡开通成功 - 赠送优惠券
|
||||
$coupon = (array)$vipInfo['coupon'] ?? [];
|
||||
if(count($coupon) > 0){
|
||||
|
||||
$StoreCouponRepository = app()->make(StoreCouponRepository::class);
|
||||
foreach ($coupon as $val){
|
||||
$StoreCouponRepository->receiveSvipCounpon($val, $order['uid']);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::info('会员卡开通成功 - 错误: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -21,7 +21,7 @@ class StoreCouponValidate extends Validate
|
|||
'use_start_time|有效期限' => 'requireIf:coupon_type,1|array|>:2',
|
||||
'sort|排序' => 'require|integer',
|
||||
'status|状态' => 'require|in:0,1',
|
||||
'type|优惠券类型' => 'require|in:0,1,10,11,12',
|
||||
'type|优惠券类型' => 'require|in:0,1,10,11,12,13',
|
||||
'product_id|商品' => 'requireIf:type,1|array|>:0',
|
||||
'send_type|类型' => 'require|in:0,1,2,3,4,5',
|
||||
'full_reduction|满赠金额' => 'requireIf:send_type,1|float|>=:0',
|
||||
|
|
|
|||
Loading…
Reference in New Issue