6 Commits
v1.2 ... master

Author SHA1 Message Date
dd133b2266 调整可用券数量校验 2021-01-25 08:53:18 +08:00
8dc55beb74 增加核销途径 2021-01-22 16:16:03 +08:00
70d4278071 增加校验 2020-12-07 10:56:03 +08:00
2e8bc33d99 增加限制 2020-12-07 10:17:05 +08:00
5dc96a5cb1 修改UserController 2020-12-07 10:07:04 +08:00
6d7bfdd4f4 增加来源 2020-12-07 10:00:08 +08:00
14 changed files with 151 additions and 389 deletions

View File

@@ -32,7 +32,7 @@ class IndexController extends AdminController
/**
* Index interface.
* @param Content $content
* @param Content $content
* @return Content
*/
public function index(Content $content)
@@ -45,8 +45,8 @@ class IndexController extends AdminController
/**
* Edit interface.
* @param mixed $id
* @param Content $content
* @param mixed $id
* @param Content $content
* @return Content
*/
public function edit($id, Content $content)
@@ -59,7 +59,7 @@ class IndexController extends AdminController
/**
* Create interface.
* @param Content $content
* @param Content $content
* @return Content
*/
public function create(Content $content)
@@ -93,6 +93,8 @@ class IndexController extends AdminController
$filter->column(1 / 2, function ($filter) {
$filter->between('start_at', '开始时间')->datetime();
$filter->between('end_at', '结束时间')->datetime();
$filter->equal('channel', '核销途径')->select(Activity::CHANNELS);
});
});
@@ -101,12 +103,19 @@ class IndexController extends AdminController
$grid->column('title', '活动名称');
$grid->column('code', '活动编号');
$grid->column('total', '可发券总数');
$grid->column('coupons_count', '发券总数');
$grid->column('coupons_count', '发券总数');
$grid->column('rule.code', '卡券规则');
$grid->column('类型')->display(function () {
return $this->type_text;
});
$grid->column('channel', '核销途径')
->using(Activity::CHANNELS)
->label([
Activity::CHANNEL_YSD => 'info',
Activity::CHANNEL_UNION => 'success',
]);
$grid->column('days', '延期(天)');
$grid->column('rule.full', '满足金额');
$grid->column('rule.take', '扣除金额');
@@ -159,7 +168,7 @@ class IndexController extends AdminController
->required();
$form->number('total', '总数')
->help('可发券总数')
->help('可发券总数0为不限制')
->default(10000)
->required();
@@ -173,6 +182,12 @@ class IndexController extends AdminController
})
->required();
$form->radio('channel', '核销途径')
->options(Activity::CHANNELS)
->default(Activity::CHANNEL_YSD)
->help('券码核销的途径亿时代是自己核销银联是银联pos核销')
->required();
$form->switch('status', '状态')->default(1);
$form->switch('need_check', '多次校验')
->default(1)

View File

@@ -184,11 +184,20 @@ class UserController extends Controller
$total = $res['total'] ?? ''; //订单总额;
$outletId = $res['outletId'] ?? ''; //网点id;
$orderid = $res['orderid'] ?? ''; //订单id;
$from = $res['from'] ?? ''; //来源;
$redemptionCode = trim($redemptionCode);
$outletId = trim($outletId);
$coupon = Coupon::Redemption($this->user, $redemptionCode, $total, $outletId, $orderid);
$coupon = Coupon::Redemption(
$this->user,
$redemptionCode,
$total,
$outletId,
$orderid,
$from
);
if (is_string($coupon)) {
return $this->error($coupon, $log);
}

View File

@@ -10,6 +10,11 @@ class Activity extends Model
use BelongsToUser;
protected $dates = [
'start_at',
'end_at',
];
const TYPE_EXTEND = 1;
const TYPE_SCOPE = 2;
const TYPES = [
@@ -24,9 +29,11 @@ class Activity extends Model
self::STATUS_CLOSE => '关闭',
];
protected $dates = [
'start_at',
'end_at',
const CHANNEL_YSD = 1;
const CHANNEL_UNION = 2;
const CHANNELS = [
self::CHANNEL_YSD => '亿时代',
self::CHANNEL_UNION => '银联',
];
/**
@@ -51,7 +58,7 @@ class Activity extends Model
}
//活动状态
public function getStatusTextAttribute()
public function getStatusTextAttribute(): string
{
return self::STATUS[$this->status] ?? '未知';
}
@@ -100,7 +107,12 @@ class Activity extends Model
{
try {
$code = 'YSD' . date('ymd') . mt_rand(100000, 999999);
//判断生成何种码
if ($this->channel == self::CHANNEL_UNION) {
$code = '66406' . date('ymdH') . mt_rand(1000000, 9999999);
} else {
$code = 'YSD' . date('ymd') . mt_rand(100000, 999999);
}
if ($this->type == SELF::TYPE_EXTEND) {
$start_at = now();

9
bootstrap/cache/events.php vendored Normal file
View File

@@ -0,0 +1,9 @@
<?php return array (
'App\\Providers\\EventServiceProvider' =>
array (
'App\\Events\\ConponCallback' =>
array (
0 => 'App\\Listeners\\ConponCallbackListener',
),
),
);

View File

@@ -1,114 +0,0 @@
<?php return array (
'aslong/sms' =>
array (
'providers' =>
array (
0 => 'AsLong\\Sms\\ServiceProvider',
),
'aliases' =>
array (
'Sms' => 'AsLong\\Sms\\Facades\\Sms',
),
),
'encore/laravel-admin' =>
array (
'providers' =>
array (
0 => 'Encore\\Admin\\AdminServiceProvider',
),
'aliases' =>
array (
'Admin' => 'Encore\\Admin\\Facades\\Admin',
),
),
'facade/ignition' =>
array (
'providers' =>
array (
0 => 'Facade\\Ignition\\IgnitionServiceProvider',
),
'aliases' =>
array (
'Flare' => 'Facade\\Ignition\\Facades\\Flare',
),
),
'fideloper/proxy' =>
array (
'providers' =>
array (
0 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider',
),
),
'intervention/image' =>
array (
'providers' =>
array (
0 => 'Intervention\\Image\\ImageServiceProvider',
),
'aliases' =>
array (
'Image' => 'Intervention\\Image\\Facades\\Image',
),
),
'laravel-admin-ext/wang-editor' =>
array (
'providers' =>
array (
0 => 'Encore\\WangEditor\\WangEditorServiceProvider',
),
),
'laravel/tinker' =>
array (
'providers' =>
array (
0 => 'Laravel\\Tinker\\TinkerServiceProvider',
),
),
'maatwebsite/excel' =>
array (
'providers' =>
array (
0 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
),
'aliases' =>
array (
'Excel' => 'Maatwebsite\\Excel\\Facades\\Excel',
),
),
'nesbot/carbon' =>
array (
'providers' =>
array (
0 => 'Carbon\\Laravel\\ServiceProvider',
),
),
'nunomaduro/collision' =>
array (
'providers' =>
array (
0 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
),
),
'overtrue/laravel-wechat' =>
array (
'providers' =>
array (
0 => 'Overtrue\\LaravelWeChat\\ServiceProvider',
),
'aliases' =>
array (
'EasyWeChat' => 'Overtrue\\LaravelWeChat\\Facade',
),
),
'simplesoftwareio/simple-qrcode' =>
array (
'providers' =>
array (
0 => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider',
),
'aliases' =>
array (
'QrCode' => 'SimpleSoftwareIO\\QrCode\\Facades\\QrCode',
),
),
);

View File

@@ -1,222 +0,0 @@
<?php return array (
'providers' =>
array (
0 => 'Illuminate\\Auth\\AuthServiceProvider',
1 => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
2 => 'Illuminate\\Bus\\BusServiceProvider',
3 => 'Illuminate\\Cache\\CacheServiceProvider',
4 => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
5 => 'Illuminate\\Cookie\\CookieServiceProvider',
6 => 'Illuminate\\Database\\DatabaseServiceProvider',
7 => 'Illuminate\\Encryption\\EncryptionServiceProvider',
8 => 'Illuminate\\Filesystem\\FilesystemServiceProvider',
9 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider',
10 => 'Illuminate\\Hashing\\HashServiceProvider',
11 => 'Illuminate\\Mail\\MailServiceProvider',
12 => 'Illuminate\\Notifications\\NotificationServiceProvider',
13 => 'Illuminate\\Pagination\\PaginationServiceProvider',
14 => 'Illuminate\\Pipeline\\PipelineServiceProvider',
15 => 'Illuminate\\Queue\\QueueServiceProvider',
16 => 'Illuminate\\Redis\\RedisServiceProvider',
17 => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
18 => 'Illuminate\\Session\\SessionServiceProvider',
19 => 'Illuminate\\Translation\\TranslationServiceProvider',
20 => 'Illuminate\\Validation\\ValidationServiceProvider',
21 => 'Illuminate\\View\\ViewServiceProvider',
22 => 'AsLong\\Sms\\ServiceProvider',
23 => 'Encore\\Admin\\AdminServiceProvider',
24 => 'Facade\\Ignition\\IgnitionServiceProvider',
25 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider',
26 => 'Intervention\\Image\\ImageServiceProvider',
27 => 'Encore\\WangEditor\\WangEditorServiceProvider',
28 => 'Laravel\\Tinker\\TinkerServiceProvider',
29 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
30 => 'Carbon\\Laravel\\ServiceProvider',
31 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
32 => 'Overtrue\\LaravelWeChat\\ServiceProvider',
33 => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider',
34 => 'App\\Providers\\AppServiceProvider',
35 => 'App\\Providers\\AuthServiceProvider',
36 => 'App\\Providers\\EventServiceProvider',
37 => 'App\\Providers\\RouteServiceProvider',
38 => 'App\\Api\\ApiServiceProvider',
39 => 'App\\Merchant\\MerchantServiceProvider',
),
'eager' =>
array (
0 => 'Illuminate\\Auth\\AuthServiceProvider',
1 => 'Illuminate\\Cookie\\CookieServiceProvider',
2 => 'Illuminate\\Database\\DatabaseServiceProvider',
3 => 'Illuminate\\Encryption\\EncryptionServiceProvider',
4 => 'Illuminate\\Filesystem\\FilesystemServiceProvider',
5 => 'Illuminate\\Foundation\\Providers\\FoundationServiceProvider',
6 => 'Illuminate\\Notifications\\NotificationServiceProvider',
7 => 'Illuminate\\Pagination\\PaginationServiceProvider',
8 => 'Illuminate\\Session\\SessionServiceProvider',
9 => 'Illuminate\\View\\ViewServiceProvider',
10 => 'AsLong\\Sms\\ServiceProvider',
11 => 'Encore\\Admin\\AdminServiceProvider',
12 => 'Facade\\Ignition\\IgnitionServiceProvider',
13 => 'Fideloper\\Proxy\\TrustedProxyServiceProvider',
14 => 'Intervention\\Image\\ImageServiceProvider',
15 => 'Encore\\WangEditor\\WangEditorServiceProvider',
16 => 'Laravel\\Tinker\\TinkerServiceProvider',
17 => 'Maatwebsite\\Excel\\ExcelServiceProvider',
18 => 'Carbon\\Laravel\\ServiceProvider',
19 => 'NunoMaduro\\Collision\\Adapters\\Laravel\\CollisionServiceProvider',
20 => 'Overtrue\\LaravelWeChat\\ServiceProvider',
21 => 'SimpleSoftwareIO\\QrCode\\QrCodeServiceProvider',
22 => 'App\\Providers\\AppServiceProvider',
23 => 'App\\Providers\\AuthServiceProvider',
24 => 'App\\Providers\\EventServiceProvider',
25 => 'App\\Providers\\RouteServiceProvider',
26 => 'App\\Api\\ApiServiceProvider',
27 => 'App\\Merchant\\MerchantServiceProvider',
),
'deferred' =>
array (
'Illuminate\\Broadcasting\\BroadcastManager' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
'Illuminate\\Contracts\\Broadcasting\\Factory' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
'Illuminate\\Contracts\\Broadcasting\\Broadcaster' => 'Illuminate\\Broadcasting\\BroadcastServiceProvider',
'Illuminate\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
'Illuminate\\Contracts\\Bus\\Dispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
'Illuminate\\Contracts\\Bus\\QueueingDispatcher' => 'Illuminate\\Bus\\BusServiceProvider',
'cache' => 'Illuminate\\Cache\\CacheServiceProvider',
'cache.store' => 'Illuminate\\Cache\\CacheServiceProvider',
'cache.psr6' => 'Illuminate\\Cache\\CacheServiceProvider',
'memcached.connector' => 'Illuminate\\Cache\\CacheServiceProvider',
'command.cache.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.cache.forget' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.clear-compiled' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.auth.resets.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.config.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.config.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.db.wipe' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.down' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.environment' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.event.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.event.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.event.list' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.key.generate' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.optimize' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.optimize.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.package.discover' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.preset' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.failed' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.flush' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.forget' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.listen' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.restart' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.retry' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.work' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.route.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.route.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.route.list' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.seed' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleFinishCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'Illuminate\\Console\\Scheduling\\ScheduleRunCommand' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.storage.link' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.up' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.view.cache' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.view.clear' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.cache.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.channel.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.console.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.controller.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.event.generate' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.event.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.exception.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.factory.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.job.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.listener.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.mail.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.middleware.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.model.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.notification.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.notification.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.observer.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.policy.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.provider.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.failed-table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.queue.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.request.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.resource.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.rule.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.seeder.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.session.table' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.serve' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.test.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.vendor.publish' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'migrator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'migration.repository' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'migration.creator' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.fresh' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.install' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.refresh' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.reset' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.rollback' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.status' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'command.migrate.make' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'composer' => 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider',
'hash' => 'Illuminate\\Hashing\\HashServiceProvider',
'hash.driver' => 'Illuminate\\Hashing\\HashServiceProvider',
'mailer' => 'Illuminate\\Mail\\MailServiceProvider',
'swift.mailer' => 'Illuminate\\Mail\\MailServiceProvider',
'swift.transport' => 'Illuminate\\Mail\\MailServiceProvider',
'Illuminate\\Mail\\Markdown' => 'Illuminate\\Mail\\MailServiceProvider',
'Illuminate\\Contracts\\Pipeline\\Hub' => 'Illuminate\\Pipeline\\PipelineServiceProvider',
'queue' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.worker' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.listener' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.failer' => 'Illuminate\\Queue\\QueueServiceProvider',
'queue.connection' => 'Illuminate\\Queue\\QueueServiceProvider',
'redis' => 'Illuminate\\Redis\\RedisServiceProvider',
'redis.connection' => 'Illuminate\\Redis\\RedisServiceProvider',
'auth.password' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
'auth.password.broker' => 'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider',
'translator' => 'Illuminate\\Translation\\TranslationServiceProvider',
'translation.loader' => 'Illuminate\\Translation\\TranslationServiceProvider',
'validator' => 'Illuminate\\Validation\\ValidationServiceProvider',
'validation.presence' => 'Illuminate\\Validation\\ValidationServiceProvider',
),
'when' =>
array (
'Illuminate\\Broadcasting\\BroadcastServiceProvider' =>
array (
),
'Illuminate\\Bus\\BusServiceProvider' =>
array (
),
'Illuminate\\Cache\\CacheServiceProvider' =>
array (
),
'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider' =>
array (
),
'Illuminate\\Hashing\\HashServiceProvider' =>
array (
),
'Illuminate\\Mail\\MailServiceProvider' =>
array (
),
'Illuminate\\Pipeline\\PipelineServiceProvider' =>
array (
),
'Illuminate\\Queue\\QueueServiceProvider' =>
array (
),
'Illuminate\\Redis\\RedisServiceProvider' =>
array (
),
'Illuminate\\Auth\\Passwords\\PasswordResetServiceProvider' =>
array (
),
'Illuminate\\Translation\\TranslationServiceProvider' =>
array (
),
'Illuminate\\Validation\\ValidationServiceProvider' =>
array (
),
),
);

View File

@@ -46,4 +46,9 @@ return [
7 => '未激活',
],
'froms' => [
'bsshop',//本时商城
'bslive',//本时生活
],
];

View File

@@ -14,4 +14,8 @@ return [
],
],
'froms' => [
'bsshop',//本时商城
'bslive',//本时生活
],
];

View File

@@ -38,6 +38,9 @@ class Init
//查询到的卡券规则和商品id 只有平安券才有
public $queryData;
//来源
public $from;
//设置渠道
public function setUser($user)
{
@@ -99,14 +102,23 @@ class Init
}
//设置来源
public function setFrom($from)
{
$this->from = $from;
return $this;
}
/**
* Notes: 插入日志
* @Author: 玄尘
* @Date : 2020/6/30 10:29
* @param $url
* @param $method
* @param $params
* @param string $type
* @param $url
* @param $method
* @param $params
* @param string $type
* @return mixed
*/
public function createLog($url, $method, $params, $type = 'pingan')
@@ -139,38 +151,56 @@ class Init
//统一门店 相同金额 3分钟之内看作是一笔订单
public function CheckCount()
{
//排除来源
if (!empty($this->from) && in_array($this->from, config('xuanchen_coupon.froms'))) {
return true;
}
if ($this->queryData) {
if (isset($this->queryData['thirdPartyGoodsId']) && $this->queryData['thirdPartyGoodsId'] == 'YSD-full0-0') {
return true;
}
}
//已核销的券的满多少金额
if ($this->orderid) {
$check_count = Coupon::where('orderid', $this->orderid)
->where('outletId', $this->outletId)
->where('total', $this->total)
->where('status', 2)
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
->count();
->where('outletId', $this->outletId)
->where('total', $this->total)
->where('status', 2)
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
->sum('full');
} else {
$check_count = Coupon::where('outletId', $this->outletId)
->where('total', $this->total)
->where('status', 2)
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
->count();
->where('total', $this->total)
->where('status', 2)
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
->sum('full');
}
$count = floor($this->total / 100);
if ($check_count > 0) {
// if ($this->total < 100) {
// return '核销失败订单金额少于100只能核销一张优惠券。';
// }
if ($check_count >= $count) {
return "核销失败,此订单您只能使用 {$count} 张优惠券";
}
//金额判断
if ($check_count >= $this->total) {
return "核销失败,此订单您无法再使用优惠券";
}
//取差值
$diff = bcsub($this->total, $check_count);
if ($diff < $this->ticket['full']) {
return "核销失败,此订单您无法再使用优惠券.";
}
// $count = floor($this->total / 100);
//
// if ($check_count > 0) {
// // if ($this->total < 100) {
// // return '核销失败订单金额少于100只能核销一张优惠券。';
// // }
// if ($check_count >= $count) {
// return "核销失败,此订单您只能使用 {$count} 张优惠券";
// }
// }
return true;
}
@@ -182,10 +212,10 @@ class Init
public function HasCheck()
{
$info = Coupon::where('redemptionCode', $this->redemptionCode)
->where('outletId', $this->outletId)
->where('total', $this->total)
->where('status', 2)
->first();
->where('outletId', $this->outletId)
->where('total', $this->total)
->where('status', 2)
->first();
if ($info) {
return '核销失败,此优惠券已被使用';
}

View File

@@ -22,6 +22,7 @@ class PinganAction extends Init implements CouponContracts
->setOutletId($this->outletId)
->setTotal($this->total)
->setOrderId($this->orderid)
->setFrom($this->from)
->start();
}

View File

@@ -85,6 +85,7 @@ class YsdAction extends Init implements CouponContracts
->setOutletId($this->outletId)
->setTotal($this->total)
->setOrderId($this->orderid)
->setFrom($this->from)
->start();
}

View File

@@ -21,8 +21,9 @@ class Verification extends PingAnInit
//查询卡券信息
$this->query_coupon = (new Query)->setOutletId($this->outletId)
->setCode($this->redemptionCode)
->start();
->setCode($this->redemptionCode)
->start();
if (is_string($this->query_coupon)) {
return $this->query_coupon;
}
@@ -90,7 +91,7 @@ class Verification extends PingAnInit
return $resdata;
} catch (Exception $e) {
} catch (\Exception $e) {
$coupon->status = 3;
$coupon->remark = '核销失败 ' . $e->getMessage();
$coupon->save();
@@ -119,6 +120,7 @@ class Verification extends PingAnInit
'productId' => $this->queryData['productId'],
'thirdPartyGoodsId' => $this->queryData['thirdPartyGoodsId'],
'couponName' => $this->query_coupon['couponName'],
'full' => $this->ticket['full'],
'price' => $this->ticket['price'],
'total' => $this->total,
'profit' => $this->ticket['profit'],
@@ -129,7 +131,7 @@ class Verification extends PingAnInit
return $coupon = Coupon::create($couponData);
} catch (Exception $e) {
} catch (\Exception $e) {
return $e->getMessage();
}
@@ -210,7 +212,7 @@ class Verification extends PingAnInit
}
$this->ticket = [
'total' => $result[0],
'full' => $result[0],
'price' => $price,
'profit' => $code->profit,
];

View File

@@ -36,6 +36,12 @@ class YsdVerification extends Init
return $this->query_coupon;
}
//校验卡券
$ticket = $this->checkCoupon();
if (!is_array($ticket)) {
return $ticket;
}
//检查可核销次数100元为1次。
if ($this->query_coupon->activity && $this->query_coupon->activity->need_check) {
$ret = $this->CheckCount();
@@ -44,12 +50,6 @@ class YsdVerification extends Init
}
}
//校验卡券
$ticket = $this->checkCoupon();
if (!is_array($ticket)) {
return $ticket;
}
//增加核销记录
$coupon = $this->AddCoupon();
if (is_string($coupon)) {
@@ -79,7 +79,7 @@ class YsdVerification extends Init
event(new ConponCallback($this->query_coupon));
return $resdata;
} catch (Exception $e) {
} catch (\Exception $e) {
DB::rollback();
$this->coupon->status = 3;
@@ -144,7 +144,7 @@ class YsdVerification extends Init
}
return $this->ticket = [
'total' => $match[0],
'full' => $match[0],
'price' => $price,
'profit' => $code->profit,
];
@@ -171,6 +171,7 @@ class YsdVerification extends Init
'redemptionCode' => $this->redemptionCode,
'thirdPartyGoodsId' => $this->query_coupon->activity->rule->code,
'couponName' => $this->query_coupon->activity->title,
'full' => $this->ticket['full'],
'price' => $this->ticket['price'],
'total' => $this->total,
'profit' => $this->ticket['profit'],
@@ -184,7 +185,7 @@ class YsdVerification extends Init
DB::commit();
return $this->coupon;
} catch (Exception $e) {
} catch (\Exception $e) {
DB::rollback();
return $e->getMessage();

View File

@@ -117,9 +117,17 @@ class Coupon
* @param float $total 订单金额
* @param string $outletId 网点id
* @param string $orderid 订单id
* @param string $from 来源
* @return string
*/
public static function Redemption(User $user, string $redemptionCode, float $total, string $outletId, string $orderid = '')
public static function Redemption(
User $user,
string $redemptionCode,
float $total,
string $outletId,
string $orderid = '',
string $from = ''
)
{
try {
@@ -133,6 +141,7 @@ class Coupon
->setTotal($total)
->setOutletId($outletId)
->setOrderId($orderid)
->setFrom($from)
->start();
} catch (\Exception $e) {