72 lines
2.8 KiB
PHP
72 lines
2.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Notes:支付后操作
|
|
* Created on: 2021/8/31 9:57
|
|
* Created by: dengbw
|
|
*/
|
|
class Payhd_service extends HD_Service
|
|
{
|
|
|
|
public function __construct($params)
|
|
{
|
|
parent::__construct();
|
|
if ($params['app_id']) {
|
|
$this->app_id = $params['app_id'];
|
|
}
|
|
$this->log_file = __CLASS__ . "_app_id_" . $this->app_id . '.log';
|
|
$this->load->model('apporder/order_purchase_model', 'mdOrderPurchase');
|
|
$this->load->model('bobing/bobing_user_model', 'mdBobingUser');
|
|
}
|
|
|
|
|
|
/**
|
|
* 支付后逻辑
|
|
* @param string $sid
|
|
* @param float $pay_price 订单真实支付金额
|
|
*/
|
|
public function after_pay($sid, $pay_price = '')
|
|
{
|
|
if ($sid) {
|
|
debug_log("[start] " . __FUNCTION__ . ": sid:" . $sid, $this->log_file);
|
|
$order = $this->mdOrderPurchase->get(array('sid' => $sid, 'app_id' => $this->app_id));
|
|
if (!$order) {
|
|
debug_log("[error] " . __FUNCTION__ . ":{$sid}_订单不存在", $this->log_file);
|
|
return array('code' => 0, 'msg' => '订单不存在');
|
|
}
|
|
if ($order['status'] > 1) {
|
|
debug_log("[error] " . __FUNCTION__ . ":{$sid}_订单已支付", $this->log_file);
|
|
return array('code' => 0, 'msg' => '订单已支付');
|
|
}
|
|
switch ($order['type']) {
|
|
case 1: //实物商品
|
|
break;
|
|
case 2: //虚拟物品
|
|
break;
|
|
case 3: //活动订单
|
|
$upd = array('status' => 2, 'status_detail' => 21, 'pay_time' => date('Y-m-d H:i:s'));
|
|
$pay_price && $upd['pay_price'] = $pay_price;
|
|
$res = $this->mdOrderPurchase->update($upd, array('id' => $order['id']));
|
|
if ($res) {
|
|
//博饼加购车金
|
|
$appConfig = $this->mdBobingUser->appConfig();
|
|
$where = array('act_key' => $appConfig['act_key'], 'app_id' => $appConfig['app_id'], 'uid' => $order['app_uid']);
|
|
$this->mdBobingUser->update(array("buy_car_gold" => $appConfig['buy_car_gold']), $where);
|
|
return array('code' => 1, 'msg' => '操作成功');
|
|
} else {
|
|
return array('code' => 0, 'msg' => '更新失败');
|
|
}
|
|
break;
|
|
case 4: //定金
|
|
break;
|
|
case 5: //委托服务费
|
|
case 6: //首付或尾款
|
|
break;
|
|
default:
|
|
debug_log("[error] " . __FUNCTION__ . ":{$order['type']}_未知商品类型", $this->log_file);
|
|
return array('code' => 0, 'msg' => '未知商品类型');
|
|
}
|
|
}
|
|
}
|
|
}
|