初始化项目
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\store\controller\partners;
|
||||
|
||||
use app\store\controller\Controller;
|
||||
use app\store\model\partners\BalanceLog as BalanceLogModel;
|
||||
|
||||
/**
|
||||
* 余额明细
|
||||
* Class Balance
|
||||
* @package app\store\controller\user
|
||||
*/
|
||||
class Balance extends Controller
|
||||
{
|
||||
/**
|
||||
* 余额明细
|
||||
* @return mixed
|
||||
*/
|
||||
public function log()
|
||||
{
|
||||
$model = new BalanceLogModel;
|
||||
$list = $model->getList($this->request->param());
|
||||
return $this->renderSuccess(compact('list'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\store\controller\partners;
|
||||
|
||||
use app\store\controller\Controller;
|
||||
use app\store\model\partners\Order as OrderModel;
|
||||
use app\store\model\Company as CompanyModel;
|
||||
use app\common\service\IdingjuOil;
|
||||
use app\store\model\order\QrCode as QrCodeModel;
|
||||
use app\common\service\QueueService;
|
||||
use think\response\Json;
|
||||
|
||||
/**
|
||||
* 余额明细
|
||||
* Class Order
|
||||
* @package app\store\controller\user
|
||||
*/
|
||||
class Order extends Controller
|
||||
{
|
||||
/**
|
||||
* 订单明细
|
||||
* @return mixed
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$model = new OrderModel;
|
||||
$list = $model->getList($this->request->param());
|
||||
return $this->renderSuccess($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付二维码
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function qrCode(): Json
|
||||
{
|
||||
$postData = $this->postForm();
|
||||
$postData['order_id'] = $this->request->param('orderId');
|
||||
|
||||
$order = OrderModel::detail($postData['order_id']);
|
||||
if($order['use_status'] != 0){
|
||||
return $this->renderError('油券已核销');
|
||||
}else {
|
||||
$company = CompanyModel::detail(['orgNo' => $this->getCompany($order['goods_no'])]);
|
||||
$IdingjuOil = new IdingjuOil();
|
||||
// 对接平台接口
|
||||
$res = $IdingjuOil->payQrCodeRequest(['order_no'=>$order['oilCardNo']], $company);
|
||||
if($res['code'] == '1' && isset($res['data']['useQrCodeUrl'])){
|
||||
// 插入支付码记录
|
||||
$QrCodeModel = new QrCodeModel();
|
||||
$QrCodeModel->add([
|
||||
'oilCardNo'=>$order['oilCardNo'],
|
||||
'qrCode'=>$res['data']['useQrCodeUrl'],
|
||||
'amount'=>$order['goods_price'],
|
||||
'order_id'=>$order['order_id'],
|
||||
'user_id'=>0,
|
||||
'store_id'=>$order['store_id'],
|
||||
]);
|
||||
$res = [
|
||||
'qrCode'=>$res['data']['useQrCodeUrl']
|
||||
];
|
||||
return $this->renderSuccess($res, '提交成功');
|
||||
}else{
|
||||
return $this->renderError($res['errMessage'] ?? $res['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $goodsNo
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany($goodsNo): string
|
||||
{
|
||||
switch ($goodsNo) {
|
||||
case 'djgdface100':
|
||||
case 'djgdface200':
|
||||
case 'djgdface300':
|
||||
return 'umQZhIHKofyA';
|
||||
case 'jmgxyyface100':
|
||||
case 'jmgxyyface200':
|
||||
case 'jmgxyyface300':
|
||||
|
||||
case 'jmgzface100':
|
||||
case 'jmgzface200':
|
||||
case 'jmgzface300':
|
||||
|
||||
case 'jmfjface100':
|
||||
case 'jmfjface200':
|
||||
case 'jmfjface300':
|
||||
return 'HpWqXIgYvTBg';
|
||||
case 'face003':
|
||||
return 'NKJBgaaRNdiL'; // 测试参数
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动分油
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function share(): Json
|
||||
{
|
||||
$IdingjuOil = new IdingjuOil();
|
||||
$postData = $this->request->param();
|
||||
$postData['order_id'] = $this->request->param('orderId');
|
||||
|
||||
$order = OrderModel::detail($postData['order_id']);
|
||||
if($order['oil_status'] != 0){
|
||||
return $this->renderError('已分油');
|
||||
}else {
|
||||
if($order['oilCardType']) {
|
||||
$data['amount'] = $order['total_price']; // 金额
|
||||
$company = CompanyModel::detail(['orgNo' => $this->getCompany($order['goods_no'])]);
|
||||
if (!$company) {
|
||||
return $this->renderError('已分油');
|
||||
}
|
||||
|
||||
// 对接平台接口
|
||||
$res = $IdingjuOil->oilOilCardShare([
|
||||
'goodsNo'=>$order['goods_no'],
|
||||
'amount'=>$data['amount'],
|
||||
'userNo'=>0,
|
||||
'mobile'=>$order['mobile'],
|
||||
'saleOrderNo'=>$order['oilCardNo'],
|
||||
'oilCardType'=>$order['oilCardType']
|
||||
], $company);
|
||||
if ($res['code'] != 1) {
|
||||
return $this->renderError($res['errMessage'] ?? $res['message']);
|
||||
}
|
||||
$IdingjuOil->saveLogStore("分油接口结果".json_encode($res,320));
|
||||
// $item['company_id'] = $company['company_id'];
|
||||
$item['shareNo'] = $res['data']['trade_no'] ?? '';
|
||||
$item['qrCode'] = $res['data']['useUrl'] ?? '';
|
||||
$item['oil_status_zsy'] = $res['data']['state'] ?? 0;
|
||||
$item['oil_time'] = time();
|
||||
$item['oil_status'] = $item['oil_status_zsy'] == 2 ? 1 : 0; // 已发券 为1
|
||||
$r = $order->save($item);
|
||||
$IdingjuOil->saveLogStore("保存分油结果".json_encode($r,320));
|
||||
return $this->renderSuccess('分油成功');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分油回调
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function oilCallback(): Json
|
||||
{
|
||||
/*
|
||||
$model = new OrderModel;
|
||||
$list = $model->getAll([
|
||||
['partners_id', '=', 4],
|
||||
['oil_status', '=', 1],
|
||||
['oil_callback', '=', 0],
|
||||
])->toArray();
|
||||
$queueService = new QueueService();
|
||||
foreach ($list as $order){
|
||||
// 存入队列处理
|
||||
$queueService->push('notify_queue', json_encode([
|
||||
'order_id' => $order['order_id'],
|
||||
'type' => 'add',
|
||||
'optType' => 'share_oil',
|
||||
'retry_count' => 0,
|
||||
], 320));
|
||||
}
|
||||
return $this->renderSuccess('回调成功');*/
|
||||
|
||||
$postData = $this->request->param();
|
||||
$postData['order_id'] = $this->request->param('orderId');
|
||||
|
||||
$order = OrderModel::detail($postData['order_id']);
|
||||
if($order['oil_status'] == 0){
|
||||
return $this->renderError('未分油');
|
||||
}else {
|
||||
// 存入队列处理
|
||||
$queueService = new QueueService();
|
||||
$queueService->push('notify_queue', json_encode([
|
||||
'order_id' => $order['order_id'],
|
||||
'type' => 'add',
|
||||
'optType' => 'share_oil',
|
||||
'retry_count' => 0,
|
||||
], 320));
|
||||
return $this->renderSuccess('回调成功');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用回调
|
||||
* @return Json
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
public function useCallback(): Json
|
||||
{
|
||||
/*
|
||||
$model = new OrderModel;
|
||||
$list = $model->getAll([
|
||||
['partners_id', '=', 4],
|
||||
['use_status', '=', 1],
|
||||
['use_callback', '=', 0],
|
||||
])->toArray();
|
||||
$queueService = new QueueService();
|
||||
foreach ($list as $order){
|
||||
// 存入队列处理
|
||||
$queueService->push('notify_queue', json_encode([
|
||||
'order_id' => $order['order_id'],
|
||||
'optType' => 'add_oil',
|
||||
'retry_count' => 0,
|
||||
], 320));
|
||||
}
|
||||
return $this->renderSuccess('回调成功');*/
|
||||
|
||||
$postData = $this->request->param();
|
||||
$postData['order_id'] = $this->request->param('orderId');
|
||||
|
||||
$order = OrderModel::detail($postData['order_id']);
|
||||
if($order['use_status'] == 0){
|
||||
return $this->renderError('未使用');
|
||||
}else {
|
||||
// 通知对接公司
|
||||
$queueService = new QueueService();
|
||||
$queueService->push('notify_queue', json_encode([
|
||||
'order_id' => $order['order_id'],
|
||||
'optType' => 'add_oil',
|
||||
'retry_count' => 0,
|
||||
], 320));
|
||||
return $this->renderSuccess('回调成功');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user