+
+
基础
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/app/api/controller/Buy.php b/app/api/controller/Buy.php
index dec03dbe6..1560aa4f9 100755
--- a/app/api/controller/Buy.php
+++ b/app/api/controller/Buy.php
@@ -54,11 +54,20 @@ class Buy extends Common
// 获取商品列表
$params = $this->data_post;
$params['user'] = $this->user;
- $ret = BuyService::BuyTypeGoodsList($params);
- // 商品校验
+ // 默认支付方式
+ $params['payment_id'] = PaymentService::BuyDefaultPayment($params);
+
+ // 订单初始化
+ $ret = BuyService::BuyOrderInit($params);
if(isset($ret['code']) && $ret['code'] == 0)
{
+ // 订单是否已提交、则直接进入订单支付
+ if(isset($ret['data']['is_order_submit']) && $ret['data']['is_order_submit'] == 1)
+ {
+ return ApiService::ApiDataReturn($ret);
+ }
+
// 基础信息
$buy_base = $ret['data']['base'];
$buy_goods = $ret['data']['goods'];
diff --git a/app/index/controller/Buy.php b/app/index/controller/Buy.php
index 6a30839ad..63b303efa 100755
--- a/app/index/controller/Buy.php
+++ b/app/index/controller/Buy.php
@@ -81,11 +81,20 @@ class Buy extends Common
// 参数
$params = array_merge($this->data_request, $data);
$params['user'] = $this->user;
- $ret = BuyService::BuyTypeGoodsList($params);
- // 商品校验
+ // 默认支付方式
+ $params['payment_id'] = PaymentService::BuyDefaultPayment($params);
+
+ // 订单初始化
+ $ret = BuyService::BuyOrderInit($params);
if(isset($ret['code']) && $ret['code'] == 0)
{
+ // 订单是否已提交、则直接进入订单支付
+ if(isset($ret['data']['is_order_submit']) && $ret['data']['is_order_submit'] == 1)
+ {
+ return MyRedirect($ret['data']['jump_url']);
+ }
+
// 基础信息
$buy_base = $ret['data']['base'];
$buy_goods = $ret['data']['goods'];
diff --git a/app/service/BuyService.php b/app/service/BuyService.php
index b506db2a0..e8a609e27 100755
--- a/app/service/BuyService.php
+++ b/app/service/BuyService.php
@@ -1131,6 +1131,7 @@ class BuyService
$order_status = 2;
}
}
+ $payment_id = intval($payment_id);
// 循环处理数据
$order_data = [];
@@ -1226,6 +1227,7 @@ class BuyService
$result = [
'order_status' => $order_status,
'order_ids' => $order_ids,
+ 'payment_id' => $payment_id,
'jump_url' => MyUrl('index/order/index'),
];
@@ -2226,5 +2228,35 @@ class BuyService
return DataReturn('操作成功', 0, $result);
}
+
+ /**
+ * 购买订单初始化
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2022-07-31
+ * @desc description
+ * @param [array] $params [输入参数]
+ */
+ public static function BuyOrderInit($params = [])
+ {
+ // 商品数据
+ $ret = self::BuyTypeGoodsList($params);
+ if(isset($ret['code']) && $ret['code'] == 0 && !empty($ret['data']))
+ {
+ // 是否开启虚拟订单快速创建订单
+ if($ret['data']['base']['site_model'] == 3 && MyC('common_fictitious_order_direct_pay') == 1)
+ {
+ // 调用订单添加
+ $ret = self::OrderInsert($params);
+ if($ret['code'] == 0)
+ {
+ // 标记订单已提交
+ $ret['data']['is_order_submit'] = 1;
+ }
+ }
+ }
+ return $ret;
+ }
}
?>
\ No newline at end of file
diff --git a/app/service/ConfigService.php b/app/service/ConfigService.php
index 1e00e2533..0c604fd5a 100755
--- a/app/service/ConfigService.php
+++ b/app/service/ConfigService.php
@@ -47,6 +47,7 @@ class ConfigService
'home_email_login_template',
'home_site_security_record_url',
'home_site_company_license',
+ 'common_default_payment',
];
// 附件字段列表
@@ -75,6 +76,11 @@ class ConfigService
'common_user_address_platform_import_list',
];
+ // json数组字段
+ public static $data_json_array_field_list = [
+ 'common_default_payment',
+ ];
+
// 需要文件缓存的key
public static $file_cache_keys = [
// 伪静态后缀
@@ -103,6 +109,9 @@ class ConfigService
'common_cdn_attachment_host',
'common_cdn_public_host',
+ // h5地址
+ 'common_app_h5_url',
+
// 编辑器配置信息
'home_max_limit_image',
'home_max_limit_video',
@@ -140,6 +149,15 @@ class ConfigService
$v['value'] = (!isset($v['value']) || $v['value'] == '' || is_array($v['value'])) ? [] : explode(',', $v['value']);
}
}
+
+ // json数据数组
+ foreach(self::$data_json_array_field_list as $fv)
+ {
+ if($k == $fv)
+ {
+ $v['value'] = empty($v['value']) ? [] : json_decode($v['value'], true);
+ }
+ }
}
}
return $data;
@@ -247,6 +265,15 @@ class ConfigService
}
}
+ // json数据数组
+ foreach(self::$data_json_array_field_list as $fv)
+ {
+ if(isset($data[$fv]))
+ {
+ $data[$fv] = empty($data[$fv]) ? [] : json_decode($data[$fv], true);
+ }
+ }
+
// 数据处理
foreach($data as $k=>&$v)
{
diff --git a/app/service/PaymentService.php b/app/service/PaymentService.php
index 0f4ccfd95..f54a5c2e3 100755
--- a/app/service/PaymentService.php
+++ b/app/service/PaymentService.php
@@ -1165,5 +1165,34 @@ php;
return DataReturn('无插件数据', 0);
}
+
+ /**
+ * 购买默认支付方式
+ * @author Devil
+ * @blog http://gong.gg/
+ * @version 1.0.0
+ * @date 2022-07-31
+ * @desc description
+ * @param [array] $params [输入参数]
+ */
+ public static function BuyDefaultPayment($params = [])
+ {
+ if(empty($params['payment_id']))
+ {
+ $payment_id = 0;
+ $default_payment = MyC('common_default_payment');
+ if(!empty($default_payment) && !empty($default_payment[APPLICATION_CLIENT_TYPE]))
+ {
+ $where = [
+ ['payment', '=', $default_payment[APPLICATION_CLIENT_TYPE]],
+ ['is_enable', '=', 1],
+ ['is_open_user', '=', 1],
+ ];
+ $payment_id = Db::name('Payment')->where($where)->value('id');
+ }
+ $params['payment_id'] = empty($payment_id) ? 0 : $payment_id;
+ }
+ return $params['payment_id'];
+ }
}
?>
\ No newline at end of file
diff --git a/public/static/common/css/common.css b/public/static/common/css/common.css
index 42857a03c..e9be313d6 100755
--- a/public/static/common/css/common.css
+++ b/public/static/common/css/common.css
@@ -935,4 +935,14 @@ form .am-tab-panel .am-form-group:last-child {
.warehouse-item-container .warehouse-icon {
width: 14px;
height: 14px;
+}
+
+/**
+ * 平台类型+数据值组合列表
+ */
+.platform-list-value-container > div.am-input-group:not(:first-child) {
+ margin-top: 10px;
+}
+.platform-list-value-container > div.am-input-group button {
+ width: 110px;
}
\ No newline at end of file