获取平安核销的订单号
This commit is contained in:
@@ -15,6 +15,7 @@ class IndexController extends AdminController
|
||||
|
||||
/**
|
||||
* Notes:
|
||||
*
|
||||
* @Author: <C.Jason>
|
||||
* @Date : 2019/9/18 14:50
|
||||
* @return Grid
|
||||
@@ -56,6 +57,7 @@ class IndexController extends AdminController
|
||||
}, '网点名称');
|
||||
|
||||
$filter->equal('type', '类型')->select(Coupon::TYPES);
|
||||
$filter->like('pa_order_id', '平安主订单号');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,6 +81,7 @@ class IndexController extends AdminController
|
||||
$grid->column('price', '核销金额');
|
||||
$grid->column('total', '订单金额');
|
||||
$grid->column('orderid', '订单id');
|
||||
$grid->column('pa_order_id', '平安主订单号')->hide();
|
||||
|
||||
$grid->column('资金通道结算')->display(function () {
|
||||
$profit = $this->status == 2 ? $this->profit : '0.00';
|
||||
|
||||
@@ -3,15 +3,20 @@
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Coupon;
|
||||
use App\Models\Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use XuanChen\Coupon\Action\pingan\Verification;
|
||||
|
||||
class TestController
|
||||
{
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
|
||||
$date = $request->date ?? date('Y-m-d');
|
||||
$time = Carbon::parse($date);
|
||||
|
||||
@@ -69,4 +74,82 @@ class TestController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 设置日志关联
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/1/19 11:12
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*/
|
||||
public function coupon(Request $request)
|
||||
{
|
||||
$type = $request->type ?? '';
|
||||
$date = $request->date ?? '';
|
||||
|
||||
if (! $type) {
|
||||
dd('type 错误');
|
||||
}
|
||||
|
||||
if (! $date) {
|
||||
dd('date 错误');
|
||||
}
|
||||
|
||||
$name = 'api_log_'.$date;//表名
|
||||
if (! Schema::hasTable($name)) {
|
||||
dd('数据表不存在');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn($name, 'coupon_no')) {
|
||||
Schema::table($name, function (Blueprint $table) {
|
||||
$table->string('coupon_no')->after('out_source')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置日志
|
||||
*/
|
||||
if ($type == 'log') {
|
||||
|
||||
(new Log())->setTable($name)
|
||||
->whereNull('coupon_no')
|
||||
->where('path', 'http://api.pingan.com.cn/open/vassPartner/appsvr/property/api/new/partner/redemption')
|
||||
->where('out_source->code', 200)
|
||||
->chunkById(1000, function ($logs) use ($name) {
|
||||
foreach ($logs as $log) {
|
||||
$data = (new Verification())->decrypt($log->in_source['json']['data']);
|
||||
$data = json_decode($data, true);
|
||||
$log->update([
|
||||
'coupon_no' => $data['couponNo']
|
||||
]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
dd($name.' 表日志设置完成');
|
||||
|
||||
}
|
||||
|
||||
if ($type == 'coupon') {
|
||||
(new Log())->setTable($name)
|
||||
->whereHas('coupon', function ($q) {
|
||||
$q->whereNull('pa_order_id');
|
||||
})
|
||||
->where('path', 'http://api.pingan.com.cn/open/vassPartner/appsvr/property/api/new/partner/redemption')
|
||||
->where('out_source->code', 200)
|
||||
->chunkById(1000, function ($logs) use ($name) {
|
||||
foreach ($logs as $log) {
|
||||
$log->coupon->update([
|
||||
'pa_order_id' => $log->out_source['data']['orderId'],
|
||||
'pa_sub_order_id' => $log->out_source['data']['subOrderId'],
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
dd($name.' 表关联的优惠券设置完成');
|
||||
}
|
||||
|
||||
|
||||
dd(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ Route::group([
|
||||
|
||||
$router->get('/', 'HomeController@index')->name('admin.home');
|
||||
$router->get('test', 'TestController@index')->name('test.index');
|
||||
$router->get('test/coupon', 'TestController@coupon')->name('test.index');
|
||||
|
||||
$router->post('uploads/editor', 'UploadController@editor')->name('uploads.editor');
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ class Log extends Model
|
||||
|
||||
/**
|
||||
* 为数组 / JSON 序列化准备日期。
|
||||
*
|
||||
* @param \DateTimeInterface $date
|
||||
* @return string
|
||||
*/
|
||||
@@ -70,4 +71,15 @@ class Log extends Model
|
||||
return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes: 关联优惠券
|
||||
*
|
||||
* @Author: 玄尘
|
||||
* @Date: 2022/1/19 11:24
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function coupon()
|
||||
{
|
||||
return $this->hasOne(Coupon::class, 'redemptionCode', 'coupon_no');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user