6 Commits
1.0.5 ... 1.0.9

Author SHA1 Message Date
454bfa3d9d 修改四肢 2021-08-19 10:27:12 +08:00
1cac561b38 配置参数 2021-07-14 09:53:55 +08:00
3b3a3601da 配置地址 2021-07-08 15:09:34 +08:00
61e8d24f3e 首页接口 2021-06-29 16:20:44 +08:00
add71f3d4c 增加优惠券详情 2021-06-25 15:04:54 +08:00
711940ecce 改名 2021-06-16 15:05:26 +08:00
6 changed files with 137 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "xuanchen/washcar", "name": "xuanchen/washcar",
"description": "平安sdk", "description": "洗车券",
"license": "MIT", "license": "MIT",
"homepage": "http://git.yuzhankeji.cn/xuanchen/PingAnWashCar.git", "homepage": "http://git.yuzhankeji.cn/xuanchen/PingAnWashCar.git",
"authors": [ "authors": [

View File

@@ -6,31 +6,36 @@ return [
* 平安洗车券 * 平安洗车券
*/ */
'this_type' => 'test', 'this_type' => env('WASH_TYPE'),
/** /**
* 测试环境参数 * 测试环境参数
*/ */
'test' => [ 'test' => [
'client_id' => env('WASH_CAR_APPID', ''),//就是 appId 'client_id' => env('WASH_CAR_TEST_APPID', ''),//就是 appId
'client_secret' => env('WASH_CAR_SECRET', ''),// 就是 client_secret 'client_secret' => env('WASH_CAR_TEST_SECRET', ''),// 就是 client_secret
'apiVersion' => 'v2', 'apiVersion' => 'v2',
'grant_type' => 'client_credentials', 'grant_type' => 'client_credentials',
'tokenUri' => 'https://open.cyzl.com/beta/auth/oauth/token', 'tokenUri' => 'https://open.cyzl.com/beta/auth/oauth/token',
'baseUri' => 'https://open.cyzl.com/beta/api', 'baseUri' => 'https://open.cyzl.com/beta/api',
'urlKey' => env('WASH_CAR_URLKEY', ''),//免登陆跳转 'indexUri' => 'https://v.cyzl.com/beta/activity/helongjiangWashCar/index.html?activityId={{activityId}}#/?accessToken={{accessToken}}',
//优惠券详情地址
'infoUri' => 'https://v.cyzl.com/beta/xtz-v2/portal/index.html?activityId={{activityId}}&activityNo=default#/car-ticketInfo?ticketCode={{ticketCode}}&isShowHead=1&accessToken={{accessToken}}',
], ],
/** /**
* 生产环境参数 * 生产环境参数
*/ */
'dev' => [ 'dev' => [
'client_id' => env('WASH_CAR_APPID', ''),//就是 appId 'client_id' => env('WASH_CAR_DEV_APPID', ''),//就是 appId
'client_secret' => env('WASH_CAR_SECRET', ''),// 就是 client_secret 'client_secret' => env('WASH_CAR_DEV_SECRET', ''),// 就是 client_secret
'apiVersion' => 'v2', 'apiVersion' => 'v2',
'grant_type' => 'client_credentials', 'grant_type' => 'client_credentials',
'tokenUri' => 'https://open.cyzl.com/api/auth/oauth/token', 'tokenUri' => 'https://open.cyzl.com/auth/oauth/token',
'baseUri' => 'https://open.cyzl.com/api', 'baseUri' => 'https://open.cyzl.com/api',
'urlKey' => env('WASH_CAR_URLKEY', ''),//免登陆跳转 //首页购买页
'indexUri' => 'https://v.cyzl.com/activity/helongjiangWashCar/index.html?activityId={{activityId}}#/?accessToken={{accessToken}}',
//优惠券详情地址
'infoUri' => 'https://v.cyzl.com/xtz-v2/portal/index.html?activityId={{activityId}}&activityNo=default#/car-ticketInfo?ticketCode={{ticketCode}}&isShowHead=1&accessToken={{accessToken}}',
], ],
]; ];

View File

@@ -5,9 +5,21 @@ namespace XuanChen\WashCar\Action;
class BaseAction extends Init class BaseAction extends Init
{ {
public function index() /**
* Notes: 免登陆
* @Author: 玄尘
* @Date : 2021/6/29 10:49
* @param string $method
* @return array
*/
public function getUnLoginUrl($method = 'POST')
{ {
return 1; $url = $this->config['baseUri'] . '/v2/h5/redirect/autoLogin/commonReturnUrl';
$params = $this->getParams();
$this->http($url, $params, $method);
return $this->getResponse();
} }
} }

View File

@@ -2,6 +2,9 @@
namespace XuanChen\WashCar\Action; namespace XuanChen\WashCar\Action;
use App\Models\Coupon;
use App\Models\CouponLog;
class CouponAction extends Init class CouponAction extends Init
{ {
@@ -12,17 +15,39 @@ class CouponAction extends Init
*/ */
public function getOrderUrl() public function getOrderUrl()
{ {
$url = $this->config['baseUri'] . '/v2/h5/redirect/autoLogin/returnUrl'; $callback_url = $this->config['indexUri'];
$this->params = array_merge($this->params, [ $callback_url = str_replace('{{activityId}}', $this->params['activityId'], $callback_url);
'urlKey' => $this->config['urlKey'], $callback_url .= '&' . $this->params['attr'];
]);
$params = $this->getParams(); return app('xuanchen.washcar')->base()
->setParams([
'phone' => $this->params['phone'],
'url' => $callback_url,
])
->getUnLoginUrl();
}
$this->http($url, $params); /**
* Notes: 获取优惠券详情H5地址
* @Author: 玄尘
* @Date : 2021/6/25 14:16
* @return array
*/
public function getCouponInfoUrl()
{
$data = $this->params;
$callback_url = $this->config['infoUri'];
$callback_url = str_replace('{{ticketCode}}', $this->params['code'], $callback_url);
return app('xuanchen.washcar')->base()
->setParams([
'phone' => $data['phone'],
'url' => $callback_url,
])
->getUnLoginUrl();
return $this->getResponse();
} }
/** /**
@@ -91,4 +116,73 @@ class CouponAction extends Init
} }
/**
* Notes: 回调地址
* @Author: 玄尘
* @Date : 2021/6/29 11:26
*/
public function callback()
{
$validator = \Validator::make($this->params, [
'couponCode' => 'required',
'verifyTime' => 'required',
'url' => 'required',
], [
'couponCode.required' => '缺少参数couponCode',
'verifyTime.required' => '缺少参数verifyTime',
'url.required' => '缺少参数url',
]);
if ($validator->fails()) {
$this->error = 999;
$this->message = $validator->errors()->first();
return $this->getResponse();
}
//插入日志
$this->addLog($this->params);
$couponCode = $this->params['couponCode'];
$verifyTime = $this->params['verifyTime'];
$this->url = $this->params['url'];
$coupon = Coupon::where('code', $couponCode)->first();
if ($coupon) {
if (in_array($coupon->status, [Coupon::STATUS_INIT, Coupon::STATUS_ERROR])) {
$coupon->status = Coupon::STATUS_USED;
$coupon->used_at = $verifyTime;
$coupon->source = $this->params;
$coupon->save();
CouponLog::create([
'code' => $coupon->code,
'from' => 'Washcar',
'type' => 'callback',
'remark' => '核销成功',
]);
//设置订单完成
if ($coupon->order && $coupon->order->canComplete()) {
$coupon->order->complete();
}
}
$this->error = 0;
$this->message = '操作成功';
} else {
$this->error = 99;
$this->message = '优惠券码不存在';
}
$this->updateLog(['code' => $this->error, 'message' => $this->message]);
return $this->getResponse();
}
} }

View File

@@ -71,6 +71,8 @@ class Init
} else { } else {
$this->getAjaxToken(); $this->getAjaxToken();
} }
return $this->access_token;
} }
/** /**

View File

@@ -3,6 +3,7 @@
namespace XuanChen\WashCar\Models; namespace XuanChen\WashCar\Models;
use Carbon\Carbon; use Carbon\Carbon;
use XuanChen\WoUnicom\Action\Order;
class WashcarCoupon extends Model class WashcarCoupon extends Model
{ {
@@ -22,4 +23,9 @@ class WashcarCoupon extends Model
self::STATUS_ERROR => '失败', self::STATUS_ERROR => '失败',
]; ];
public function order()
{
return $this->morphTo();
}
} }