无意义

This commit is contained in:
2020-10-30 16:35:21 +08:00
parent c214cfed0d
commit a8852873d2
4 changed files with 49 additions and 159 deletions

2
README
View File

@@ -1,2 +0,0 @@
核销系统 增加发券 开发分支

9
README.md Normal file
View File

@@ -0,0 +1,9 @@
# 核销接口
[TOC]
## 文档说明
| 版本号 | 发行说明 |
| ------ | ------------------ |
| 1.0.1 | 第一版本发布 |

View File

@@ -17,20 +17,36 @@ class TestController
public function index(Request $request) public function index(Request $request)
{ {
$user_id = $request->user_id; $this->user = User::find(6);
$data = $request->data; $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); $this->user = User::find(3);
$data = '5VehIrHTZsS1BY8V5VcKlhTN9hbutq4j+HIT2zRCbSqgPWvClQSxYSP7mn7PmHuiYQpj55NRC6w4397FfdVTq23wd4BOQ964giie/JForTjt0l7UaY23XzKnNjDSKiGqr7DAbd8P3SzJ75ZjKaqUu7UWu3PVylAeesGRbZgpQEF/XKwOW4XMaJGV2tIsowILZCtF+moqHg7yA6hI4vT7iYU3rTq9vk7kpcnfArLKPQ5dxH9FFIegdr7E1S8NVwpTZrxeQEmjDUsGrBcWe/Q9dRWXSlKF1Hdz2qCUCK94fu3gqvEVSYRllTCa5mwQhlYJLs2UTmWMSism7nsivySseSl1/JOvNH0lyvWaV1XDUMKG8oTC+kOPQKxFA3qp2xO9ohRhN0dkpML4JVgkMF1r6rv+rThYQuOL/rnsuY5Jdh4QdPWCItQ05lqI46s2yPyKROrLx7jQ3/+BOyEmP+Cj5W8/trEAVS1HczMj4Jnl3vrcY879ubokUcEatalAuKGM0uLNAqQF5XfHzgXam4coEMek8MjdbxW+Z9+eZFQp/P1ts7yN5qzpac6Y8CrqSMFJZf1vwowp+1peiEC5tCsXlHCsDLPS8Uh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XZu7jX5uVR9nxR2c/ibBJOAHcUO+NcjmzoN+dQOeBkb/aWj9B+9mW5RUQmfUk6O+Vwkb5ruZZbXsoJJULj4tHJv87+mVo30e0mBbaPD47+fTp1+qSJtLOOlLO2nEj1NNDBSBGLM4RxTDQ4ju2r6HY9YyMXsbNC2YB8zrXrDsUoB1WSuu5XcaWx8rzA0NpckzNbEIuv0+6fA69gXOhC9xcGGPyEBbko73XHr7W8MIDtWhGOG8kHf1cAMdjwVGS2OUJ6XKZnBMwIzY8cJn4Fi+jXRMFnt+7BxWLToNQsyOoHbYWypeM8FrAb4VQeaxGhBQUXUmHhmAp00jcGEe/ngxn1oVjq6G+pEq8CxBntvQ+GZ975sPaCqkYOjbuHa9Myd2tT6GWbczL/YcR4RRV96ByYYCEOBy01LsBNeo6SSpWYcK4eoLhc70v8s';
$iv = substr($this->user->des3key, 0, 8); $iv = substr($this->user->des3key, 0, 8);
$ret = openssl_decrypt($data, 'DES-EDE3-CBC', $this->user->des3key, 0, $iv); $ret = openssl_decrypt($data, 'DES-EDE3-CBC', $this->user->des3key, 0, $iv);
if (false === $ret) { if (false === $ret) {
return openssl_error_string(); return openssl_error_string();
} }
dd($ret); dd($ret);
dd(); dd();
$this->user = User::find(215); $this->user = User::find(215);
$ret = [ $ret = [
'redemptionCode' => '951951858070', 'redemptionCode' => '951951858070',
'total' => 5, 'total' => 5,
'outletId' => '2006151433887', 'outletId' => '2006151433887',
@@ -95,7 +111,7 @@ class TestController
$this->user = User::find(3); $this->user = User::find(3);
$redemptionCode = $request->redemptionCode; $redemptionCode = $request->redemptionCode;
$outletId = $request->outletId; $outletId = $request->outletId;
$data = $this->jiami($request->all()); $data = $this->jiami($request->all());
@@ -121,7 +137,7 @@ class TestController
$this->user = User::find(3); $this->user = User::find(3);
$redemptionCode = $request->redemptionCode; $redemptionCode = $request->redemptionCode;
$data = $this->jiami($request->all()); $data = $this->jiami($request->all());
$url = $this->baseUrl . 'user/destroy'; $url = $this->baseUrl . 'user/destroy';
$res = $this->http($data, $url); $res = $this->http($data, $url);
@@ -148,11 +164,11 @@ class TestController
$this->user = User::find($user_id); $this->user = User::find($user_id);
$data = $this->jiami([ $data = $this->jiami([
'redemptionCode' => $request->redemptionCode, 'redemptionCode' => $request->redemptionCode,
'total' => $request->total, 'total' => $request->total,
'outletId' => $request->outletId, 'outletId' => $request->outletId,
'orderid' => $request->orderid, 'orderid' => $request->orderid,
]); ]);
$url = $this->baseUrl . 'user/freezecoupon'; $url = $this->baseUrl . 'user/freezecoupon';
$res = $this->http($data, $url); $res = $this->http($data, $url);
@@ -160,10 +176,10 @@ class TestController
return $res; return $res;
$redemptionCode = $request->redemptionCode; $redemptionCode = $request->redemptionCode;
$total = $request->total; $total = $request->total;
$outletId = $request->outletId; $outletId = $request->outletId;
$orderid = $request->orderid ?? ''; $orderid = $request->orderid ?? '';
$res = Coupon::Redemption($this->user, $redemptionCode, $total, $outletId, $orderid); $res = Coupon::Redemption($this->user, $redemptionCode, $total, $outletId, $orderid);
if (is_string($res)) { if (is_string($res)) {
return $this->error($res); return $this->error($res);
@@ -174,22 +190,22 @@ class TestController
public function http($data, $url) public function http($data, $url)
{ {
$client = new Client(); $client = new Client();
$response = $client->request('POST', $url, ['form_params' => $data, 'http_errors' => false]); $response = $client->request('POST', $url, ['form_params' => $data, 'http_errors' => false]);
$body = $response->getBody(); $body = $response->getBody();
$content = $body->getContents(); $content = $body->getContents();
$result = json_decode($content, true); $result = json_decode($content, true);
return $result; return $result;
} }
public function jiami($ret) public function jiami($ret)
{ {
$jsonData = json_encode($ret); //数据JSON化 $jsonData = json_encode($ret); //数据JSON化
$ascdata = $this->keyasc($jsonData); //加密 $ascdata = $this->keyasc($jsonData); //加密
$addcode = sprintf("%08d", mt_rand(0, 99999999)); //随机code 验证签名用 $addcode = sprintf("%08d", mt_rand(0, 99999999)); //随机code 验证签名用
$sign = $this->keysign($ascdata, $addcode); $sign = $this->keysign($ascdata, $addcode);
$data = [ $data = [
'server_id' => $this->user->server_id, 'server_id' => $this->user->server_id,
@@ -209,7 +225,7 @@ class TestController
*/ */
public function jiemi($value) public function jiemi($value)
{ {
$iv = substr($this->user->des3key, 0, 8); $iv = substr($this->user->des3key, 0, 8);
$ret = openssl_decrypt($value, 'DES - EDE3 - CBC', $this->user->des3key, 0, $iv); $ret = openssl_decrypt($value, 'DES - EDE3 - CBC', $this->user->des3key, 0, $iv);
if (false === $ret) { if (false === $ret) {
return openssl_error_string(); return openssl_error_string();

View File

@@ -2,143 +2,10 @@
namespace XuanChen\Sinopec; namespace XuanChen\Sinopec;
use App\Models\Activity;
use App\Models\User;
use Illuminate\Support\Facades\DB;
/** /**
* 中石化接口 * 中石化接口
*/ */
class Sinopec 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();
}
}
} }