|  | @@ -44,7 +44,63 @@ class Notify extends Api
 | 
	
		
			
				|  |  |                  // 修改用户钻石余额
 | 
	
		
			
				|  |  |                  $res2 = $userModel->where(["id" => $orderInfo["user_id"]])->setInc("jewel", $orderInfo["jewel"]);
 | 
	
		
			
				|  |  |                  // 添加钻石流水记录
 | 
	
		
			
				|  |  | -                $detail = "砖石充值";
 | 
	
		
			
				|  |  | +                $detail = "钻石充值";
 | 
	
		
			
				|  |  | +                $res3 = $jewellogModel->addUserJewelLog($userInfo["id"], $orderInfo["jewel"], "+", $userInfo["jewel"], $detail, 1);
 | 
	
		
			
				|  |  | +                // 添加充值记录
 | 
	
		
			
				|  |  | +                $res4 = $rechargelogModel->addRecord($userInfo["id"], $orderInfo["jewel"], $payamount, bcadd($userInfo["jewel"], $orderInfo["jewel"], 2), $userInfo["money"], $orderInfo["platform"], 1);
 | 
	
		
			
				|  |  | +                if ($res1 && $res2 && $res3 && $res4) {
 | 
	
		
			
				|  |  | +                    // 添加统计
 | 
	
		
			
				|  |  | +                    $userInfo->chargecount = $userInfo->chargecount + $payamount;
 | 
	
		
			
				|  |  | +                    $userInfo->chargetime = time();
 | 
	
		
			
				|  |  | +                    $userInfo->save();
 | 
	
		
			
				|  |  | +                    Db::commit();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } catch (ValidateException $e) {
 | 
	
		
			
				|  |  | +                Db::rollback();
 | 
	
		
			
				|  |  | +                $this->error($e->getMessage());
 | 
	
		
			
				|  |  | +            } catch (PDOException $e) {
 | 
	
		
			
				|  |  | +                Db::rollback();
 | 
	
		
			
				|  |  | +                $this->error($e->getMessage());
 | 
	
		
			
				|  |  | +            } catch (Exception $e) {
 | 
	
		
			
				|  |  | +                Db::rollback();
 | 
	
		
			
				|  |  | +                $this->error($e->getMessage());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //你可以在此编写订单逻辑
 | 
	
		
			
				|  |  | +        } catch (Exception $e) {
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        echo $pay->success();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 支付回调
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function alipaynotify()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        $paytype = "alipay";
 | 
	
		
			
				|  |  | +        $pay = Service::checkNotify($paytype);
 | 
	
		
			
				|  |  | +        if (!$pay) {
 | 
	
		
			
				|  |  | +            echo '签名错误';
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $data = $pay->verify();
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            $payamount = $data['total_fee'] / 100;
 | 
	
		
			
				|  |  | +            $out_trade_no = $data['out_trade_no'];
 | 
	
		
			
				|  |  | +            Db::startTrans();
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                $orderModel = new \app\common\model\RecharOrder();
 | 
	
		
			
				|  |  | +                $userModel = new \app\common\model\User();
 | 
	
		
			
				|  |  | +                $jewellogModel = new \app\common\model\UserJewelLog();
 | 
	
		
			
				|  |  | +                $rechargelogModel = new \app\common\model\UserRechargeLog();
 | 
	
		
			
				|  |  | +                $orderInfo = $orderModel->where(["order_no" => $out_trade_no])->find();
 | 
	
		
			
				|  |  | +                $userInfo = $userModel->where(["id" => $orderInfo["user_id"]])->find();
 | 
	
		
			
				|  |  | +                // 修改订单状态
 | 
	
		
			
				|  |  | +                $res1 = $orderModel->update(["status" => 1], ["order_no" => $out_trade_no]);
 | 
	
		
			
				|  |  | +                // 修改用户钻石余额
 | 
	
		
			
				|  |  | +                $res2 = $userModel->where(["id" => $orderInfo["user_id"]])->setInc("jewel", $orderInfo["jewel"]);
 | 
	
		
			
				|  |  | +                // 添加钻石流水记录
 | 
	
		
			
				|  |  | +                $detail = "钻石充值";
 | 
	
		
			
				|  |  |                  $res3 = $jewellogModel->addUserJewelLog($userInfo["id"], $orderInfo["jewel"], "+", $userInfo["jewel"], $detail, 1);
 | 
	
		
			
				|  |  |                  // 添加充值记录
 | 
	
		
			
				|  |  |                  $res4 = $rechargelogModel->addRecord($userInfo["id"], $orderInfo["jewel"], $payamount, bcadd($userInfo["jewel"], $orderInfo["jewel"], 2), $userInfo["money"], $orderInfo["platform"], 1);
 |