|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :Extension3059ModuleController.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/25 9:44
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bside\ExtensionModule;
|
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Helper\PayStripeApi;
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Models\ExtentModule\ExtensionModuleValue;
|
|
|
|
|
|
|
|
class Extension3059ModuleController extends BaseController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @remark :获取当前所有的商品列表
|
|
|
|
* @name :getProductLists
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/25 9:37
|
|
|
|
*/
|
|
|
|
public function getProductLists(){
|
|
|
|
$this->param['module_id'] = $this->param['module_id'] ?? 2;//默认加载商品数据
|
|
|
|
$searchParam = [
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
];
|
|
|
|
$data = [];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
$lists = $moduleValueModel->list($searchParam);
|
|
|
|
if(!empty($lists)){
|
|
|
|
foreach ($lists as $k => $v){
|
|
|
|
$data[$v['uuid']][$v['field_id']] = $v['value'];
|
|
|
|
$data[$v['uuid']]['created_at'] = $v['created_at'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$resultData = [];
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
$v['uuid'] = $k;
|
|
|
|
$resultData[] = $v;
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,$resultData);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :编辑订单详情
|
|
|
|
* @name :editOrderDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/12/25 10:26
|
|
|
|
*/
|
|
|
|
public function saveOrderDetail(){
|
|
|
|
$this->request->validate([
|
|
|
|
'data'=>'required',
|
|
|
|
'amount'=>'required',
|
|
|
|
'currency'=>'required',
|
|
|
|
'payment_method_types'=>'required',
|
|
|
|
],[
|
|
|
|
'data.required' => '数据不能为空',
|
|
|
|
'amount.required' => '金额不能为空',
|
|
|
|
'currency.required' => '币种不能为空',
|
|
|
|
'payment_method_types.required' => '支付方式不能为空',
|
|
|
|
]);
|
|
|
|
$this->param['module_id'] = 1;//默认订单模块
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
$info = $moduleValueModel->where('module_id',$this->param['module_id'])->orderBy('uuid','desc')->first();
|
|
|
|
if(empty($info)){
|
|
|
|
$uuid = 1;
|
|
|
|
}else{
|
|
|
|
$info = $info->toArray();
|
|
|
|
$uuid = $info['uuid'] + 1;
|
|
|
|
}
|
|
|
|
$saveData = [];
|
|
|
|
try {
|
|
|
|
//生成订单id
|
|
|
|
$saveData[] =['uuid'=>$uuid,'module_id'=>$this->param['module_id'],'field_id'=>1,'value'=>md5(uniqid(mt_rand(), true))];
|
|
|
|
$data = $this->param['data'];
|
|
|
|
$moduleValueModel = new ExtensionModuleValue();
|
|
|
|
foreach ($data as $k => $v){
|
|
|
|
$saveData[] = [
|
|
|
|
'uuid'=>$uuid,
|
|
|
|
'module_id'=>$this->param['module_id'],
|
|
|
|
'field_id'=>$v['field_id'],
|
|
|
|
'value'=>$v['value']
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$pay = new PayStripeApi();
|
|
|
|
$data = $pay->createPaymentIntent($this->param['amount'],$this->param['currency'],$this->param['payment_method_types']);
|
|
|
|
$saveData[] = ['uuid'=>$uuid,'module_id'=>$this->param['module_id'],'field_id'=>8,'value'=>$data['id'] ?? '未获取到支付意愿,请重新获取'];
|
|
|
|
$moduleValueModel->insertAll($saveData);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('error,请联系管理员');
|
|
|
|
}
|
|
|
|
$this->response('success',Code::SUCCESS,['uuid'=>$uuid,'data'=>$data]);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|