Commit c487b748 authored by wanjilong's avatar wanjilong

add: 提交创建支付订单模块

parent 72fb1170
...@@ -12,6 +12,7 @@ class PayException extends BaseException ...@@ -12,6 +12,7 @@ class PayException extends BaseException
protected $cus = [ protected $cus = [
0 => '用户已通过个人认证,无需重复认证', 0 => '用户已通过个人认证,无需重复认证',
1 => '企业已通过认证,无需重复认证' 1 => '企业已通过认证,无需重复认证',
4 => '费率计算错误,费率分母为0',
]; ];
} }
<?php
namespace Helpers;
/**
* Strategy 计算手续费策略
*/
class Strategy {
/**
* @param $current_amount
* @param $total_amount
* @param $cleared_amount
* @param $total_tip
* @param $cleared_tip
* 计算微信手续费公式,计算单位是分
*/
public static function getWxTip($current_amount, $total_amount, $cleared_amount, $total_tip, $cleared_tip) {
$left_amount = $total_amount - $cleared_amount;
if($left_amount == 0) {
return $left_amount;
}
return round($current_amount/$left_amount * ($total_tip - $cleared_tip));
}
/**
* @param $current_amount
* @param $total_amount
* @param $cleared_amount
* @param $total_tip
* @param $cleared_tip
* @return false|float
* 计算平台手续费
*/
public static function getTip($current_amount, $total_amount, $cleared_amount, $total_tip, $cleared_tip) {
$left_amount = $total_amount - $cleared_amount;
if($left_amount == 0) {
return $left_amount;
}
return round($current_amount/$left_amount * ($total_tip - $cleared_tip));
}
}
\ No newline at end of file
...@@ -24,4 +24,21 @@ class Dictionary ...@@ -24,4 +24,21 @@ class Dictionary
public const SOURCE_LIFE = 1; //生活圈 public const SOURCE_LIFE = 1; //生活圈
public const SOURCE_MAIN = 2; //主端 public const SOURCE_MAIN = 2; //主端
public const PAY_TYPE_IN = 1; //入账
public const PAY_TYPE_OUT = 2; //出账
public const PAY_SUB_TYPE_WX = 1; //微信手续费
public const PAY_SUB_TYPE_SYS_IN = 3; //平台营收
public const PAY_SUB_TYPE_M_IN = 4; //商家收入
public const PAY_SUB_TYPE_C_IN = 5; //团长收入
public const PAY_SUB_TYPE_SYS_OUT = 21; //平台补贴
public const PAY_SUB_TYPE_M_OUT = 22; //商家补贴
public const ACCOUNT_TYPE_C = 1; //用户
public const ACCOUNT_TYPE_M = 2; //商户
public const ACCOUNT_TYPE_SS = 3; //平台(平台收入+平台补贴)
public const ACCOUNT_TYPE_ST = 4; //平台交易总账+三方手续费
} }
...@@ -21,10 +21,38 @@ class PayOrder extends MysqlBase ...@@ -21,10 +21,38 @@ class PayOrder extends MysqlBase
return 'pay_order_id'; return 'pay_order_id';
} }
public function selectForUpdate($id) { /**
* @param $order_id
* @param $pay_order
* @return array
*/
public static function get_valid_order($order_id, $pay_order) {
$link = self::getConnection('write'); $link = self::getConnection('write');
$link->pdo-> $order = [];
$link->action(function($link, $order_id, $pay_order) use (&$order) {
$_date = date('Y-h-m H:i:s');
$sql = "select * from " . self::getTableName() . " where order_id = :order_id and expire_time >:date limit 1 for update";
$order = $link->query(
$sql, [
":order_id" => $order_id,
":date" => $_date
]
)->fetch();
if(empty($order)) {
$new['order_id'] = $order_id;
$link->insert(self::getTableName(), $pay_order);
$order = $link->query(
$sql, [
":order_id" => $order_id,
":date" => $_date
]
)->fetch();
}
});
return $order;
} }
} }
...@@ -25,7 +25,7 @@ class AccountController extends Base ...@@ -25,7 +25,7 @@ class AccountController extends Base
/** /**
* 创建未认证的个人生活号 * 创建未认证的个人生活号
*/ */
public function create_unauthorizedAction() public function createAction()
{ {
// 获取手机号 // 获取手机号
(new UserPhoneValidate())->validate(); (new UserPhoneValidate())->validate();
......
...@@ -55,6 +55,9 @@ class OrderService ...@@ -55,6 +55,9 @@ class OrderService
] ]
]; ];
foreach ($order_items as $r) { foreach ($order_items as $r) {
$order_distribution[] = [ $order_distribution[] = [
'commission_mode'=>1, 'commission_mode'=>1,
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"type": "project", "type": "project",
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "7.4.*", "php": "7.2.*",
"ext-json": "*", "ext-json": "*",
"api/php_utils":"dev-master", "api/php_utils":"dev-master",
"api/php_services":"dev-master", "api/php_services":"dev-master",
...@@ -41,4 +41,4 @@ ...@@ -41,4 +41,4 @@
"url":"https://gitlab.yidian-inc.com/bp/php_services.git" "url":"https://gitlab.yidian-inc.com/bp/php_services.git"
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment