コード例 #1
0
ファイル: Common.php プロジェクト: emilymwang8/ajk-broker
 public static function &getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
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("*****@*****.**");
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $mailArr);
 }
コード例 #3
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" => "提现成功");
 }
コード例 #4
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>";
     }
 }
コード例 #5
0
 public function handle_request()
 {
     $queueList = $this->getRequestData();
     if (!empty($queueList)) {
         foreach ($queueList as $val) {
             $this->createTime = time();
             $userId = $val->userId;
             // 设置游标
             $this->setMyFlag($val->id);
             /*
              *1.Start 设置status = 1,为正在处理中  更新队列为处理状态(更新失败,跳出继续执行下一跳数据)
              */
             $status = array(Model_Fyk_MoneyActionFail::STATUS_NODEAL, Model_Fyk_MoneyActionFail::STATUS_ERROR);
             $check = Bll_Fyk_Payment_MoneyAction::getInstance()->updateFailQueueData(array('id' => $val->id, 'status' => $status), array('status' => Model_Fyk_MoneyActionFail::STATUS_DEALING));
             if (!$check) {
                 continue;
             }
             $val->add_old_property_value('status', Model_Fyk_MoneyActionFail::STATUS_DEALING);
             // 获取队列信息
             $tmpListData = Bll_Fyk_Payment_MoneyAction::getInstance()->getQueueDataById($val->listId);
             if (empty($tmpListData)) {
                 continue;
             }
             $listData = $tmpListData[0];
             $requestId = $val->requestId;
             $propId = !empty($listData->propId) ? $listData->propId : 0;
             /*
              * 2.执行扣钱或者加钱
              */
             $userAccoutId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
             $node = Bll_Fyk_Payment_Common::getInstance()->getPaymentNode($val->actionCode, $propId);
             $payResult = $this->mainDealMoney($userId, $val->price, $userAccoutId, "", $node, $requestId);
             if ($payResult['status'] == true) {
                 $newStatus = Model_Fyk_MoneyActionFail::STATUS_SUCCESS;
                 // 记录账户流水表
                 $addBalanceLogArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'propId' => $propId, 'listId' => $val->id, 'price' => $val->price, 'realPrice' => $val->price, 'amount' => $payResult['balance'], 'requestId' => $requestId, 'type' => $val->actionCode, 'createTime' => $this->createTime);
                 Bll_Fyk_Payment_Log::getInstance()->insertBalanceLog($addBalanceLogArr);
                 // 更新队列表
                 $this->updateQueueTable($listData, Model_Fyk_MoneyActionQueue::STATUS_SUCCESS);
                 Bll_Fyk_UserUnReadData::getInstance()->updateUnReadNum($userId, Model_Fyk_UserUnread::TYTE_AMOUNT);
             } else {
                 $newStatus = Model_Fyk_MoneyActionFail::STATUS_ERROR;
             }
             // 更新队列状态
             $this->updateFailQueueTable($val, $newStatus);
         }
     }
 }
コード例 #6
0
ファイル: Recharge.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $type = $this->_params['type'];
     $source = $this->_params['source'];
     $amount = $this->_params['amount'];
     //$amount = 1;
     $userAccoutId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
     if (empty($userAccoutId)) {
         return array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_ACTION_ACCOUNT_IS_NULL, "message" => "支付中心账户创建失败");
     }
     /*****************创建充值订单**********/
     $addArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'price' => $amount, 'payType' => $type, 'status' => Model_Fyk_RechargeOrder::STATUS_NODEAL, 'source' => $source, 'createTime' => time());
     $id = Bll_Fyk_Payment_Recharge::getInstance()->insertRechargeOrder($addArr);
     $tmpData = Bll_Fyk_Payment_Recharge::getInstance()->getRechargeOrderDataById($id);
     if (empty($id) || empty($tmpData)) {
         return array("status" => "error", "errcode" => Const_APIStatus::E_UNKNOWN, "message" => "充值插入数据库失败");
     }
     $rechargeOrder = $tmpData[0];
     $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("recharge", $id);
     $orderNo = Bll_Fyk_Payment_Common::getInstance()->createOrderNo("recharge", $requestId);
     $this->updateRechargeOrderTable($rechargeOrder, array('orderNo' => $orderNo, 'status' => Model_Fyk_RechargeOrder::STATUS_DEALING));
     /*****************生成支付中心充值参数**********/
     // 获取ack
     $tmpAckResult = Bll_Fyk_Payment_Common::getInstance()->getAckValue($userAccoutId);
     $ack = $tmpAckResult['status'] ? $tmpAckResult['sessionkey'] : "";
     $userData = Bll_Broker_User::getBrokerInfoByUserId($userId);
     $apps = APF::get_instance()->get_config('apps', 'acenter');
     $userName = !empty($userData) ? $userData['trueName'] : '';
     $orderName = "移动经纪人钱包充值";
     $appId = $apps['fyk']['appId'];
     $backUrl = $this->getBackUrl($id, $userId, $amount);
     $cityId = !empty($userData) ? $userData['cityId'] : '';
     $mobile = !empty($userData) ? $userData['userMobile'] : '';
     if (empty($userAccoutId) || empty($ack) || empty($userName) || empty($cityId) || empty($mobile)) {
         return array('status' => "error", "errcode" => Const_APIStatus::E_PARAM_MISS, "message" => "参数不正确");
     }
     $objApi = new Uri_PayCenterAPI();
     $acUrl = $objApi->redirectWabPayCenter($amount / 100, $userAccoutId, $ack, $userName, $orderName, $appId, $backUrl, $orderNo, $cityId, $mobile, $orderNo);
     return array('status' => "ok", 'data' => array('acUrl' => $acUrl), "message" => "成功");
 }
コード例 #7
0
 public function handle_request_internal()
 {
     $apf = APF::get_instance();
     $request = $apf->get_request();
     $act = $request->get_parameters();
     //操作类型
     $tmpAct = $act;
     $sign = $act['sign'];
     $signType = $act['sign_type'];
     $notifyTime = $act['notify_time'];
     unset($act['sign']);
     unset($act['sign_type']);
     $apps = APF::get_instance()->get_config('apps', 'acenter');
     $check = Bll_Fyk_Payment_Common::getInstance()->md5SignCheck($act, $apps['fyk']['appKey'], $sign);
     if ($check && time() - strtotime($notifyTime) < 30) {
         // 签名认证通过
         $this->dealMain($tmpAct);
         echo "success";
         exit;
     } else {
         echo "非法访问";
         exit;
     }
 }
コード例 #8
0
ファイル: Transfer.php プロジェクト: emilymwang8/ajk-broker
 public function buildAcenterBatchData($detailData, $payType, $batchNo, $batchNum, $totalAmount)
 {
     $note = "提现扣费";
     foreach ($detailData as $val) {
         $detail[] = array('biz_order_no' => $val['orderNo'], 'account_id' => $val['accountId'], 'user_alipay_name' => $val['transferName'], 'user_alipay_account' => $val['transferAccount'], 'need_amount' => $val['price'] / 100, 'note' => $note);
     }
     $apps = APF::get_instance()->get_config('apps', 'acenter');
     $callbackUrl = $this->getCallBackUrl();
     $notifyUrl = $this->getNotifyUrl();
     $msg = array('app_id' => $apps['fyk']['appId'], 'pay_type' => $payType, 'biz_batch_no' => $batchNo, 'biz_batch_num' => $batchNum, 'biz_batch_fee' => $totalAmount / 100, 'biz_notify_url' => $notifyUrl, 'biz_callback_url' => $callbackUrl, 'detail_data' => json_encode($detail));
     $sign = Bll_Fyk_Payment_Common::getInstance()->md5Sign($msg, $apps['fyk']['appKey']);
     $msg['sign'] = $sign;
     $msg['sign_type'] = 'MD5';
     return $msg;
 }
コード例 #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;
 }