zengyyh 4 months ago
commit c6dfff7c82
  1. 51
      app/api/service/order/PaySuccess.php
  2. 2
      app/common/library/payment/gateway/driver/Huifu.php
  3. 5
      app/common/model/MerchantPay.php
  4. 2
      app/common/service/qrcode/InviteUser.php

@ -344,27 +344,36 @@ class PaySuccess extends BaseService
// 当前订单信息 // 当前订单信息
$orderInfo = $this->getOrderInfo(); $orderInfo = $this->getOrderInfo();
// 余额支付 // 余额支付
if ($this->method == PaymentMethodEnum::BALANCE) { if ($this->method == PaymentMethodEnum::BALANCE || $this->method == PaymentMethodEnum::HUIFU) {
// 更新用户余额 if ($this->method == PaymentMethodEnum::BALANCE) {
UserModel::setDecBalance((int)$orderInfo['user_id'], (float)$orderInfo['pay_price']); // 更新用户余额
// 新增余额变动记录 UserModel::setDecBalance((int)$orderInfo['user_id'], (float)$orderInfo['pay_price']);
BalanceLogModel::add(SceneEnum::CONSUME, [ // 新增余额变动记录
'user_id' => (int)$orderInfo['user_id'], BalanceLogModel::add(SceneEnum::CONSUME, [
'money' => -$orderInfo['pay_price'], 'user_id' => (int)$orderInfo['user_id'],
], ['order_no' => $orderInfo['order_no']]); 'money' => -$orderInfo['pay_price'],
], ['order_no' => $orderInfo['order_no']]);
// //增加商户支付详情 }
// $model = \app\store\model\Merchant::detail($orderInfo['merchant_id']);
// $precent = 1;
if ($orderInfo['merchant_id']) {
// if ($model['commission_ratio']) { //增加商户支付详情
// $precent = (1 - $model['commission_ratio'] / 1000); $model = \app\store\model\Merchant::detail($orderInfo['merchant_id']);
// } if ($model) {
// $precentPrice = round($precent * $orderInfo['pay_price'], 2); $precent = 1;
// (new merchantPayModel())->addDetail($orderInfo, $precentPrice);
if ($model['commission_ratio']) {
// //累计商户余额支付金额 $precent = (1 - $model['commission_ratio'] / 1000);
// merchantModel::setIncTotal($orderInfo['merchant_id'], $precentPrice); }
$precentPrice = round($precent * $orderInfo['pay_price'], 2);
(new merchantPayModel())->addDetail($orderInfo, $precentPrice, $this->method == PaymentMethodEnum::HUIFU ? 1 : 0);
//累计商户余额支付金额
merchantModel::setIncTotal($orderInfo['merchant_id'], $precentPrice);
}
}
} }
// 将第三方交易记录更新为已支付状态 // 将第三方交易记录更新为已支付状态
if (in_array($this->method, [PaymentMethodEnum::WECHAT, PaymentMethodEnum::ALIPAY, PaymentMethodEnum::HUIFU])) { if (in_array($this->method, [PaymentMethodEnum::WECHAT, PaymentMethodEnum::ALIPAY, PaymentMethodEnum::HUIFU])) {

@ -249,6 +249,8 @@ class Huifu extends Driver
$headers = ["Authorization:".$authorization]; $headers = ["Authorization:".$authorization];
$data = httpRequest($refund_url, "POST", json_encode($params), $headers, false); $data = httpRequest($refund_url, "POST", json_encode($params), $headers, false);
//var_dump($data);
if ($data['errCode'] != "SUCCESS") { if ($data['errCode'] != "SUCCESS") {
$this->throwError($data['errMsg']); $this->throwError($data['errMsg']);
} }

@ -34,14 +34,15 @@ class MerchantPay extends BaseModel
* @param float $money * @param float $money
* @return mixed * @return mixed
*/ */
public function addDetail($orderInfo, $precentPrice) public function addDetail($orderInfo, $precentPrice, $source = 0)
{ {
if (!empty($orderInfo['merchant_id'])) { if (!empty($orderInfo['merchant_id'])) {
$data = [ $data = [
'order_id' => $orderInfo['order_id'], 'order_id' => $orderInfo['order_id'],
//'store_id' => $orderInfo['store_id'], 'store_id' => $orderInfo['store_id'],
'merchant_id' => $orderInfo['merchant_id'], 'merchant_id' => $orderInfo['merchant_id'],
'total_amount' => $precentPrice, 'total_amount' => $precentPrice,
'source' => $source,
]; ];
return $this->save($this->createData($data)); return $this->save($this->createData($data));
} }

@ -61,7 +61,7 @@ class InviteUser extends BaseQRcode
// 小程序码参数 // 小程序码参数
$scene = "refereeId:" . ($this->userInfo['user_id'] ?: ''); $scene = "refereeId:" . ($this->userInfo['user_id'] ?: '');
// 下载小程序码 // 下载小程序码
$page = 'pages/index/index'; $page = 'pages/login/index';
$qrcode = $this->getQrcode($storeId, $scene, $page, $this->channel); $qrcode = $this->getQrcode($storeId, $scene, $page, $this->channel);
//获取图片名称 //获取图片名称
$arr = explode('/', $qrcode); $arr = explode('/', $qrcode);

Loading…
Cancel
Save