|
|
|
@ -26,6 +26,7 @@ use service\SystemConfigService; |
|
|
|
|
use service\WechatService; |
|
|
|
|
use service\WechatTemplateService; |
|
|
|
|
use think\Cache; |
|
|
|
|
use think\Log; |
|
|
|
|
use think\Url; |
|
|
|
|
use traits\ModelTrait; |
|
|
|
|
use app\wap\model\user\MemberShip; |
|
|
|
@ -586,7 +587,17 @@ class StoreOrder extends ModelBasic |
|
|
|
|
if ($orderInfo['paid']) exception('支付已支付!'); |
|
|
|
|
if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!'); |
|
|
|
|
$openid = WechatUser::uidToOpenid($orderInfo['uid']); |
|
|
|
|
return WechatService::jsPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name')); |
|
|
|
|
$res = MiniProgramService::appPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name')); |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'appid' => $res['appid'], |
|
|
|
|
'partnerid' => $res['partnerid'], |
|
|
|
|
'prepayid' => $res['prepayid']['prepay_id'], |
|
|
|
|
'package'=> $res['package'], |
|
|
|
|
'noncestr'=> $res['noncestr'], |
|
|
|
|
'sign' => $res['sign'], |
|
|
|
|
'timestamp' => $res['timestamp'] |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 微信小程序支付 |
|
|
|
@ -684,16 +695,36 @@ class StoreOrder extends ModelBasic |
|
|
|
|
*/ |
|
|
|
|
public static function h5Pay($orderId, $field = 'order_id') |
|
|
|
|
{ |
|
|
|
|
//11 |
|
|
|
|
if (is_string($orderId)) |
|
|
|
|
$orderInfo = self::where($field, $orderId)->find(); |
|
|
|
|
$orderInfo = self::where($field, $orderId)->where('type', 2)->find(); |
|
|
|
|
else |
|
|
|
|
$orderInfo = $orderId; |
|
|
|
|
if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!'); |
|
|
|
|
if ($orderInfo['paid']) exception('支付已支付!'); |
|
|
|
|
if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!'); |
|
|
|
|
$site_name = SystemConfigService::get('site_name'); |
|
|
|
|
if (!$site_name) exception('支付参数缺少:请前往后台设置->系统设置-> 填写 网站名称'); |
|
|
|
|
return WechatService::paymentPrepare(null, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', self::getSubstrUTf8($site_name . '-商品购买', 30), '', 'MWEB'); |
|
|
|
|
$openid = WechatUser::uidToOpenid($orderInfo['uid']); |
|
|
|
|
$res = MiniProgramService::appPay($openid, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', SystemConfigService::get('site_name')); |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
'appid' => $res['appid'], |
|
|
|
|
'partnerid' => $res['partnerid'], |
|
|
|
|
'prepayid' => $res['prepayid']['prepay_id'], |
|
|
|
|
'package'=> $res['package'], |
|
|
|
|
'noncestr'=> $res['noncestr'], |
|
|
|
|
'sign' => $res['sign'], |
|
|
|
|
'timestamp' => $res['timestamp'] |
|
|
|
|
]; |
|
|
|
|
// if (is_string($orderId)) |
|
|
|
|
// $orderInfo = self::where($field, $orderId)->find(); |
|
|
|
|
// else |
|
|
|
|
// $orderInfo = $orderId; |
|
|
|
|
// if (!$orderInfo || !isset($orderInfo['paid'])) exception('支付订单不存在!'); |
|
|
|
|
// if ($orderInfo['paid']) exception('支付已支付!'); |
|
|
|
|
// if ($orderInfo['pay_price'] <= 0) exception('该支付无需支付!'); |
|
|
|
|
// $site_name = SystemConfigService::get('site_name'); |
|
|
|
|
// if (!$site_name) exception('支付参数缺少:请前往后台设置->系统设置-> 填写 网站名称'); |
|
|
|
|
// return WechatService::paymentPrepare(null, $orderInfo['order_id'], $orderInfo['pay_price'], 'goods', self::getSubstrUTf8($site_name . '-商品购买', 30), '', 'MWEB'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**商品余额支付 |
|
|
|
|