コード例 #1
0
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $num = Bll_Fyk_Payment_Amount::getInstance()->getUnReadNewAmountNum($userId);
     $result = array("status" => "ok", "noReadNum" => $num);
     return $result;
 }
コード例 #2
0
ファイル: UserAmount.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     //Bll_Fyk_Payment_Amount::getInstance()->payBackMoney(528,5000,"","","asddadf",1133);
     $userId = $this->_params['userId'];
     $result = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId);
     $ary = array("status" => "ok", "data" => array("amount" => number_format($result['balance'] / 100, 2), "amountUnit" => "元"));
     return $ary;
 }
コード例 #3
0
 public function handle_request()
 {
     $listData = $this->getRequestData();
     $errChargeUserId = array();
     $errDeleteLogUserId = array();
     $totalUserId = array();
     foreach ($listData as $val) {
         // 设置游标
         $this->setMyFlag($val['id']);
         $userId = intval($val['userId']);
         $totalUserId[] = $userId;
         $accountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId, false);
         if (empty($accountId)) {
             continue;
         }
         // 查询余额
         $balanceResult = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId, $accountId);
         if ($balanceResult && $balanceResult['status'] && $balanceResult['balance'] >= $this->defaltAmount) {
             $balance = $balanceResult['balance'];
         } else {
             continue;
         }
         $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("unActivateUserAmount", $val['id']);
         $note = "未激活用户,系统赠送的金钱回收";
         $chargeResult = Bll_Fyk_Payment_Amount::getInstance()->chargeMoney($userId, $balance, $accountId, $note, $requestId);
         if ($chargeResult['status'] == false) {
             $errChargeUserId[] = $userId;
             // 记录日志
             echo "扣费失败,userId:" . $userId . ",扣费金额:" . $balance . "\n";
             continue;
         }
         // 删除日志
         $deleteResult = Bll_Fyk_Payment_Log::getInstance()->deleteBalanceLogByUserId($userId);
         if ($deleteResult == 0) {
             $errDeleteLogUserId[] = $userId;
             echo "删除日志失败,userId:" . $userId;
         }
     }
     if ($errChargeUserId) {
         $mailBody = "扣费失败,userId:" . implode(',', $errChargeUserId);
     }
     if ($errDeleteLogUserId) {
         $mailBody .= "<br> 删除日志失败,userId:" . implode(',', $errDeleteLogUserId);
     }
     if (empty($mailBody)) {
         $mailBody = "没有异常";
     }
     $mailBody .= "<br> totalUserId:" . implode(',', $totalUserId);
     print_r($mailBody);
     // 发生邮件通知
     $mailSubject = "未激活用户,系统回收金额";
     $mailArr = array("kanhu@anjuke.com");
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $mailArr);
 }
コード例 #4
0
ファイル: Transfer.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $type = $this->_params['type'];
     $source = $this->_params['source'];
     $price = $this->_params['amount'];
     $transferAccount = $this->_params['transferAccount'];
     $transferName = $this->_params['transferName'];
     /***************查询余额,验证是否在范围之内 *******/
     $transferPriceInfo = APF::get_instance()->get_config('fyk_transfer_price');
     if ($transferPriceInfo['min'] * 100 > $price || $transferPriceInfo['max'] * 100 < $price) {
         return $result = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_USER_TRANSFER_AMOUNT_RANGE_ERROR, "message" => "不在提现范围之内");
     }
     //$price  = 1;
     /***************查询余额,验证是否够提现 **********/
     $userAccoutId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
     if (empty($userAccoutId)) {
         return $result = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_ACTION_ACCOUNT_IS_NULL, "message" => "支付中心账户创建失败");
     }
     $balanceResult = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId);
     if ($price > $balanceResult['balance']) {
         return $result = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_ACTION_LACK_OF_BALANCE, "message" => "余额不足");
     }
     /*************创建提现申请 *********************/
     $addArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'transferAccount' => $transferAccount, 'transferName' => $transferName, 'price' => $price, 'payType' => $type, 'chargeStatus' => Model_Fyk_TransferDetail::CHARGESTATUS_NODEAL, 'status' => Model_Fyk_TransferDetail::STATUS_INVALID, 'source' => $source, 'createTime' => time());
     $id = Bll_Fyk_Payment_Transfer::getInstance()->insertTransferDetail($addArr);
     $tmpDetailData = Bll_Fyk_Payment_Transfer::getInstance()->getTransferDetailById($id, "", true);
     if (empty($id) || empty($tmpDetailData)) {
         return array("status" => "error", "errcode" => Const_APIStatus::E_UNKNOWN, "message" => "提现插入数据库失败");
     }
     $detailData = $tmpDetailData[0];
     $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("transferDetail", $id);
     $orderNo = Bll_Fyk_Payment_Common::getInstance()->createOrderNo("transferDetail", $requestId);
     $this->updateDetailTable($detailData, array('requestId' => $requestId, 'orderNo' => $orderNo));
     /************** 提现扣费 **********************/
     $note = "提现扣费";
     $chargeResult = Bll_Fyk_Payment_Amount::getInstance()->chargeMoney($userId, $price, $userAccoutId, $note, $requestId);
     if ($chargeResult['status'] == false) {
         $this->updateDetailTable($detailData, array('chargeStatus' => Model_Fyk_TransferDetail::CHARGESTATUS_ERROR));
         return array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_TRANSFER_CHARGE_FAILURE, "message" => "提现扣费失败");
     }
     $this->updateDetailTable($detailData, array('chargeStatus' => Model_Fyk_TransferDetail::CHARGESTATUS_SUCCESS, 'status' => Model_Fyk_TransferDetail::STATUS_STRATVALID));
     // 记录账户流水表
     $this->insertBalanceLog($id, $userId, $userAccoutId, $price, $chargeResult['balance'], $requestId);
     // 跳转页面
     $twUrl = APF::get_instance()->get_config('wabTransferSuccessUrl');
     $twUrl .= "?amount=" . $price / 100;
     return array("status" => "ok", "data" => array("twUrl" => $twUrl), "message" => "提现成功");
 }
コード例 #5
0
 private function isNotify($rechargeOrderId, $userId, $userAccoutId, $price, $amount, $acOrderNo)
 {
     // 更新订单
     $keyData = array('id' => $rechargeOrderId, 'status' => Model_Fyk_RechargeOrder::STATUS_DEALING);
     $updateData = array('status' => Model_Fyk_RechargeOrder::STATUS_SUCCESS, 'acNotifyTime' => time(), 'acOrderNo' => $acOrderNo);
     $flag = Bll_Fyk_Payment_Recharge::getInstance()->updateRechargeOrder($keyData, $updateData);
     if ($flag) {
         // 记录账户流水表
         $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("recharge", $rechargeOrderId);
         $balanceResult = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId);
         $addBalanceLogArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'propId' => 0, 'listId' => $rechargeOrderId, 'price' => $price, 'realPrice' => $amount, 'amount' => $balanceResult['status'] ? $balanceResult['balance'] : 0, 'requestId' => $requestId, 'type' => Const_Fyk::THE_THIRD_PARTY_RECHARGE, 'createTime' => time());
         Bll_Fyk_Payment_Log::getInstance()->insertBalanceLog($addBalanceLogArr);
         echo "<result>1</result>";
     }
 }
コード例 #6
0
 public function mainDealMoney($userId, $price, $userAccoutId, $addDode, $node, $requestId)
 {
     $payResult = Bll_Fyk_Payment_Amount::getInstance()->payBackMoney($userId, $price, $userAccoutId, "", $node, $requestId);
     return $payResult;
 }
コード例 #7
0
ファイル: AmountLog.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $sinceId = isset($this->_params['sinceId']) ? $this->_params['sinceId'] : 0;
     $per = isset($this->_params['per']) ? $this->_params['per'] : 20;
     $per += 1;
     $hasNextPage = 0;
     $fPropId = array();
     $amountList = array();
     $logInfo = Bll_Fyk_Payment_Log::getInstance()->getLogInfoByUserIdOrderByIdDesc($userId, $per, $sinceId);
     if (!empty($logInfo)) {
         //判断是否有下一页
         if (isset($logInfo[$per - 1])) {
             $hasNextPage = 1;
             unset($logInfo[$per - 1]);
         }
         //房源数据获取
         foreach ($logInfo as $log) {
             $fPropId[] = $log['propId'];
         }
         $fPropId = array_unique($fPropId);
         $fPropInfo = Bll_Fyk_Prop_Manage::getInstance()->getPropInfo($fPropId);
         //获取app版本号
         $cv = 4.2;
         $chatInfos = Model_Mobile_BrokerChatInfo::getActiveBrokerIdsCV(array($this->_params['brokerId']));
         if (!empty($chatInfos)) {
             $chatInfo = $chatInfos[0];
             $response = Bll_Mobile_ChatInfoBll::getInstance()->apiGetChatInfoByCV($chatInfo['chatId']);
             $cv = $response['data']['result']['cv'];
         }
         //组装数据
         foreach ($logInfo as $log) {
             $list = array();
             $createTime = date('Y-m-d', $log['createTime']);
             list($comment, $content, $symbol, $clickAble) = $this->_loadingLogConfig(intval($log['type']));
             $amount = $this->_assemblyAmount($log['price'], $symbol);
             $type = $log['type'];
             $typeArr = array(Const_Fyk::THE_THIRD_PARTY_RECHARGE, Const_Fyk::THE_THIRD_PARTY_WITHDRAWAL, Const_Fyk::THE_THIRD_PARTY_WITHDRAWAL_FAILED);
             //4.3版本以下,做兼容处理 (支付宝提现,支付宝充值,支付宝提现失败,全部并入type=8)
             if ($cv < 4.3 && in_array($log['type'], $typeArr)) {
                 $type = 8;
             }
             $list['id'] = $log['id'];
             $list['amountType'] = $type;
             $list['comment'] = $comment;
             $list['content'] = $content;
             $list['amount'] = $amount;
             $list['amountUnit'] = '元';
             $list['fPropId'] = $log['propId'];
             $list['createTime'] = $createTime;
             $list['clickAble'] = $clickAble;
             $list['commName'] = '';
             $list['roomNum'] = '';
             $list['price'] = '';
             $list['priceUnit'] = '';
             $list['area'] = '';
             //获取房源基本信息
             if (empty($content)) {
                 if (!empty($fPropInfo[$log['propId']])) {
                     $commInfo = Bll_Community_APIComm::getInstance()->getInfoById($fPropInfo[$log['propId']]['commId']);
                     $list['commName'] = $commInfo['name'];
                     $list['roomNum'] = $fPropInfo[$log['propId']]['cell'];
                     $list['price'] = intval($fPropInfo[$log['propId']]['totalPrices']);
                     $list['priceUnit'] = '万';
                     $list['area'] = $fPropInfo[$log['propId']]['acreage'];
                 }
             }
             $amountList[] = $list;
         }
         //更新未读账户日志
         Bll_Fyk_Payment_Amount::getInstance()->updateUnReadNewAmountNum($userId);
     }
     $result = array('status' => 'ok', 'data' => array('amountList' => $amountList, 'hasNextPage' => $hasNextPage));
     return $result;
 }
コード例 #8
0
ファイル: Amount.php プロジェクト: emilymwang8/ajk-broker
 /**
  *  返回经纪人钱
  * @param $userId
  * @param $price
  * @param string $userAccountId
  * @param $addNode
  * @param $node
  * @param $requestId
  * @return array
  */
 public function payBackMoney($userId, $price, $userAccountId = "", $addNode, $node, $requestId)
 {
     $result = array('status' => false, 'msg' => '', 'balance' => 0);
     if (empty($userId) || empty($price) || empty($requestId)) {
         $result['msg'] = "参数不正确";
         return $result;
     }
     if (empty($userAccountId)) {
         // 获取到支付账户Id
         $accountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
     } else {
         $accountId = $userAccountId;
     }
     $count = 0;
     while (true) {
         if ($count >= 3) {
             break;
         }
         // 调用api,开始返钱
         $params = array('accountId' => $accountId, 'reqId' => $requestId, 'amount' => $price, 'addnote' => $addNode, 'note' => $node);
         $configPayment = Const_PaymentApp::FYK;
         $apiResult = Bll_Service_Payment::restitution($configPayment, $params);
         if ($apiResult->isSucceeded()) {
             $transferInfo = $apiResult->getTransferInfo();
             if ($apiResult['result'] == true) {
                 $result['status'] = true;
                 $balanceData = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId, $accountId);
                 if ($balanceData['status'] == true) {
                     $result['balance'] = $balanceData['balance'];
                 }
                 $result['msg'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code']));
                 break;
             } else {
                 $result['msg'] = array('response' => $apiResult->getResponse(), 'transferInfo' => array('url' => $transferInfo['url'], 'content_type' => $transferInfo['content_type'], 'http_code' => $transferInfo['http_code']));
                 $count++;
             }
         } else {
             $result['msg'] = '链接失败';
             $count++;
         }
     }
     // 记录请求支付中心日志
     $addLogArr = array('userId' => $userId, 'accountId' => $accountId, 'price' => $price, 'amount' => $result['balance'], 'requestId' => $requestId, 'status' => $result['status'] ? 2 : 1, 'msg' => json_encode($result['msg']), 'createTime' => time());
     Bll_Fyk_Payment_Log::getInstance()->insertPayRequestLog($addLogArr);
     return $result;
 }
コード例 #9
0
ファイル: Manage.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 购买房源
  * @param $userId
  * @param $propId
  * @param $source
  * @return array
  */
 public function addUserProp($userId, $propId, $source)
 {
     //$t1 = microtime(true);
     $result = array('status' => false, 'errcode' => '', 'msg' => '');
     if (empty($userId) || empty($propId) || empty($source)) {
         $result['errcode'] = Const_APIStatus::E_UNKNOWN;
         $result['msg'] = '参数不正确';
         return $result;
     }
     /*
      * 1、验证经纪人是否已经购买
      */
     $tmpUserPropData = $this->getUserPropByUserIdAndPropId($userId, $propId);
     if (!empty($tmpUserPropData)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_HAVE_TO_BUY;
         $result['msg'] = '该房源已购买';
         return $result;
     }
     /*
      * 2、验证房源是否存在
      */
     $propData = $this->getPropInfo($propId, array(Const_Fyk::PROPSTATUS_SELLING, Const_Fyk::PROPSTATUS_NOSELL));
     if (empty($propData)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_INFO_IS_NULL;
         $result['msg'] = '该房源不存在';
         return $result;
     }
     // 判断是否是测试账户
     if (!empty($_SERVER['PG_TEST'])) {
         //PG
         $testCommIds = APF::get_instance()->get_config('fyk_pg_test_commIds');
         $tmpTestUserIds = APF::get_instance()->get_config('fyk_pg_test_userIds');
     } else {
         $testCommIds = APF::get_instance()->get_config('fyk_ga_test_commIds');
         $tmpTestUserIds = APF::get_instance()->get_config('fyk_ga_test_userIds');
     }
     $testUserIds = array_values($tmpTestUserIds);
     if (in_array($userId, $testUserIds) && !in_array($propData[$propId]['commId'], $testCommIds)) {
         $result['errcode'] = Const_APIStatus::E_UNKNOWN;
         $result['msg'] = '测试账户,不能购买其他房源';
         return $result;
     } else {
         if (!in_array($userId, $testUserIds) && in_array($propData[$propId]['commId'], $testCommIds)) {
             $result['errcode'] = Const_APIStatus::E_UNKNOWN;
             $result['msg'] = '测试房源,您不能购买';
             return $result;
         }
     }
     //$t2 =  microtime(true);
     //echo '1.本地耗时'.round($t2-$t1,3)."<br>";
     $cityId = empty($propData[$propId]['cityId']) ? 0 : $propData[$propId]['cityId'];
     $userCityId = Bll_Broker_User::getCityIdByUserId($userId);
     if (empty($cityId) || empty($userCityId) || $cityId != $userCityId) {
         $result['errcode'] = Const_APIStatus::E_UNKNOWN;
         $result['msg'] = '经纪人城市id信息异常';
         return $result;
     }
     /*
      * 3、验证余额是否足够
      */
     $userAccoutId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
     if (empty($userAccoutId)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_ACCOUNT_IS_NULL;
         $result['msg'] = '支付账号不存在';
         return $result;
     }
     //$t3 =  microtime(true);
     //echo '2.本地耗时'.round($t3-$t2,3)."<br>";
     $balanceResult = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId, $userAccoutId);
     $balance = $balanceResult['status'] ? $balanceResult['balance'] : 0;
     //$t4 =  microtime(true);
     //echo '3.查询余额耗时'.round($t4-$t3,3)."<br>";
     // 获取购买价格
     $startDate = date("Ymd");
     $price = Bll_Fyk_Payment_Price::getInstance()->getPropUnitPrice($cityId, $startDate, Model_Fyk_CityPriceConfig::TYPE_BUY);
     if (empty($price)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_PRICE_ANOMALIES;
         $result['msg'] = '支付价格异常';
         return $result;
     }
     if ($balance < $price) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_LACK_OF_BALANCE;
         $result['msg'] = '余额不足';
         return $result;
     }
     /*
      * 4、添加订单
      */
     $addOrderData = array('accountId' => $userAccoutId, 'userId' => $userId, 'propId' => $propId, 'price' => $price, 'status' => Model_Fyk_UserOrder::ORDER_STATUS_NODEAL, 'requestId' => 0, 'source' => $source, 'createTime' => time());
     $orderId = Bll_Fyk_Order_Manage::getInstance()->insertData($addOrderData);
     // $t5 = microtime(true);
     // echo '5.本地耗时'.round($t5-$t4,3)."<br>";
     /*
      * 5.扣费
      */
     $note = "购买房源扣款,房源id为{$propId}";
     $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("order", $orderId);
     $payResult = Bll_Fyk_Payment_Amount::getInstance()->chargeMoney($userId, $price, $userAccountId = "", $note, $requestId);
     //$t6 = microtime(true);
     //echo '6.扣费耗时'.round($t6-$t5,3)."<br>";
     if ($payResult['status'] == false) {
         // 更新订单状态支付失败
         $updateOrderArr = array("status" => Model_Fyk_UserOrder::ORDER_STATUS_PAYFAIL, "requestId" => $requestId);
         Bll_Fyk_Order_Manage::getInstance()->updateData(array("id" => $orderId), $updateOrderArr);
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_PAY_FAILURE;
         $result['msg'] = '支付失败';
     } else {
         // 记录到账户流水表
         $addBalanceLogArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'propId' => $propId, 'listId' => $orderId, 'price' => $price, 'realPrice' => $price, 'amount' => $payResult['balance'], 'requestId' => $requestId, 'type' => Const_Fyk::USER_BUY_PROP, 'createTime' => time());
         Bll_Fyk_Payment_Log::getInstance()->insertBalanceLog($addBalanceLogArr);
         // 更新订单状态支付成功
         $updateOrderArr = array("status" => Model_Fyk_UserOrder::ORDER_STATUS_PAYSUCCESS, "requestId" => $requestId);
         Bll_Fyk_Order_Manage::getInstance()->updateData(array("id" => $orderId), $updateOrderArr);
         // 插入我的房源列表
         $addUserPropArr = array('cityId' => $cityId, 'userId' => $userId, 'propId' => $propId, 'source' => $source, 'status' => !empty($propData[$propId]['status']) ? $propData[$propId]['status'] : Const_Fyk::PROPSTATUS_DELETE, 'comeFrom' => Model_Fyk_UserProps::COME_FROM_BUY, 'createTime' => time());
         Model_Fyk_UserProps::getInstance()->insertData($addUserPropArr);
         Bll_Fyk_UserUnReadData::getInstance()->updateUnReadNum($userId, Model_Fyk_UserUnread::TYTE_AMOUNT);
         $result['status'] = true;
     }
     // 记录到扣费详细日志
     //$t7 = microtime(true);
     //echo '7.耗时'.round($t7-$t6,3)."<br>";
     //echo '8.总耗时'.round($t7-$t1,3).'秒';exit;
     return $result;
 }