[新增] 配置文件

This commit is contained in:
2021-01-31 14:36:21 +08:00
parent 79e60eb40e
commit abea4f86d5
7 changed files with 1035 additions and 321 deletions

View File

@@ -2,330 +2,72 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Coupon; use Illuminate\Http\Request;
use App\Models\TestLog; use League\Flysystem\Sftp\SftpAdapter;
use App\Models\User; use League\Flysystem\Filesystem;
use Illuminate\Queue\Jobs\Job; use XuanChen\UnionPay\Check;
use XuanChen\Coupon\Action\pingan\Query;
use XuanChen\Coupon\Action\ysd\YsdQuery;
class SkyxuController class SkyxuController extends Controller
{ {
public $user; /**
* Notes: 链接sftp
public $jiemi; * @Author: 玄尘
* @Date : 2021/1/26 8:18
public $query_coupon; */
public function sftp()
public $ticket;
public $type;
public function index()
{ {
$list = Job::get(); $app = app('xuanchen.unionpay.check');
dd($list); $app->date = '20190722';
Coupon::whereBetween('id', ['70091', '70513']) $app->login();
->orderBy('created_at', 'ASC') $app->hasFile();
->chunk(100, function ($logs) { $app->start();
foreach ($logs as $log) { dump($app->msg);
if (preg_match('/^YSD/', $log->redemptionCode, $matches)) {
$type = Coupon::TYPE_YSD; die();
} else { $path = '/home/wwwroot/pingan/upload/';
$type = Coupon::TYPE_PINGAN; $name = 'JYMX66007320190722.txt';
$adapter = new SftpAdapter([
'host' => '123.57.16.212',
'port' => 22,
'username' => 'root',
'password' => 'Anetadmin1',
'privateKey' => '',
'passphrase' => '',
'root' => $path,
'timeout' => 10,
'directoryPerm' => 0755,
]);
$filesystem = new Filesystem($adapter);
$lists = $filesystem->listContents();
$content = $filesystem->read($name);
$content = str_replace("\n", "br", $content);
dump($content);
$content = explode("br", $content);
foreach ($content as $item) {
$array = explode('|', $item);
foreach ($array as $item) {
echo $item . "<br>";
}
echo '----------------------------------------' . "<br>";
}
dd($content);
} }
$log->type = $type; public function index(Request $request)
$log->save();
}
});
dd();
$count = TestLog::whereBetween('created_at', ['2020-11-10 11:06:40', '2020-11-11 10:42:26'])
->where('type', 'freezecoupon')
->where('back', '0')
->orderBy('created_at', 'ASC')
->count();
dump($count);
// $list = TestLog::whereBetween('created_at', ['2020-11-10 11:06:40', '2020-11-11 10:42:26'])
// ->where('type', 'freezecoupon')
// ->where('back', '0')
// ->orderBy('created_at', 'ASC')
// ->get();
//
//// $data = [];
//// foreach ($list as $cou) {
//// $data[] = $cou->in_source['jiemi']['redemptionCode'];
//// }
//// dump($data);
if ($count > 1) {
try {
TestLog::whereBetween('created_at', ['2020-11-10 11:06:40', '2020-11-11 10:42:26'])
->where('type', 'freezecoupon')
->where('back', '0')
->orderBy('created_at', 'ASC')
->chunk(100, function ($logs) {
$su = $er = [];
foreach ($logs as $log) {
$this->jiemi = $log->in_source['jiemi'];
$this->user = User::where('outlet_id', $this->jiemi['outletId'])->first();
$this->getQuery();
if (is_string($this->queryData)) {
$er[$this->jiemi['redemptionCode']] = $this->queryData;
continue;
}
if ($this->jiemi['redemptionCode'] == '157922465040') {
dump($this->jiemi);
dump($this->ticket);
dump($this->queryData);
}
$this->checkCode();
if (is_string($this->ticket)) {
$er[$this->jiemi['redemptionCode']] = $this->ticket;
$er[] = $this->jiemi['redemptionCode'];
continue;
}
$status = isset($log->out_source['code']) ? 2 : 3;
$exists = Coupon::where('status', $status)
->where('redemptionCode', $this->jiemi['redemptionCode'])->exists();
if ($exists && $status != 3) {
$er[$this->jiemi['redemptionCode']] = [
$log->out_source,
];
continue;
}
$couponData = [
'user_id' => $this->user->parent->id,
'type' => Coupon::TYPE_YSD,
'outletId' => $this->user->outlet_id,
'orderid' => '',
'PaOutletId' => $this->queryData['PaOutletId'],
'redemptionCode' => $this->jiemi['redemptionCode'],
'thirdPartyGoodsId' => $this->queryData['thirdPartyGoodsId'],
'couponName' => $this->queryData['couponName'],
'price' => $this->ticket['price'],
'total' => $this->jiemi['total'],
'profit' => $this->ticket['profit'],
'status' => $status,
'remark' => isset($log->out_source['code']) ? '核销成功!' : $log->out_source[0],
'startTime' => $this->queryData['startTime'],
'endTime' => $this->queryData['endTime'],
'created_at' => $log->created_at->format('Y-m-d H:i:s'),
];
// dump($this->jiemi);
// dump($this->ticket);
// dump($couponData);
// dd($this->queryData);
$coupon = Coupon::create($couponData);
$coupon->profit();
$log->back = 1;
$log->save();
}
if (count($er) > 1) {
dump($er);
}
});
} catch (\Exception $e) {
dd($e->getMessage());
}
}
}
public function getQuery()
{ {
if (preg_match('/^YSD/', $this->jiemi['redemptionCode'], $matches)) { if (method_exists($this, $request->action)) {
$this->query_coupon = (new YsdQuery)->setOutletId($this->jiemi['outletId'])
->setCode($this->jiemi['redemptionCode'])
->start();
$this->type = 'ysd';
} else {
$this->query_coupon = (new Query)->setOutletId($this->jiemi['outletId'])
->setCode($this->jiemi['redemptionCode'])
->start();
$this->type = 'pingan';
} return call_user_func_array([$this, $request->action], [$request->all()]);
if ($this->type == 'ysd') {
return $this->getYsdPro();
} else { } else {
return $this->getPro(); dd('未找到方法');
} }
}
public function getYsdPro()
{
$rule_code = $this->query_coupon->activity->rule->code;
$code = $this->user->parent->code->where('code', $rule_code)->first();
if (!$code) {
$this->queryData = "核销失败,您没有权限使用此卡券优惠活动。";
}
$ticket = explode('-', $rule_code);
if (!is_array($ticket) || count($ticket) != 3) {
$this->queryData = "核销失败,卡券规则格式不正确";
}
$full = $ticket[1]; //full100
$price = $ticket[2];
// preg_match('/(\d{3}(\.\d+)?)/is', $full, $match);
preg_match('/\d+/', $full, $match);
if (!is_array($match)) {
$this->queryData = "核销失败,卡券规则格式不正确。";
}
if (!is_numeric($this->jiemi['total'])) {
$this->queryData = "核销失败,订单金额必须是数字";
}
if ($match[0] > $this->jiemi['total']) {
$this->queryData = '核销失败,订单金额不足。';
}
$this->queryData = [
'couponName' => $this->query_coupon->activity->title,
'thirdPartyGoodsId' => $rule_code,
'productId' => '',
'PaOutletId' => '',
'startTime' => $this->query_coupon->start_at->format('Y-m-d H:i:s'),
'endTime' => $this->query_coupon->end_at->format('Y-m-d H:i:s'),
];
return $this->ticket = [
'total' => $match[0],
'price' => $price,
'profit' => $code->profit,
];
}
public function getPro()
{
if (is_string($this->query_coupon)) {
return $this->query_coupon;
}
$profitOfferItemVersion = $this->query_coupon['profitOfferItemVersion'];
$productItemList = $this->query_coupon['productItemList'];
if (!is_array($productItemList) || !is_array($productItemList[0])) {
$this->queryData = '核销失败,平安券数据有误,可能是未配置网点。';
}
//循环查找
$first = '';
foreach ($productItemList as $key => $item) {
$productId = $item['productId'];
$thirdPartyGoodsId = $item['thirdPartyGoodsId'];
$outletList = $item['outletList'];
if (!is_array($outletList) || !is_array($outletList[0])) {
$this->queryData = '核销失败,网点信息有误!请检查平安券配置信息。';
break;
}
$outletList = collect($outletList);
//判断是新版还是旧版
if ($profitOfferItemVersion) {
//新版通过第三方查询
$first = $outletList->firstWhere('thirdOutletNo', $this->user->outlet_id);
if ($first) {
break;
}
} else {
//旧版通过平安网点查询
$first = $outletList->firstWhere('outletNo', $this->user->PaOutletId);
if ($first) {
break;
}
}
}
if (!$first) {
$this->queryData = '核销失败,未找到可用网点信息。';
}
if (!$thirdPartyGoodsId) {
$this->queryData = '核销失败,平安券编号规则有误。';
}
if (!$productId) {
$this->queryData = '核销失败未查询到平安券商品id。';
}
return $this->queryData = [
'couponName' => $this->query_coupon['couponName'],
'thirdPartyGoodsId' => $thirdPartyGoodsId,
'productId' => $productId,
'PaOutletId' => $first['outletNo'],
'startTime' => $this->query_coupon['startTime'],
'endTime' => $this->query_coupon['endTime'],
];
}
public function checkCode()
{
if ($this->type == 'ysd') {
return $this->ticket;
}
$code = $this->user->parent->code->where('code', $this->queryData['thirdPartyGoodsId'])->first();
if (!$code) {
$this->ticket = "核销失败,未找到此项平安券规则,请联系管理人员检查渠道配置。";
}
$ticket = explode('-', $this->queryData['thirdPartyGoodsId']);
if (!is_array($ticket) || count($ticket) != 3) {
$this->ticket = "核销失败,平安券规则格式不正确。";
}
$full = $ticket[1]; //full100
$price = $ticket[2];
preg_match('/\d+/', $full, $result);
if (empty($result) || !is_array($result)) {
$this->ticket = "核销失败,平安券规则格式不正确。";
}
if (!is_numeric($this->jiemi['total'])) {
$this->ticket = "核销失败,订单金额必须是数字";
}
if ($result[0] > $this->jiemi['total']) {
$this->ticket = '核销失败,订单金额不足,平安券不可使用。';
}
$this->ticket = [
'total' => $result[0],
'price' => $price,
'profit' => $code->profit,
];
return $this->ticket;
} }
} }

188
composer.lock generated
View File

@@ -1735,6 +1735,10 @@
"sftp", "sftp",
"storage" "storage"
], ],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/1.x"
},
"funding": [ "funding": [
{ {
"url": "https://offset.earth/frankdejonge", "url": "https://offset.earth/frankdejonge",
@@ -1743,6 +1747,58 @@
], ],
"time": "2020-08-23T07:39:11+00:00" "time": "2020-08-23T07:39:11+00:00"
}, },
{
"name": "league/flysystem-sftp",
"version": "1.0.22",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-sftp.git",
"reference": "cab59dd2277e02fe46f5f23195672a02ed49774d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-sftp/zipball/cab59dd2277e02fe46f5f23195672a02ed49774d",
"reference": "cab59dd2277e02fe46f5f23195672a02ed49774d",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"league/flysystem": "~1.0",
"php": ">=5.6.0",
"phpseclib/phpseclib": "~2.0"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "^5.7.25"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\Flysystem\\Sftp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frenky.net"
}
],
"description": "Flysystem adapter for SFTP",
"support": {
"issues": "https://github.com/thephpleague/flysystem-sftp/issues",
"source": "https://github.com/thephpleague/flysystem-sftp/tree/master"
},
"time": "2019-10-16T20:05:49+00:00"
},
{ {
"name": "league/mime-type-detection", "name": "league/mime-type-detection",
"version": "1.7.0", "version": "1.7.0",
@@ -2190,6 +2246,121 @@
], ],
"time": "2020-07-20T17:29:33+00:00" "time": "2020-07-20T17:29:33+00:00"
}, },
{
"name": "phpseclib/phpseclib",
"version": "2.0.30",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/136b9ca7eebef78be14abf90d65c5e57b6bc5d36",
"reference": "136b9ca7eebef78be14abf90d65c5e57b6bc5d36",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
"squizlabs/php_codesniffer": "~2.0"
},
"suggest": {
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
},
"type": "library",
"autoload": {
"files": [
"phpseclib/bootstrap.php"
],
"psr-4": {
"phpseclib\\": "phpseclib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/2.0.30"
},
"funding": [
{
"url": "https://github.com/terrafrost",
"type": "github"
},
{
"url": "https://www.patreon.com/phpseclib",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
"type": "tidelift"
}
],
"time": "2020-12-17T05:42:04+00:00"
},
{ {
"name": "psr/container", "name": "psr/container",
"version": "1.0.0", "version": "1.0.0",
@@ -5538,16 +5709,16 @@
}, },
{ {
"name": "xuanchen/unionpay", "name": "xuanchen/unionpay",
"version": "2.6", "version": "2.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/xuanchen120/unionpay.git", "url": "https://github.com/xuanchen120/unionpay.git",
"reference": "a2430888e99a9dd284c95788a4275b78d81356e9" "reference": "877342101be87fb82f92681578953733bf2f93f7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/xuanchen120/unionpay/zipball/a2430888e99a9dd284c95788a4275b78d81356e9", "url": "https://api.github.com/repos/xuanchen120/unionpay/zipball/877342101be87fb82f92681578953733bf2f93f7",
"reference": "a2430888e99a9dd284c95788a4275b78d81356e9", "reference": "877342101be87fb82f92681578953733bf2f93f7",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@@ -5558,6 +5729,7 @@
}, },
"require": { "require": {
"laravel/framework": "*", "laravel/framework": "*",
"league/flysystem-sftp": "^1.0 || ^2.0",
"php": ">=7.1.3" "php": ">=7.1.3"
}, },
"type": "library", "type": "library",
@@ -5584,7 +5756,11 @@
} }
], ],
"description": "第三方银联对接", "description": "第三方银联对接",
"time": "2021-01-29T07:44:22+00:00" "support": {
"issues": "https://github.com/xuanchen120/unionpay/issues",
"source": "https://github.com/xuanchen120/unionpay/tree/2.7"
},
"time": "2021-01-31T06:20:57+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@@ -8162,5 +8338,5 @@
"php": "^7.3|^8.0" "php": "^7.3|^8.0"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "1.1.0" "plugin-api-version": "2.0.0"
} }

54
config/pingan.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
return [
/**
* 平安接口参数
*/
'this_type' => 'dev',
/**
* 测试环境参数
*/
'test' => [
'client_id' => 'P_YISHIDAI',
'grant_type' => 'client_credentials',
'client_secret' => 'zGg9e6J5',
'userName' => '18804518018',
'AES_CODE' => '61DA0376BEBCFE1F',
'tokenUri' => 'https://test-api.pingan.com.cn:20443/oauth/oauth2/access_token',
'Uri' => 'http://test-api.pingan.com.cn:20080/open/vassPartner/appsvr/property/api/new/',
],
/**
* 生产环境参数
*/
'dev' => [
'client_id' => 'P_YISHIDAI',
'grant_type' => 'client_credentials',
'client_secret' => 'F3j5J7bx',
'userName' => '13936166646',
'AES_CODE' => '108DD27AB83252DB',
'tokenUri' => 'http://api.pingan.com.cn/oauth/oauth2/access_token',
'Uri' => 'http://api.pingan.com.cn/open/vassPartner/appsvr/property/api/new/',
],
'profit' => [
'YSD-full100-10' => 0,
'YSD-full100-25' => 15,
'YSD-full100-50' => 40,
'YSD-full200-100' => 80,
],
'coupon_status' => [
1 => '使用中',
2 => '已使用',
3 => '已过期',
4 => '已收回',
5 => '退兑换',
6 => '已冻结',
7 => '未激活',
],
'froms' => [
'bsshop',//本时商城
'bslive',//本时生活
],
];

687
config/unionpay.php Normal file
View File

@@ -0,0 +1,687 @@
<?php
return [
//环境变量
'this_type' => 'test',
//添加日志
'log' => true,
//对账单信息
'check' => [
'sftpadapter' => [
'host' => 'localhost',//地址
'port' => 22,//端口
'username' => 'root', //账号
'password' => 'Anetadmin1',//密码
'privateKey' => '',
'passphrase' => '',
'root' => '/home/wwwroot/pingan/upload/',//路径
'timeout' => 10,//超时时间
'directoryPerm' => 0755,
],
'type' => 'JYMX',
'file_type' => 'txt',
],
//获取微信侧的优惠券
'unionpay_url' => [
'test' => [
'code' => 'http://dev.spserv.yxlm.chinaums.com:25941/spapigateway/v2/markting/sp/coupon/order/get',
],
'dev' => [
'code' => 'https://mktos.chinaums.com/spapigateway/v2/markting/sp/coupon/order/get',
],
],
//不进行sign校验
'nosign' => [
// '002025',//查询
// '002100',//核销
// '002101',//冲正
// '002102',//撤销
'openid',//获取openid 封装数据
'code',//微信测获取优惠券
],
//分配的渠道号
'msg_sender' => '660134',
//打印在小票上,由活动标题、优惠金额、原始金额组合而成
'pos_receipt' => '本时生活,优惠生活',
//广告,用于打印在小票上
'pos_ad' => '',
//营销联盟广告,用于打印在小票上
'pos_mkt_ad' => '本时生活,优惠生活',
//银联渠道id
'agent_id' => '299',
//银联网点id
'outlet_id' => '2009300919918',
//用于银商与sp分润的金额(是佣金的一部分), 以分为单位
'serv_chg' => 0,
//佣金
'commission' => 0,
//证书
'certificate' => [
'dev' => [
'ysd' => [
'private' => storage_path('cert/unionpay/dev/ysd/private_rsa.pem'),
'public' => storage_path('cert/unionpay/dev/ysd/public_rsa.pem'),
],
'union' => [
'public' => storage_path('cert/unionpay/dev/union/public_rsa.pem'),
],
],
'test' => [
'ysd' => [
'private' => storage_path('cert/unionpay/test/ysd/private_rsa.pem'),
'public' => storage_path('cert/unionpay/test/ysd/public_rsa.pem'),
],
'union' => [
'public' => storage_path('cert/unionpay/test/union/public_rsa.pem'),
],
],
],
//接口类型
'type' => [
'002025' => '查询',
'002100' => '交易',
'002101' => '冲正',
'002102' => '撤销',
'openid' => '封装openid参数',
'106040' => '领券',
'012100' => '核销通知',
'code' => '生活请求发券',
],
//日志类型对应
'log_type' => [
'002025' => 'query',
'002100' => 'freezecoupon',
'002101' => 'reversal',
'002102' => 'annul',
'openid' => 'openid',
'106040' => 'getcode',
'012100' => 'notify',
],
// 签名检查数据 没有为全数据
'checksign' => [
'default' => [
'in' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
'sign_type',
],
'out' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_sys_sn',
'msg_time',
'msg_ver',
'msg_rsp_code',
'msg_rsp_desc',
],
],
'106040' => [
'in' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
'sign_type',
],
'out' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_sys_sn',
'msg_time',
'msg_ver',
'msg_rsp_code',
'msg_rsp_desc',
],
],
'012100' => [
'in' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
],
'out' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
'msg_rsp_code',
'msg_rsp_desc',
],
],
],
//需要校验的数据
'validator' => [
'002025' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_flg",
"msg_sender",
"msg_time",
"msg_ver",
"msg_sys_sn",
"req_serial_no",
"mkt_code",
"amount",
"avl_amt",
],
'002100' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_flg",
"msg_sender",
"msg_time",
"msg_sys_sn",
"msg_ver",
"req_serial_no",
"orig_req_serial_no",
"sett_date",
"txn_date",
"txn_time",
"orig_amt",
"discount_amt",
],
'002101' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_flg",
"msg_sender",
"msg_time",
"msg_sys_sn",
"msg_ver",
"req_serial_no",
"orig_req_serial_no",
],
'002102' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_flg",
"msg_sender",
"msg_time",
"msg_sys_sn",
"msg_ver",
"req_serial_no",
"orig_req_serial_no",
],
//封装openid参数
'openid' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_sender",
"callback_type",
"callback_url",
],
//本时生活领券
'code' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_sender",
"issue_user_id",
"event_no",
"mobile",
],
//本时生活领券
'106040' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
// 'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
'sp_chnl_no',
'sp_order_no',
'order_date',
'event_no',
'issue_user_id',
],
//回调核销信息 校验数据项目
'012100' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
'mchnt_no',
'term_no',
'shop_no',
'req_serial_no',
'coupon_no',
'coupon_type',
'enc_card_no',
'acq_term_sn',
'refer_no',
'sett_date',
'txn_date',
'txn_time',
'orig_amt',
'discount_amt',
'pay_amt',
'pay_mode',
'event_no',
],
],
//入库基础数据
'regular' => [
'002025' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
// "msg_flg",
"msg_sender",
"msg_time",
"msg_ver",
"msg_sys_sn",//自己添加的基础数据
"req_serial_no",//自己添加的基础数据
"mkt_code",//自己添加的基础数据
],
'002100' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
// "msg_flg",
"msg_sender",
"msg_time",
"msg_sys_sn",
"msg_ver",
"req_serial_no",//自己添加的基础数据
"orig_req_serial_no",//自己添加的基础数据
"sett_date",//自己添加的基础数据
],
'002101' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
// "msg_flg",
"msg_sender",
"msg_time",
"msg_sys_sn",
"msg_ver",
"req_serial_no",//自己添加的基础数据
"orig_req_serial_no",//自己添加的基础数据
],
'002102' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
// "msg_flg",
"msg_sender",
"msg_time",
"msg_sys_sn",
"msg_ver",
"req_serial_no",//自己添加的基础数据
"orig_req_serial_no",//自己添加的基础数据
],
//封装获取openid数据
'openid' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_sender",
],
//本时生活领券
'code' => [
"msg_type",
"msg_txn_code",
"msg_crrltn_id",
"msg_sender",
],
//去联盟领券
'106040' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
// 'msg_flg',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
],
//回调核销信息
'012100' => [
'msg_type',
'msg_txn_code',
'msg_crrltn_id',
'msg_sender',
'msg_time',
'msg_sys_sn',
'msg_ver',
'req_serial_no',
'sett_date',
],
],
'fields' => [
//聚合营销优惠查询接口
'002025' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "报文流水号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"req_serial_no" => "查询流水号",
"shop_no" => "门店号",
"term_no" => "受理终端号",
"service_code" => "受理方式",
"voucher_no" => "受理凭证号",
"mkt_code" => "聚合营销码",
"mkt_mode" => "聚合营销类型",
"embedded_mchnt_no" => "发起渠道商户号",
"currency_code" => "货币代码",
"amount" => "消费金额",
"avl_amt" => "可优惠金额",
"term_sp_chnl_no" => "终端指定SP渠道号",
"func_code" => "功能码",
"times" => "次数",
"pay_mode" => "支付方式",
//用户附加信息
"user_ext_info" => [
"mobile_no" => "手机号",
"user_code" => "用户号",
"user_code_type" => "用户号类型",
"dev_id" => "设备id",
],
"sign" => "签名域",
],
'out' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "报文流水号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_rsp_code" => "响应码",
"msg_rsp_desc" => "响应码描述",
"discount" => "折扣金额",
"actual_amt" => "折后应收金额",
"pos_display" => "POS显示",
"pos_receipt" => "POS小票",
"pos_ad" => "POS广告",
"pos_mkt_ad" => "Pos_营销联盟广告",
"sign" => "签名域",
],
],
//销账交易接口
'002100' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"shop_no" => "门店号",
"term_no" => "终端号",
"req_serial_no" => "销券流水号",
"orig_req_serial_no" => "原查询流水号",
"enc_card_no" => "加密卡号",
"part_card_no" => "部分卡号",
"acq_term_sn" => "受理终端流水号",
"refer_no" => "检索参考号",
"sett_date" => "清算日期",
"txn_date" => "交易日期",
"txn_time" => "交易时间",
"orig_amt" => "原始金额",
"discount_amt" => "优惠的金额",
"pay_amt" => "支付金额",
"pay_mode" => "支付方式",
"order_no" => "订单号",
"trans_crrltn_no" => "交易关联流水号",
"equity_no" => "权益号",
"card_no" => "全卡号",
"sign" => "签名数据",
],
'out' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"msg_rsp_code" => "响应码",
"msg_rsp_desc" => "响应码描述",
"orig_amt" => "原始金额",
"discount_amt" => "折扣金额",
"pay_amt" => "支付金额",
"serv_chg" => "服务费",
"commission" => "佣金",
"ad" => "广告",
"pos_receipt" => "POS优惠",
"coupon_no" => "凭证号",
"coupon_type" => "凭证类型",
"sp_biz_code" => "SP统计码",
"charge_code" => "计费码",
"pos_event_title" => "SP活动主题",
"sp_contact" => "SP联系电话",
"sp_name" => "SP名称",
"event_no" => "活动号",
"td_code" => "二维码",
"memo" => "附言",
"mkt_sp_chnl_no" => "营销渠道号",
"point_amt" => "积分抵扣金额",
"sign" => "签名数据",
],
],
//销账冲正通知接口
'002101' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"shop_no" => "门店号",
"term_no" => "终端号",
"req_serial_no" => "冲正流水号",
"orig_req_serial_no" => "原始销账流水号",
"trans_crrltn_no" => "交易关联流水号",
"sign" => "签名数据",
],
'out' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"msg_rsp_code" => "响应码",
"msg_rsp_desc" => "响应码描述",
"sign" => "签名数据",
],
],
'002102' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"shop_no" => "门店号",
"term_no" => "终端号",
"req_serial_no" => "撤销流水号",
"orig_req_serial_no" => "原始销账流水号",
"trans_crrltn_no" => "交易关联流水号",
"sign" => "签名数据",
],
'out' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"msg_rsp_code" => "响应码",
"msg_rsp_desc" => "响应码描述",
"ad" => "广告",
"td_code" => "二维码",
"sign" => "签名数据",
],
],
'openid' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_sender" => "报文发送方",
"callback_type" => "回调类型",
"callback_url" => "回调地址",
],
'out' => [
"msg_sender" => "报文类型",
"nonce_str" => "随机码",
"timestamp" => "时间戳",
"auth_scope" => "授权类型",
"callback_type" => "回调类型",
"callback_url" => "回调地址",
"sign" => "签名数据",
],
],
'code' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_sender" => "报文发送方",
"issue_user_id" => "发券平台渠道用户id",//领取微信活动的券码送微信的openid
"event_no" => "活动号",
"mobile" => "手机号",
],
'out' => [
"code" => "优惠券",
"sign" => "签名数据",
],
],
//去联盟领券
'106040' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"shop_no" => "门店号",
"term_no" => "终端号",
"req_serial_no" => "撤销流水号",
"orig_req_serial_no" => "原始销账流水号",
"trans_crrltn_no" => "交易关联流水号",
'sp_chnl_no' => "渠道方",
'sp_order_no' => "第三方订单号",
'order_date' => "订单日期",
'event_no' => "活动号",
'issue_user_id' => "发券平台渠道用户id",
],
'out' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"msg_rsp_code" => "响应码",
"msg_rsp_desc" => "响应码描述",
"sign" => "签名数据",
],
],
//回调核销信息
'012100' => [
'in' => [
"msg_type" => "报文类型",
"msg_txn_code" => "交易代码",
"msg_crrltn_id" => "消息关联号",
"msg_flg" => "报文请求应答标志",
"msg_sender" => "报文发送方",
"msg_time" => "报文日期",
"msg_sys_sn" => "平台流水号",
"msg_ver" => "报文版本号",
"mchnt_no" => "商户号",
"term_no" => "终端号",
"shop_no" => "门店号",
"req_serial_no" => "销券流水号",
"coupon_no" => "凭证号",
"coupon_type" => "凭证类型",
"enc_card_no" => "加密卡号",
"acq_term_sn" => "受理终端流水号",
"refer_no" => "检索参考号",
"sett_date" => "清算日期",
"txn_date" => "交易日期",
"txn_time" => "交易时间",
"orig_amt" => "原始金额",
"discount_amt" => "优惠的金额",
"pay_amt" => "支付金额",
"pay_mode" => "支付方式",
"event_no" => "活动号",
"trans_crrltn_no" => "交易关联流水号",
"equity_no" => "权益号",
"order_no" => "订单号",
"point" => "使用的积分数量",
"point_amt" => "积分抵扣金额",
"point_account_no" => "积分账户号",
"mkt_uuid" => "联盟码申请流水号",
"custom_info" => "第三方自定义域",
],
],
],
];

23
config/wo.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
return [
'merchantCert' => storage_path('cert/wo/309700710354582.cer'),
'private' => storage_path('cert/wo/private_rsa.pem'),
'public' => storage_path('cert/wo/public_rsa.pem'),
'merchant_id' => '309700710354582',
'charset' => '00-GBK',
'version' => '1.0',
'signType' => 'RSA',
'channelType' => 'wbsh',
'baseUri' => 'http://123.125.97.251:8880/mpc/wbsh',
'ticketState' => [
'A' => 'ticketBuyback',
'U' => 'ticketInvalid',
],
'ticketStateText' => [
'A' => '已领用',
'U' => '已使用',
'E' => '已过期',
'H' => '已冻结',
],
];

View File

@@ -0,0 +1,27 @@
<?php
return [
'coupon_model' => \App\Models\Coupon::class,
'rules' => [
'ysd' => [
// 'pattern' => '/^YSD\d{12}/',
'pattern' => '/^YSD/',
'model' => \XuanChen\Coupon\Action\YsdAction::class,
],
'unionpay' => [
// 'pattern' => '/^YSD\d{12}/',
'pattern' => '/^66406/',
'model' => \XuanChen\Coupon\Action\YsdAction::class,
],
'pingan' => [
'pattern' => '/^\d{12}$/',
'model' => \XuanChen\Coupon\Action\PinganAction::class,
],
],
'froms' => [
'bsshop',//本时商城
'bslive',//本时生活
],
];

View File

@@ -1,12 +1,17 @@
<?php <?php
Route::get('/', 'IndexController@index')->name('index'); use App\Http\Controllers\CouponController;
Route::get('/test', 'TestController@index')->name('test'); use App\Http\Controllers\SkyxuController;
Route::get('/test/grant', 'TestController@grant')->name('test.grant'); use App\Http\Controllers\TestController;
Route::get('/test/checkcoupon', 'TestController@checkcoupon')->name('test.checkcoupon'); use App\Http\Controllers\IndexController;
Route::get('/test/query', 'TestController@query')->name('test.query');
Route::get('/test/destroy', 'TestController@destroy')->name('test.destroy');
Route::get('/test/getsign', 'TestController@getSign')->name('test.getsign');
Route::get('/skyxu', 'SkyxuController@index')->name('skyxu'); Route::get('/', [IndexController::class, 'index'])->name('index');
Route::get('/coupon', 'CouponController@index')->name('coupon'); Route::get('/test', [TestController::class, 'index'])->name('test');
Route::get('/test/grant', [TestController::class, 'grant'])->name('test.grant');
Route::get('/test/checkcoupon', [TestController::class, 'checkcoupon'])->name('test.checkcoupon');
Route::get('/test/query', [TestController::class, 'query'])->name('test.query');
Route::get('/test/destroy', [TestController::class, 'destroy'])->name('test.destroy');
Route::get('/test/getsign', [TestController::class, 'getSign'])->name('test.getsign');
Route::get('/skyxu', [SkyxuController::class, 'index'])->name('skyxu');
Route::get('/coupon', [CouponController::class, 'index'])->name('coupon');