作者 赵彬吉
@@ -11,7 +11,6 @@ use App\Models\Product\Keyword; @@ -11,7 +11,6 @@ use App\Models\Product\Keyword;
11 use App\Models\Product\KeywordRelated; 11 use App\Models\Product\KeywordRelated;
12 use App\Models\Product\Product; 12 use App\Models\Product\Product;
13 use App\Models\Project\Project; 13 use App\Models\Project\Project;
14 -use App\Models\RouteMap\RouteMap;  
15 use App\Models\WebSetting\WebLanguage; 14 use App\Models\WebSetting\WebLanguage;
16 use App\Services\BatchExportService; 15 use App\Services\BatchExportService;
17 use App\Services\ProjectServer; 16 use App\Services\ProjectServer;
@@ -35,7 +34,7 @@ class Temp extends Command @@ -35,7 +34,7 @@ class Temp extends Command
35 34
36 public function handle() 35 public function handle()
37 { 36 {
38 - $this->check_server_minor_site(); 37 +
39 } 38 }
40 39
41 /** 40 /**
@@ -63,7 +63,7 @@ class UpdateRoute extends Command @@ -63,7 +63,7 @@ class UpdateRoute extends Command
63 foreach ($list as $v){ 63 foreach ($list as $v){
64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
65 ProjectServer::useProject($v['id']); 65 ProjectServer::useProject($v['id']);
66 - $this->getProduct(); 66 + $this->setProductKeyword();
67 DB::disconnect('custom_mysql'); 67 DB::disconnect('custom_mysql');
68 } 68 }
69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
@@ -183,9 +183,9 @@ class UpdateRoute extends Command @@ -183,9 +183,9 @@ class UpdateRoute extends Command
183 if(!empty($lists)){ 183 if(!empty($lists)){
184 foreach ($lists as $v){ 184 foreach ($lists as $v){
185 if(!empty($v['route'])){ 185 if(!empty($v['route'])){
186 - echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;  
187 - $route = $this->setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);  
188 - $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); 186 +// echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
  187 +// $route = $this->setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
  188 +// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
189 continue; 189 continue;
190 }else{ 190 }else{
191 echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL; 191 echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
@@ -275,16 +275,16 @@ class UpdateRoute extends Command @@ -275,16 +275,16 @@ class UpdateRoute extends Command
275 $lists = $keywordModel->list(['status'=>1,'route'=>'']); 275 $lists = $keywordModel->list(['status'=>1,'route'=>'']);
276 if(!empty($lists)){ 276 if(!empty($lists)){
277 foreach ($lists as $v){ 277 foreach ($lists as $v){
278 - $tag = "-tag";  
279 - if (!(substr($v['route'], -strlen($tag)) === $tag)) {  
280 - echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;  
281 - $route = $v['route'].$tag; 278 +// $tag = "-tag";
  279 +// if (!(substr($v['route'], -strlen($tag)) === $tag)) {
  280 +// echo date('Y-m-d H:i:s') . '拼接'.$tag . PHP_EOL;
  281 + $route = $v['title'];
282 // 如果不是以 '-tag' 结尾,则拼接上 '-tag' 282 // 如果不是以 '-tag' 结尾,则拼接上 '-tag'
283 $routeModel = new RouteMap(); 283 $routeModel = new RouteMap();
284 $routeModel->edit(['route'=>$route],['source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,'source_id'=>$v['id']]); 284 $routeModel->edit(['route'=>$route],['source'=>RouteMap::SOURCE_PRODUCT_KEYWORD,'source_id'=>$v['id']]);
285 $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); 285 $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
286 echo date('Y-m-d H:i:s') . 'end'.$v['id'] . PHP_EOL; 286 echo date('Y-m-d H:i:s') . 'end'.$v['id'] . PHP_EOL;
287 - } 287 +// }
288 } 288 }
289 } 289 }
290 } 290 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :PayStripeApi.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/12/24 10:35
  8 + */
  9 +
  10 +namespace App\Helper;
  11 +
  12 +use App\Models\ExtentModule\ExtensionModuleValue;
  13 +
  14 +class PayStripeApi
  15 +{
  16 + private $secretKey;
  17 + //币种对应支付方式
  18 + public $currency_types = [
  19 + 'usd' => ['card', 'alipay', 'wechat_pay', 'cashapp', 'link', 'afterpay_clearpay'],
  20 + 'eur' => ['card', 'ideal', 'giropay', 'sofort', 'bancontact', 'klarna', 'link'],
  21 + 'gbp' => ['card', 'apple_pay', 'google_pay', 'klarna', 'link', 'afterpay_clearpay'],
  22 + 'aud' => ['card', 'afterpay_clearpay', 'apple_pay', 'google_pay'],
  23 + 'cad' => ['card', 'apple_pay', 'google_pay', 'link'],
  24 + 'sgd' => ['card', 'grabpay', 'fpx', 'wechat_pay', 'apple_pay', 'google_pay'],
  25 + 'jpy' => ['card', 'apple_pay', 'google_pay'],
  26 + 'cny' => ['alipay', 'wechat_pay'],
  27 + 'brl' => ['card', 'boleto', 'pix'],
  28 + 'mxn' => ['card', 'oxxo'],
  29 + 'inr' => ['card', 'upi', 'netbanking'],
  30 + 'php' => ['card', 'paymaya', 'gcash'],
  31 + 'myr' => ['card', 'fpx'],
  32 + 'thb' => ['card', 'promptpay'],
  33 + 'idr' => ['card', 'bank_transfer'],
  34 + 'zar' => ['card'],
  35 + 'ngn' => ['card'],
  36 + 'aed' => ['card', 'apple_pay', 'google_pay']
  37 + ];
  38 +
  39 + // 构造函数设置密钥
  40 + public function __construct()
  41 + {
  42 + $this->secretKey = 'sk_test_51MyseXIWCYVeLww1tbPZzRe1Qk4lS5d2VLiDjpju7G0ToiX1RJcFinQXNlftq9eCjZE0n2gjaz1mfy1g0mxTusdf00m636Gv62';
  43 + }
  44 +
  45 + /**
  46 + * @remark :通用的 cURL 请求方法
  47 + * @name :sendRequest
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2024/12/24 10:38
  51 + */
  52 + private function sendRequest($url, $method = 'POST', $data = [])
  53 + {
  54 + $ch = curl_init();
  55 + curl_setopt($ch, CURLOPT_URL, $url);
  56 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  57 + curl_setopt($ch, CURLOPT_HTTPHEADER, [
  58 + "Authorization: Bearer {$this->secretKey}",
  59 + "Content-Type: application/x-www-form-urlencoded"
  60 + ]);
  61 + if ($method === 'POST') {
  62 + curl_setopt($ch, CURLOPT_POST, true);
  63 + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  64 + } elseif ($method === 'GET') {
  65 + curl_setopt($ch, CURLOPT_HTTPGET, true);
  66 + } elseif ($method === 'DELETE') {
  67 + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
  68 + }
  69 + $response = curl_exec($ch);
  70 + if (curl_errno($ch)) {
  71 + throw new Exception('cURL Error: ' . curl_error($ch));
  72 + }
  73 + curl_close($ch);
  74 + return json_decode($response, true);
  75 + }
  76 +
  77 + /**
  78 + * @remark :创建支付意图
  79 + * @name :createPaymentIntent
  80 + * @author :lyh
  81 + * @method :post
  82 + * @time :2024/12/24 10:38
  83 + */
  84 + public function createPaymentIntent($amount, $currency = 'usd', $paymentMethodTypes = 'card')
  85 + {
  86 + $url = "https://api.stripe.com/v1/payment_intents";
  87 + $data = [
  88 + 'amount' => $amount,
  89 + 'currency' => $currency,
  90 + 'payment_method_types[]' => $paymentMethodTypes,
  91 + ];
  92 + return $this->sendRequest($url, 'POST', $data);
  93 + }
  94 +
  95 + /**
  96 + * @remark :查询支付意图
  97 + * @name :retrievePaymentIntent
  98 + * @author :lyh
  99 + * @method :post
  100 + * @time :2024/12/24 10:38
  101 + */
  102 + public function retrievePaymentIntent($paymentIntentId)
  103 + {
  104 + $url = "https://api.stripe.com/v1/payment_intents/{$paymentIntentId}";
  105 + return $this->sendRequest($url, 'GET');
  106 + }
  107 +
  108 + /**
  109 + * @remark :创建退款
  110 + * @name :createRefund
  111 + * @author :lyh
  112 + * @method :post
  113 + * @time :2024/12/24 10:42
  114 + */
  115 + public function createRefund($chargeId, $amount = null)
  116 + {
  117 + $url = "https://api.stripe.com/v1/refunds";
  118 + $data = ['charge' => $chargeId];
  119 + if ($amount) {
  120 + $data['amount'] = $amount;
  121 + }
  122 + return $this->sendRequest($url, 'POST', $data);
  123 + }
  124 +
  125 + /**
  126 + * @remark :查询退款
  127 + * @name :retrieveRefund
  128 + * @author :lyh
  129 + * @method :post
  130 + * @time :2024/12/24 10:42
  131 + */
  132 + public function retrieveRefund($refundId)
  133 + {
  134 + $url = "https://api.stripe.com/v1/refunds/{$refundId}";
  135 + return $this->sendRequest($url, 'GET');
  136 + }
  137 +
  138 + /**
  139 + * @remark :处理 Webhook
  140 + * @name :handleWebhook
  141 + * @author :lyh
  142 + * @method :post
  143 + * @time :2024/12/24 10:43
  144 + */
  145 + public static function handleWebhook()
  146 + {
  147 + try {
  148 + // Webhook 签名密钥(从 Stripe 仪表盘获取)
  149 + $endpointSecret = 'whsec_garhW2TrCIrduyM3rve9mFS2sn69B9Yt';
  150 + // 获取原始请求内容
  151 + $payload = request()->getContent();
  152 + // 获取 Stripe 签名头
  153 + $sigHeader = request()->header('Stripe-Signature');
  154 + // 验证签名
  155 + if (!self::verifySignature($payload, $sigHeader, $endpointSecret)) {
  156 + return [
  157 + 'code' => '201',
  158 + 'message' => 'Invalid signature',
  159 + 'details' => [
  160 + 'payload' => $payload,
  161 + 'sigHeader' => $sigHeader,
  162 + 'endpointSecret' => $endpointSecret,
  163 + ],
  164 + ]; // 返回 400 Bad Request 状态码;
  165 + }
  166 + $event = json_decode($payload, true);
  167 + // 获取事件类型
  168 + $eventType = $event['type'];
  169 + $eventData = $event['data']['object'];
  170 + // 根据事件类型处理
  171 + switch ($eventType) {
  172 + case 'payment_intent.succeeded':
  173 + // 处理支付成功逻辑
  174 + $paymentIntentId = $eventData['id'];
  175 + self::getExtensionInfo($paymentIntentId,$eventData);
  176 + break;
  177 + case 'payment_intent.payment_failed':
  178 + // 处理支付失败逻辑
  179 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($eventData, true) . PHP_EOL, FILE_APPEND);
  180 + $error = $eventData['last_payment_error'];
  181 + break;
  182 + case 'charge.refunded':
  183 + // 处理退款逻辑
  184 + $chargeId = $eventData['id'];
  185 + break;
  186 + default:
  187 + throw new \Exception('Unhandled event type: ' . $eventType);
  188 + }
  189 + return $event;
  190 + } catch (Exception $e) {
  191 + throw new \Exception('Webhook Error: ' . $e->getMessage());
  192 + }
  193 + }
  194 +
  195 + /**
  196 + * @remark :根据id获取当前数据详情
  197 + * @name :getExtensionInfo
  198 + * @author :lyh
  199 + * @method :post
  200 + * @time :2024/12/25 14:43
  201 + */
  202 + public static function getExtensionInfo($id,$eventData){
  203 + $extensionModel = new ExtensionModuleValue();
  204 + $info = $extensionModel->read(['value'=>$id]);
  205 + if($info === false){
  206 + @file_put_contents(storage_path('logs/lyh_3059_error.log'), var_export($id.':当前数据错误', true) . PHP_EOL, FILE_APPEND);
  207 + }
  208 + //组装数据保存
  209 + $data = [
  210 + ['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>6,'value'=>'success'],
  211 + ['uuid'=>$info['uuid'],'module_id'=>$info['module_id'],'field_id'=>7,'value'=>json_encode($eventData)],
  212 + ];
  213 + $moduleValueModel = new ExtensionModuleValue();
  214 + $moduleValueModel->insertAll($data);
  215 + }
  216 +
  217 + /**
  218 + * @remark :验证签名
  219 + * @name :verifySignature
  220 + * @author :lyh
  221 + * @method :post
  222 + * @time :2024/12/24 15:55
  223 + */
  224 + public static function verifySignature($payload, $sigHeader, $endpointSecret)
  225 + {
  226 + // 解析 Signature Header,获取 timestamp 和签名
  227 + if (!preg_match('/t=(\d+),v1=([a-f0-9]+)/', $sigHeader, $matches)) {
  228 + return false; // 签名格式错误
  229 + }
  230 + $timestamp = $matches[1]; // 提取时间戳
  231 + $receivedSignature = $matches[2]; // 提取签名
  232 + // 防止重放攻击:检查时间戳是否在 5 分钟以内
  233 + $currentTimestamp = time();
  234 + if (abs($currentTimestamp - $timestamp) > 300) {
  235 + return false; // 签名过期
  236 + }
  237 + // 计算预期签名
  238 + $signedPayload = "{$timestamp}.{$payload}";
  239 + $expectedSignature = hash_hmac('sha256', $signedPayload, $endpointSecret);
  240 + // 比较签名是否匹配
  241 + return hash_equals($expectedSignature, $receivedSignature);
  242 + }
  243 +
  244 +
  245 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :PayStripeController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/12/24 16:42
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Api;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Helper\PayStripeApi;
  14 +
  15 +class PayStripeController extends BaseController
  16 +{
  17 + /**
  18 + * @remark :回调方法
  19 + * @name :handleWebhook
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2024/12/24 15:41
  23 + */
  24 + public function handleWebhook(){
  25 + $pay = new PayStripeApi();
  26 + $data = $pay->handleWebhook();
  27 + $this->response('success',Code::SUCCESS,$data);
  28 + }
  29 +}
@@ -49,12 +49,6 @@ class OptimizeController extends BaseController @@ -49,12 +49,6 @@ class OptimizeController extends BaseController
49 if(!empty($lists) && !empty($lists['list'])){ 49 if(!empty($lists) && !empty($lists['list'])){
50 $rankDataModel = new RankData(); 50 $rankDataModel = new RankData();
51 foreach ($lists['list'] as $k => $v){ 51 foreach ($lists['list'] as $k => $v){
52 - $data = $rankDataModel->read(['project_id'=>$v['id'],'lang'=>''],['first_page_num','indexed_pages_num']);  
53 - $v['first_page_num'] = $data['first_page_num'] ?? 0;  
54 - $v['indexed_pages_num'] = $data['indexed_pages_num'] ?? 0;  
55 - $v['g'] = $this->getGNum($v['id']);  
56 - $v = $this->handleParam($v);  
57 -  
58 //特殊项目 两个api_no 52 //特殊项目 两个api_no
59 if($v['id'] == 2104){ 53 if($v['id'] == 2104){
60 $keyword_num_map = [10690=>100, 11201 => 50]; 54 $keyword_num_map = [10690=>100, 11201 => 50];
@@ -70,8 +64,13 @@ class OptimizeController extends BaseController @@ -70,8 +64,13 @@ class OptimizeController extends BaseController
70 $v['indexed_pages_num'] = implode(',', $v['indexed_pages_num']); 64 $v['indexed_pages_num'] = implode(',', $v['indexed_pages_num']);
71 $v['g'] = implode(',', $v['g']); 65 $v['g'] = implode(',', $v['g']);
72 $v['keyword_num'] = implode(',', $v['keyword_num']); 66 $v['keyword_num'] = implode(',', $v['keyword_num']);
  67 + }else{
  68 + $data = $rankDataModel->read(['project_id'=>$v['id'],'lang'=>''],['first_page_num','indexed_pages_num']);
  69 + $v['first_page_num'] = $data['first_page_num'] ?? 0;
  70 + $v['indexed_pages_num'] = $data['indexed_pages_num'] ?? 0;
  71 + $v['g'] = $this->getGNum($v['id']);
73 } 72 }
74 - 73 + $v = $this->handleParam($v);
75 $lists['list'][$k] = $v; 74 $lists['list'][$k] = $v;
76 } 75 }
77 } 76 }
@@ -224,6 +223,7 @@ class OptimizeController extends BaseController @@ -224,6 +223,7 @@ class OptimizeController extends BaseController
224 'gl_project_deploy_optimize.start_date AS start_date', 223 'gl_project_deploy_optimize.start_date AS start_date',
225 'gl_project_deploy_optimize.backlink AS backlink', 224 'gl_project_deploy_optimize.backlink AS backlink',
226 'gl_project_deploy_optimize.ai_video AS ai_video', 225 'gl_project_deploy_optimize.ai_video AS ai_video',
  226 + 'gl_project_deploy_optimize.api_no AS api_no',
227 'gl_domain_info.amp_status AS amp_status', 227 'gl_domain_info.amp_status AS amp_status',
228 'gl_domain_info.domain AS domain', 228 'gl_domain_info.domain AS domain',
229 ]; 229 ];
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Extension3059ModuleController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/12/25 9:44
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\ExtensionModule;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Helper\PayStripeApi;
  14 +use App\Http\Controllers\Bside\BaseController;
  15 +use App\Models\ExtentModule\ExtensionModuleField;
  16 +use App\Models\ExtentModule\ExtensionModuleValue;
  17 +use App\Services\ProjectServer;
  18 +use Illuminate\Support\Facades\DB;
  19 +
  20 +class Extension3059ModuleController extends BaseController
  21 +{
  22 + /**
  23 + * @remark :获取所有的支付方式
  24 + * @name :getPayMethod
  25 + * @author :lyh
  26 + * @method :post
  27 + * @time :2024/12/25 16:01
  28 + */
  29 + public function getPayMethod(){
  30 + $pay = new PayStripeApi();
  31 + $data = $pay->currency_types;
  32 + $this->response('success',Code::SUCCESS,$data);
  33 + }
  34 +
  35 + /**
  36 + * @remark :获取当前所有的商品列表
  37 + * @name :getProductLists
  38 + * @author :lyh
  39 + * @method :post
  40 + * @time :2024/12/25 9:37
  41 + */
  42 + public function get3059Product(){
  43 + ProjectServer::useProject(3059);
  44 + $this->param['module_id'] = $this->param['module_id'] ?? 2;//默认加载商品数据
  45 + $searchParam = [
  46 + 'module_id'=>$this->param['module_id'],
  47 + ];
  48 + $moduleValueModel = new ExtensionModuleValue();
  49 + if(isset($this->param['product_id'])){
  50 + $info = $moduleValueModel->read(['value'=>$this->param['product_id']]);
  51 + if($info === false){
  52 + $this->response('success');
  53 + }
  54 + $searchParam['uuid'] = $info['uuid'];
  55 + }
  56 + $data = [];
  57 + $filedData = $this->getFiledList();
  58 + $moduleValueModel = new ExtensionModuleValue();
  59 + $lists = $moduleValueModel->list($searchParam);
  60 + if(!empty($lists)){
  61 + foreach ($lists as $k => $v){
  62 + $data[$v['uuid']][$filedData[$v['field_id']]] = $v['value'];
  63 + $data[$v['uuid']]['created_at'] = $v['created_at'];
  64 + }
  65 + }
  66 + $resultData = [];
  67 + foreach ($data as $k => $v){
  68 + $v['uuid'] = $k;
  69 + $resultData[] = $v;
  70 + }
  71 + DB::disconnect('custom_mysql');
  72 + $this->response('success',Code::SUCCESS,$resultData);
  73 + }
  74 +
  75 + /**
  76 + * @remark :获取所有字段
  77 + * @name :getFiledList
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2024/12/25 14:13
  81 + */
  82 + public function getFiledList(){
  83 + $moduleFieldModel = new ExtensionModuleField();
  84 + $this->param['module_id'] = 2;//商品的所有字段
  85 + $filedList = $moduleFieldModel->list(['module_id'=>$this->param['module_id']],'sort',['id','field_name'],'desc');
  86 + $data = [];
  87 + if(!empty($filedList)){
  88 + foreach ($filedList as $k => $v){
  89 + $data[$v['id']] = $v['field_name'];
  90 + }
  91 + }
  92 + return $data;
  93 + }
  94 +
  95 + /**
  96 + * @remark :编辑订单详情
  97 + * @name :editOrderDetail
  98 + * @author :lyh
  99 + * @method :post
  100 + * @time :2024/12/25 10:26
  101 + */
  102 + public function save3059OrderDetail(){
  103 + ProjectServer::useProject(3059);
  104 +// $this->param = [
  105 +// 'amount'=>1000,
  106 +// 'currency'=>'cny',
  107 +// 'payment_method_types'=>'alipay',
  108 +// 'data'=>[
  109 +// ['field_id'=>2, 'value'=>'20241225114204'],
  110 +// ['field_id'=>3, 'value'=>date('Y-m-d H:i:s')],
  111 +// ['field_id'=>4, 'value'=>1000],
  112 +// ['field_id'=>5, 'value'=>'成都市武侯区二仙桥走成华大道'],
  113 +// ['field_id'=>9, 'value'=>'cny'],
  114 +// ['field_id'=>10, 'value'=>'alipay'],
  115 +// ['field_id'=>14, 'value'=>'二仙桥大爷'],
  116 +// ['field_id'=>15, 'value'=>'15687012587'],
  117 +// ]
  118 +// ];
  119 + $this->request->validate([
  120 + 'data'=>'required',
  121 + 'amount'=>'required',
  122 + 'currency'=>'required',
  123 + 'payment_method_types'=>'required',
  124 + ],[
  125 + 'data.required' => '数据不能为空',
  126 + 'amount.required' => '金额不能为空',
  127 + 'currency.required' => '币种不能为空',
  128 + 'payment_method_types.required' => '支付方式不能为空',
  129 + ]);
  130 + $this->param['module_id'] = 1;//默认订单模块
  131 + $moduleValueModel = new ExtensionModuleValue();
  132 + $info = $moduleValueModel->where('module_id',$this->param['module_id'])->orderBy('uuid','desc')->first();
  133 + if(empty($info)){
  134 + $uuid = 1;
  135 + }else{
  136 + $info = $info->toArray();
  137 + $uuid = $info['uuid'] + 1;
  138 + }
  139 + $saveData = [];
  140 + try {
  141 + //生成订单id
  142 + $saveData[] =['uuid'=>$uuid,'module_id'=>$this->param['module_id'],'field_id'=>1,'value'=>md5(uniqid(mt_rand(), true))];
  143 + $data = $this->param['data'];
  144 + $moduleValueModel = new ExtensionModuleValue();
  145 + foreach ($data as $k => $v){
  146 + $saveData[] = [
  147 + 'uuid'=>$uuid,
  148 + 'module_id'=>$this->param['module_id'],
  149 + 'field_id'=>$v['field_id'],
  150 + 'value'=>$v['value']
  151 + ];
  152 + }
  153 + $pay = new PayStripeApi();
  154 + $payData = $pay->createPaymentIntent($this->param['amount'],$this->param['currency'],$this->param['payment_method_types']);
  155 + $saveData[] = ['uuid'=>$uuid,'module_id'=>$this->param['module_id'],'field_id'=>8,'value'=>$data['id'] ?? '未获取到支付意愿,请重新获取'];
  156 + $moduleValueModel->insertAll($saveData);
  157 + }catch (\Exception $e){
  158 + $this->fail('error,请联系管理员');
  159 + }
  160 + DB::disconnect('custom_mysql');
  161 + $this->response('success',Code::SUCCESS,$payData);
  162 + }
  163 +}
@@ -16,6 +16,7 @@ use App\Models\ExtentModule\Extension2205ModuleValueLog; @@ -16,6 +16,7 @@ use App\Models\ExtentModule\Extension2205ModuleValueLog;
16 use App\Models\ExtentModule\ExtensionModule; 16 use App\Models\ExtentModule\ExtensionModule;
17 use App\Models\ExtentModule\ExtensionModuleField; 17 use App\Models\ExtentModule\ExtensionModuleField;
18 use App\Models\ExtentModule\ExtensionModuleValue; 18 use App\Models\ExtentModule\ExtensionModuleValue;
  19 +use App\Services\ProjectServer;
19 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
20 21
21 class ExtensionModuleController extends BaseController 22 class ExtensionModuleController extends BaseController
@@ -185,13 +186,7 @@ class ExtensionModuleController extends BaseController @@ -185,13 +186,7 @@ class ExtensionModuleController extends BaseController
185 foreach ($data as $k => $v){ 186 foreach ($data as $k => $v){
186 $info = $moduleValueModel->read(['uuid'=>$this->param['uuid'],'field_id'=>$v['field_id'],'module_id'=>$this->param['module_id']]); 187 $info = $moduleValueModel->read(['uuid'=>$this->param['uuid'],'field_id'=>$v['field_id'],'module_id'=>$this->param['module_id']]);
187 if($info === false){ 188 if($info === false){
188 - if($this->user['project_id'] == 2205 && $this->param['module_id'] == 1){  
189 - if($v['field_id'] == 12 && !empty($v['value'])){//下拉框数据  
190 - if($v['value'] != 'Ordered'){  
191 - $this->fail('请从第一个流程开始选择。');  
192 - }  
193 - }  
194 - } 189 + $this->edit2205ModuleValue($v);
195 $data = [ 190 $data = [
196 'uuid'=>$this->param['uuid'], 191 'uuid'=>$this->param['uuid'],
197 'module_id'=>$this->param['module_id'], 192 'module_id'=>$this->param['module_id'],
@@ -200,6 +195,22 @@ class ExtensionModuleController extends BaseController @@ -200,6 +195,22 @@ class ExtensionModuleController extends BaseController
200 ]; 195 ];
201 $moduleValueModel->addReturnId($data); 196 $moduleValueModel->addReturnId($data);
202 }else{ 197 }else{
  198 + $this->edit2205ModuleValue($v);
  199 + $moduleValueModel->edit(['value'=>$v['value'] ?? ''],['id'=>$info['id']]);
  200 + }
  201 + }
  202 + $this->response('success',Code::SUCCESS,['uuid'=>$this->param['uuid']]);
  203 + }
  204 +
  205 + /**
  206 + * @remark :2205项目单独处理
  207 + * @name :edit2205ModuleValue
  208 + * @author :lyh
  209 + * @method :post
  210 + * @time :2024/12/25 10:12
  211 + */
  212 + public function edit2205ModuleValue($v){
  213 + if(isset($this->param['id']) && !empty($this->param['id'])){
203 if($this->user['project_id'] == 2205 && $this->param['module_id'] == 1){ 214 if($this->user['project_id'] == 2205 && $this->param['module_id'] == 1){
204 if($v['field_id'] == 12 && (!empty($v['value']) && !empty($info['value']))){//下拉框数据 215 if($v['field_id'] == 12 && (!empty($v['value']) && !empty($info['value']))){//下拉框数据
205 $filedModel = new ExtensionModuleField(); 216 $filedModel = new ExtensionModuleField();
@@ -221,12 +232,16 @@ class ExtensionModuleController extends BaseController @@ -221,12 +232,16 @@ class ExtensionModuleController extends BaseController
221 } 232 }
222 } 233 }
223 } 234 }
224 - $moduleValueModel->edit(['value'=>$v['value'] ?? ''],['id'=>$info['id']]); 235 + }else{
  236 + if($this->user['project_id'] == 2205 && $this->param['module_id'] == 1){
  237 + if($v['field_id'] == 12 && !empty($v['value'])){//下拉框数据
  238 + if($v['value'] != 'Ordered'){
  239 + $this->fail('请从第一个流程开始选择。');
  240 + }
  241 + }
225 } 242 }
226 } 243 }
227 - $this->response('success',Code::SUCCESS,['uuid'=>$this->param['uuid']]);  
228 } 244 }
229 -  
230 245
231 /** 246 /**
232 * @remark :新增數據 247 * @remark :新增數據
@@ -252,13 +267,7 @@ class ExtensionModuleController extends BaseController @@ -252,13 +267,7 @@ class ExtensionModuleController extends BaseController
252 $data = $this->param['data']; 267 $data = $this->param['data'];
253 $moduleValueModel = new ExtensionModuleValue(); 268 $moduleValueModel = new ExtensionModuleValue();
254 foreach ($data as $k => $v){ 269 foreach ($data as $k => $v){
255 - if($this->user['project_id'] == 2205 && $this->param['module_id'] == 1){  
256 - if($v['field_id'] == 12 && !empty($v['value'])){//下拉框数据  
257 - if($v['value'] != 'Ordered'){  
258 - $this->fail('请重第一个流程开始选择');  
259 - }  
260 - }  
261 - } 270 + $this->edit2205ModuleValue($v);
262 $data = [ 271 $data = [
263 'uuid'=>$uuid, 272 'uuid'=>$uuid,
264 'module_id'=>$this->param['module_id'], 273 'module_id'=>$this->param['module_id'],
@@ -96,7 +96,7 @@ class KeywordController extends BaseController @@ -96,7 +96,7 @@ class KeywordController extends BaseController
96 * @method :post 96 * @method :post
97 * @time :2023/8/23 16:57 97 * @time :2023/8/23 16:57
98 */ 98 */
99 - public function info(Request $request, KeywordLogic $logic){ 99 + public function info(KeywordLogic $logic){
100 $data = $logic->getKeywordInfo(); 100 $data = $logic->getKeywordInfo();
101 if($data !== false){ 101 if($data !== false){
102 $data = $this->handleReturnInfo($data); 102 $data = $this->handleReturnInfo($data);
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Http\Controllers\Bside; 10 namespace App\Http\Controllers\Bside;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
  13 +use App\Helper\PayStripeApi;
13 use App\Http\Logic\Bside\News\NewsLogic; 14 use App\Http\Logic\Bside\News\NewsLogic;
14 use App\Models\Channel\Channel; 15 use App\Models\Channel\Channel;
15 use App\Models\CustomModule\CustomModuleCategory; 16 use App\Models\CustomModule\CustomModuleCategory;
@@ -34,7 +35,9 @@ class TestController extends BaseController @@ -34,7 +35,9 @@ class TestController extends BaseController
34 * @time :2024/11/11 14:51 35 * @time :2024/11/11 14:51
35 */ 36 */
36 public function ceshi(){ 37 public function ceshi(){
37 - $this->response('success',Code::SUCCESS,[]); 38 + $pay = new PayStripeApi();
  39 + $data = $pay->createPaymentIntent(5000,'cny','alipay');
  40 + $this->response('success',Code::SUCCESS,$data);
38 } 41 }
39 42
40 43
@@ -32,9 +32,9 @@ class ExtensionModuleFieldLogic extends BaseLogic @@ -32,9 +32,9 @@ class ExtensionModuleFieldLogic extends BaseLogic
32 public function saveModuleField(){ 32 public function saveModuleField(){
33 //先查看当前字段是否存在 33 //先查看当前字段是否存在
34 if(isset($this->param['id']) && !empty($this->param['id'])){ 34 if(isset($this->param['id']) && !empty($this->param['id'])){
35 - $info = $this->model->read(['field_name'=>$this->param['field_name'],'id'=>['!=',$this->param['id']]]); 35 + $info = $this->model->read(['field_name'=>$this->param['field_name'],'module_id'=>$this->param['module_id'],'id'=>['!=',$this->param['id']]]);
36 }else{ 36 }else{
37 - $info = $this->model->read(['field_name'=>$this->param['field_name']]); 37 + $info = $this->model->read(['field_name'=>$this->param['field_name'],'module_id'=>$this->param['module_id']]);
38 } 38 }
39 if($info !== false){ 39 if($info !== false){
40 $this->fail('当前字段名已存在'); 40 $this->fail('当前字段名已存在');
@@ -549,7 +549,7 @@ class ProductLogic extends BaseLogic @@ -549,7 +549,7 @@ class ProductLogic extends BaseLogic
549 */ 549 */
550 public function copyColumn($product_id,$new_product_id){ 550 public function copyColumn($product_id,$new_product_id){
551 $columnModel = new Column(); 551 $columnModel = new Column();
552 - $columnList = $columnModel->list(['product_id'=>$product_id]); 552 + $columnList = $columnModel->list(['product_id'=>$product_id],'id',['*'],'asc');
553 if(!empty($columnList)){ 553 if(!empty($columnList)){
554 foreach ($columnList as $k => $v){ 554 foreach ($columnList as $k => $v){
555 $column_id = $v['id']; 555 $column_id = $v['id'];
@@ -558,7 +558,7 @@ class ProductLogic extends BaseLogic @@ -558,7 +558,7 @@ class ProductLogic extends BaseLogic
558 $column_news_id = $columnModel->addReturnId($v); 558 $column_news_id = $columnModel->addReturnId($v);
559 //执行新增描述 559 //执行新增描述
560 $detailModel = new Detail(); 560 $detailModel = new Detail();
561 - $detailList = $detailModel->list(['product_id'=>$product_id,'column_id'=>$column_id]); 561 + $detailList = $detailModel->list(['product_id'=>$product_id,'column_id'=>$column_id],'id',['*'],'asc');
562 if(!empty($detailList)){ 562 if(!empty($detailList)){
563 $data = []; 563 $data = [];
564 foreach ($detailList as $val){ 564 foreach ($detailList as $val){
@@ -116,6 +116,24 @@ class Base extends Model @@ -116,6 +116,24 @@ class Base extends Model
116 } 116 }
117 117
118 /** 118 /**
  119 + * @remark :批量添加数据
  120 + * @name :addAllReturnId
  121 + * @author :lyh
  122 + * @method :post
  123 + * @time :2024/12/25 11:16
  124 + */
  125 + public function insertAll($data){
  126 + if(is_array($data)){
  127 + foreach ($data as $k => $sonData){
  128 + $sonData['created_at'] = date('Y-m-d H:i:s');
  129 + $sonData['updated_at'] = $sonData['created_at'];
  130 + $data[$k] = $sonData;
  131 + }
  132 + }
  133 + return $this->insert($data);
  134 + }
  135 +
  136 + /**
119 * @remark :统计数量 137 * @remark :统计数量
120 * @name :count 138 * @name :count
121 * @author :lyh 139 * @author :lyh
@@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Route; @@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Route;
17 Route::middleware('auth:sanctum')->get('/user', function (Request $request) { 17 Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
18 return $request->user(); 18 return $request->user();
19 }); 19 });
20 - 20 +Route::any('stripeWebhook', [\App\Http\Controllers\Api\PayStripeController::class, 'handleWebhook'])->name('api.handleWebhook');
21 Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit'); 21 Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit');
22 Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list'); 22 Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list');
23 Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route'); 23 Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route');
@@ -643,6 +643,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -643,6 +643,12 @@ Route::middleware(['bloginauth'])->group(function () {
643 }); 643 });
644 //无需登录验证的路由组 644 //无需登录验证的路由组
645 Route::group([], function () { 645 Route::group([], function () {
  646 + Route::prefix('extension_module')->group(function () {
  647 + //3059项目单独处理
  648 + Route::any('3059/getPayMethod', [\App\Http\Controllers\Bside\ExtensionModule\Extension3059ModuleController::class, 'getPayMethod'])->name('extension_module_getPayMethod');
  649 + Route::any('3059/get3059Product', [\App\Http\Controllers\Bside\ExtensionModule\Extension3059ModuleController::class, 'get3059Product'])->name('extension_module_get3059Product');
  650 + Route::any('3059/save3059OrderDetail', [\App\Http\Controllers\Bside\ExtensionModule\Extension3059ModuleController::class, 'save3059OrderDetail'])->name('extension_module_save3059OrderDetail');
  651 + });
646 Route::any('/login', [\App\Http\Controllers\Bside\LoginController::class, 'login'])->name('login'); 652 Route::any('/login', [\App\Http\Controllers\Bside\LoginController::class, 'login'])->name('login');
647 Route::any('/projectLogin', [\App\Http\Controllers\Bside\LoginController::class, 'projectLogin'])->name('projectLogin'); 653 Route::any('/projectLogin', [\App\Http\Controllers\Bside\LoginController::class, 'projectLogin'])->name('projectLogin');
648 Route::any('/ceshi', [\App\Http\Controllers\Bside\TestController::class, 'ceshi'])->name('ceshi'); 654 Route::any('/ceshi', [\App\Http\Controllers\Bside\TestController::class, 'ceshi'])->name('ceshi');