无意义
This commit is contained in:
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 核销接口
|
||||
|
||||
[TOC]
|
||||
|
||||
## 文档说明
|
||||
|
||||
| 版本号 | 发行说明 |
|
||||
| ------ | ------------------ |
|
||||
| 1.0.1 | 第一版本发布 |
|
||||
@@ -17,6 +17,22 @@ class TestController
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$this->user = User::find(6);
|
||||
$ret = [
|
||||
'redemptionCode' => 'YSD201029312435',
|
||||
'outletId' => '2008030929274',
|
||||
];
|
||||
|
||||
$ret = [
|
||||
'mobile' => '15663876870',
|
||||
'orderid' => '202008105236478',
|
||||
'activityId' => 'ysd202010272',
|
||||
'outletId' => '2008241014458',
|
||||
|
||||
];
|
||||
|
||||
return $this->success($ret);
|
||||
dd();
|
||||
$user_id = $request->user_id;
|
||||
$data = $request->data;
|
||||
$this->user = User::find(3);
|
||||
|
||||
@@ -2,143 +2,10 @@
|
||||
|
||||
namespace XuanChen\Sinopec;
|
||||
|
||||
use App\Models\Activity;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* 中石化接口
|
||||
*/
|
||||
class Sinopec
|
||||
{
|
||||
|
||||
/**
|
||||
* Notes: 发券接口
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/6/28 15:07
|
||||
* @param $activityId 活动编号
|
||||
* @param $outletId 网点编号
|
||||
* @param $mobile 手机号
|
||||
*/
|
||||
public static function Grant($activityId, $outletId, $mobile)
|
||||
{
|
||||
$model = config('xuanchen_coupon.rules.ysd.model');
|
||||
|
||||
return (new $model)->setActivityId($activityId)
|
||||
->setOutletId($outletId)
|
||||
->setMobile($mobile)
|
||||
->grant();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 查询接口
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/7/21 11:58
|
||||
* @param $redemptionCode
|
||||
*/
|
||||
public static function Query($redemptionCode, $outletId)
|
||||
{
|
||||
if (!$redemptionCode) {
|
||||
return '查询失败,未获取到券码';
|
||||
}
|
||||
|
||||
$model = self::getModelByCode($redemptionCode);
|
||||
if (is_string($model)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return $model->setCode($redemptionCode)
|
||||
->setOutletId($outletId)
|
||||
->detail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 卡券作废
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/9/2 16:54
|
||||
* @param $redemptionCode
|
||||
* @param $outletId
|
||||
* @return string
|
||||
*/
|
||||
public static function Destroy($redemptionCode, $outletId)
|
||||
{
|
||||
try {
|
||||
$model = self::getModelByCode($redemptionCode);
|
||||
if (is_string($model)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return $model->setCode($redemptionCode)
|
||||
->setOutletId($outletId)
|
||||
->destroy();
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 根据券码 获取class
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/7/21 12:00
|
||||
* @param $code
|
||||
* @return string
|
||||
*/
|
||||
public static function getModelByCode($code)
|
||||
{
|
||||
$rules = config('xuanchen_coupon.rules');
|
||||
if (!$rules) {
|
||||
return '系统出错,未找到配置文件';
|
||||
}
|
||||
|
||||
$model = '';
|
||||
foreach ($rules as $rule) {
|
||||
if (preg_match($rule['pattern'], $code, $matches)) {
|
||||
$model = $rule['model'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$model) {
|
||||
throw new \Exception('卡券核销失败。未查到卡券所属');
|
||||
}
|
||||
|
||||
return new $model;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: description
|
||||
* @Author: 玄尘
|
||||
* @Date : 2020/8/21 13:33
|
||||
* @param \App\Models\User $user 渠道
|
||||
* @param string $redemptionCode 要核销的券码
|
||||
* @param float $total 订单金额
|
||||
* @param string $outletId 网点id
|
||||
* @param string $orderid 订单id
|
||||
* @return string
|
||||
*/
|
||||
public static function Redemption(User $user, string $redemptionCode, float $total, string $outletId, string $orderid = '')
|
||||
{
|
||||
|
||||
try {
|
||||
$model = self::getModelByCode($redemptionCode);
|
||||
if (is_string($model)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return $model->setUser($user)
|
||||
->setCode($redemptionCode)
|
||||
->setTotal($total)
|
||||
->setOutletId($outletId)
|
||||
->setOrderId($orderid)
|
||||
->start();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user