Beispiel #1
0
 public function callback($data)
 {
     $this->logPay($data);
     $iMoney = $data['total_fee'] / 100;
     $sOrderID = $data['attach'];
     $aArg = array('iPayType' => Model_Finance::TYPE_WEIXIN, 'sPayAccount' => $data['openid'], 'sPayOrder' => $data['transaction_id']);
     return Model_Finance::pay($sOrderID, $iMoney, $aArg);
 }
Beispiel #2
0
 public function action_index()
 {
     $pagination = \Pagination::forge('default', ['name' => 'bootstrap3', 'total_items' => \Model_Finance::count(), 'per_page' => 50, 'uri_segment' => 'p', 'num_links' => 20]);
     $conditions = array('rows_limit' => $pagination->per_page, 'rows_offset' => $pagination->offset);
     $finances = Model_Finance::find('all', $conditions);
     $auctions_sum = \DB::select(\DB::expr('SUM(price) AS auctions_sum'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where('username', Config::get('my.main_bidder'))->execute();
     $items_count = \DB::select(\DB::expr('SUM(item_count) AS items_count'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where('username', Config::get('my.main_bidder'))->execute();
     $parts_sum = \DB::select(\DB::expr('SUM(price) AS parts_sum'))->from('parts')->execute();
     $usd = \DB::select(\DB::expr('SUM(Case When usd < 0 then usd else 0 end) AS usd'))->from('balances')->execute();
     $usd_balance = \DB::select(\DB::expr('SUM(usd) AS usd_balance'))->from('balances')->execute();
     $jpy = \DB::select(\DB::expr('SUM(jpy) AS jpy'))->from('balances')->execute();
     $balance = $jpy[0]['jpy'];
     $balance -= $auctions_sum[0]['auctions_sum'];
     $balance -= $parts_sum[0]['parts_sum'];
     $balance -= $items_count[0]['items_count'] * Config::get('my.commission');
     $this->template->title = "Finances";
     $this->template->content = View::forge('admin/finance/index', ['finances' => $finances, 'usd' => $usd[0]['usd'], 'usd_balance' => $usd_balance[0]['usd_balance'], 'jpy' => $jpy[0]['jpy'], 'balance' => $balance]);
 }
Beispiel #3
0
 /**
  * 支付宝
  */
 public function notifyAction()
 {
     $aParam = $this->getParams();
     Yaf_Logger::debug('notify: ' . json_encode($aParam, JSON_UNESCAPED_UNICODE) . "\n", 'alipay');
     $bRet = Payment_Alipay::callback($aParam);
     $iOrderID = $aParam['out_trade_no'];
     $iMoney = $aParam['total_fee'];
     if ($bRet) {
         // 支付成功
         $this->logPay($aParam);
         $aArg = array('iPayType' => Model_Finance::TYPE_ALIPAY, 'sPayAccount' => $aParam['buyer_email'], 'sPayOrder' => $aParam['trade_no']);
         Model_Finance::pay($iOrderID, $iMoney, $aArg);
         echo "success";
     } else {
         // 支付失败
         echo "fail";
     }
     return false;
 }
Beispiel #4
0
    /**
     * 导出
     */
    public function explodeAction()
    {
        $uWhere = array();
        $aParam = $this->getParams();
        $userid = '';
        if (!empty($aParam['sRealName'])) {
            $uWhere['sRealName LIKE'] = '%' . $aParam['sRealName'] . '%';
            $data_user = Model_User::getAll(array('where' => $uWhere));
            $useridArr = array();
            foreach ($data_user as $val) {
                if ($val['iUserID'] != '') {
                    $useridArr[] = $val['iUserID'];
                }
            }
            if (count($useridArr) > 0) {
                $userid = implode(',', array_unique($useridArr));
            }
        }
        $aWhere = array();
        if (!empty($aParam['iUserID'])) {
            $aWhere['iUserID'] = $aParam['iUserID'];
        }
        if ($userid != '') {
            $aWhere['iUserID IN'] = $userid;
        }
        if (!empty($aParam['iPayment']) && $aParam['iPayment'] != '') {
            $aWhere['iPayment'] = $aParam['iPayment'];
        }
        if (!empty($aParam['iSource']) && $aParam['iSource'] != '') {
            $aWhere['iSource'] = $aParam['iSource'];
        }
        if (!empty($aParam['sRealName']) && $aParam['sRealName'] != '') {
            $aWhere['sRealName LIKE'] = '%' . $aParam['sRealName'] . '%';
        }
        if (!empty($aParam['iPayType']) && $aParam['iPayType'] != '') {
            $aWhere['iPayType'] = $aParam['iPayType'];
        }
        if (!empty($aParam['iPayStatus']) && $aParam['iPayStatus'] != '') {
            $aWhere['iPayStatus'] = $aParam['iPayStatus'];
        }
        $aList = Model_Finance::getAll(array('where', $aWhere));
        header("Content-type:application/vnd.ms-excel");
        header("Content-Disposition:filename=财务_" . date('Y-m-d', time()) . ".xls");
        $str_explode = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /><title>导出</title><style>td{text-align:center;font-size:12px;font-family:Arial, Helvetica, sans-serif;border:#1C7A80 1px solid;color:#152122;width:100px;}table,tr{border-style:none;}.title{background:#7DDCF0;color:#FFFFFF;font-weight:bold;}</style></head><body>";
        $str_explode .= '<table cellspacing="0" cellpadding="3" rules="rows" border="1" id="" style="border-style:None;width:100%;border-collapse:collapse;">
							<tr>
								<th scope="col">用户名称/th>
								<th scope="col">收支情况</th>
								<th scope="col">事件来源</th>
								<th scope="col">申请人</th>
								<th scope="col">支付类型</th>
								<th scope="col">本次金额</th>
								<th scope="col">用户余额</th>
								<th scope="col">银行开户姓名</th>
								<th scope="col">开户银行</th>
								<th scope="col">支付帐号</th>
								<th scope="col">支付状态</th>
								<th scope="col">支付流水号</th>
								<th scope="col">备注</th>
								<th scope="col">时间</th>
							</tr>';
        foreach ($aList as $key => $val) {
            $row = Model_User::getDetail($val['iUserID']);
            $sUserRealName = isset($row) && $row['sRealName'] != '' ? $row['sRealName'] : '';
            $iPayment = isset($val['iPayment']) && $val['iPayment'] == '1' ? '收入' : '支出';
            $iSource = '';
            if ($val['iSource'] == '1') {
                $iSource = '自主充值';
            } elseif ($val['iSource'] == '2') {
                $iSource = '付款充值';
            } elseif ($val['iSource'] == '3') {
                $iSource = '拒单退款';
            } elseif ($val['iSource'] == '4') {
                $iSource = '取现';
            } elseif ($val['iSource'] == '5') {
                $iSource = '广告费用';
            }
            $sRealName = $val['sRealName'];
            $iPayType = '';
            if ($val['iPayType'] == '1') {
                $iPayType = '支付宝';
            } elseif ($val['iPayType'] == '2') {
                $iPayType = '微信';
            } elseif ($val['iPayType'] == '3') {
                $iPayType = '银行卡';
            }
            $iPayMoney = $val['iPayMoney'];
            $iUserMoney = $val['iUserMoney'];
            $sOpenName = $val['sOpenName'];
            $sBankName = $val['sBankName'];
            $sPayAccount = $val['sPayAccount'];
            $iPayStatus = isset($val['iPayStatus']) && $val['iPayStatus'] == '0' ? '未支付' : '已支付';
            $sPayOrder = $val['sPayOrder'];
            $sRemark = $val['sRemark'];
            $iCreateTime = date('Y-m-d H:i:s', $val['iCreateTime']);
            $str_explode .= '<tr>
								<td align="left">' . $sUserRealName . '</td>
								<td align="left">' . $iPayment . '</td>
								<td align="left">' . $iSource . '</td>
								<td align="left">' . $sRealName . '</td>
								<td align="left">' . $iPayType . '</td>
								<td align="left">' . $iPayMoney . '</td>
								<td align="left">' . $iUserMoney . '</td>
								<td align="left">' . $sOpenName . '</td>
								<td align="left">' . $sBankName . '</td>
								<td align="left">' . $sPayAccount . '</td>
								<td align="left">' . $iPayStatus . '</td>
								<td align="left">' . $sPayOrder . '</td>
								<td align="left">' . $sRemark . '</td>
								<td align="left">' . $iCreateTime . '</td>
							</tr>';
        }
        $str_explode .= '</table>';
        $str_explode .= "</body></html>";
        echo $str_explode;
    }
Beispiel #5
0
 /**
  * 提现申请
  */
 public function cashoutAction()
 {
     if ($this->isPost()) {
         $aUser = Model_User::getDetail($this->aCurrUser['iUserID']);
         $aParam = $this->getParams();
         $aParam['iPayMoney'] = (int) $this->getParam('iPayMoney');
         $aParam['iPayType'] = (int) $this->getParam('iPayType');
         $aErr = array();
         if (empty($aParam['sRealName'])) {
             $aErr['sRealName'] = '请输入申请人';
         }
         if (empty($aParam['iPayMoney']) || intval($aParam['iPayMoney']) < 1) {
             $aErr['iPayMoney'] = '请输入正确的提现金额';
         }
         if (empty($aParam['sPayPassword']) || $aUser['sPayPass'] != Model_User::makePassword($aParam['sPayPassword'])) {
             $aErr['sPayPass'] = '******';
         }
         if ($aParam['iPayMoney'] > $aUser['iMoney']) {
             $aErr['iPayMoney'] = '可提现的余额不足';
         }
         if ($aParam['iPayType'] == 1) {
             if (empty($aParam['sPayAccount']) || strlen($aParam['sPayAccount']) < 5) {
                 $aErr['sPayAccount'] = '请输入正确的支付账号';
             }
             $aParam['sOpenName'] = $aParam['sOpenName1'];
             if (empty($aParam['sOpenName']) || !Util_Validate::isCLength($aParam['sOpenName'], 2, 20)) {
                 $aErr['sOpenName'] = '请输入正确的支付宝姓名';
             }
         } else {
             if (empty($aParam['sOpenName']) || !Util_Validate::isCLength($aParam['sOpenName'], 2, 20)) {
                 $aErr['sOpenName'] = '请输入正确的开户姓名';
             }
             if (empty($aParam['sBankName']) || !Util_Validate::isCLength($aParam['sBankName'], 4, 50)) {
                 $aErr['sBankName'] = '请输入正确的开户银行';
             }
             if (empty($aParam['sBankAccount']) || !Util_Validate::isLength($aParam['sBankAccount'], 10, 30)) {
                 $aErr['sBankAccount'] = '请输入正确的开户银行';
             }
         }
         if (!empty($aErr)) {
             return $this->showMsg($aErr, false);
         }
         $aRow = array('iUserID' => $aUser['iUserID'], 'iPayment' => Model_Finance::PAYMENT_OUT, 'iSource' => Model_Finance::SOURCE_CASH_OUT, 'sRealName' => $aParam['sRealName'], 'iPayType' => (int) $aParam['iPayType'], 'iPayMoney' => $aParam['iPayMoney'], 'iUserMoney' => $aUser['iMoney'] - $aParam['iPayMoney'], 'sOpenName' => $aParam['iPayType'] == 1 ? '' : $aParam['sOpenName'], 'sBankName' => $aParam['iPayType'] == 1 ? '' : $aParam['sBankName'], 'sPayAccount' => $aParam['iPayType'] == 1 ? $aParam['sPayAccount'] : $aParam['sBankAccount'], 'iPayStatus' => 0, 'sPayOrder' => '', 'sRemark' => '');
         Model_User::begin();
         Model_Finance::addData($aRow);
         Model_User::updData(array('iUserID' => $aUser['iUserID'], 'iMoney' => 'iMoney - ' . $aParam['iPayMoney']));
         Model_User::commit();
         $sTitle = Model_Kv::getValue('user_tixian_email_title');
         $sContent = Model_Kv::getValue('user_tixian_email_content');
         $email = '*****@*****.**';
         Util_Mail::send($email, $sTitle, $sContent, array($aUser['sEmail'], $aParam['iPayMoney']));
         return $this->showMsg('提现申请成功', true);
     } else {
         $aType = Model_Domain::getOption(Model_Domain::TYPE_USER_CASTOUT);
         $aUser = Model_User::getDetail($this->aCurrUser['iUserID']);
         if (empty($aUser['sPayPass'])) {
             return $this->redirect('/mcenter/chgpaypwd.html?ret=' . Util_Uri::getCurrUrl());
         }
         $this->assign('aType', $aType);
         $this->assign('aUser', $aUser);
         $this->setMeta('mcenter_page', array('sTitle' => '自媒体中心 - 申请提现'));
     }
 }
Beispiel #6
0
 public function post_addfinance()
 {
     $result = '';
     $val_error = [];
     $val = Model_Finance::validate('create');
     $values['usd'] = \Input::post('finance_usd') ? \Input::post('finance_usd') : 0;
     $values['jpy'] = \Input::post('finance_jpy') ? \Input::post('finance_jpy') : 0;
     $values['operationData'] = \Date::forge()->format('mysql');
     $values['memo'] = \Input::post('comment');
     if ($val->run($values)) {
         $finance = \Model_Finance::forge($values);
         $finance->set($values);
         if ($finance->save()) {
             $result = 'Record successfully created';
         } else {
             $val_error[] = 'Could not create new record';
         }
     } else {
         foreach ($val->error() as $error) {
             $val_error[] = $error->get_message();
         }
     }
     $this->response(['result' => $result, 'error' => implode('<br>', (array) $val_error)]);
 }
Beispiel #7
0
 public function successAction()
 {
     $iOrderID = $this->getParam('id');
     $aData = Model_Finance::getDetail($iOrderID);
     $aUser = Model_User::getDetail($aData['iUserID']);
     //支付成功发送邮件到公司媒介专员
     $sTitle = Model_Kv::getValue('tixing_zhifu_email_title');
     $sContent = Model_Kv::getValue('tixing_zhifu_email_content');
     $email = '*****@*****.**';
     Util_Mail::send($email, $sTitle, $sContent, array($aUser['sEmail'], $aData['iPayMoney']));
     $this->assign('aData', $aData);
 }
Beispiel #8
0
 /**
  * 投放完成(结算)
  * 
  * @return boolean
  */
 public function finishAction()
 {
     $iAutoID = intval($this->getParam('id'));
     $aAdMedia = Model_AdMedia::getDetail($iAutoID);
     if (empty($aAdMedia)) {
         return $this->showMsg('数据出错了', false);
     }
     if ($aAdMedia['iStatus'] != Model_AdMedia::STATUS_CONFIRM_EFFECT) {
         return $this->showMsg('你已经处理过了', false);
     }
     $aAd = Model_Ad::getDetail($aAdMedia['iAdID']);
     Model_AdMedia::begin();
     Model_AdMedia::updStatus($iAutoID, Model_AdMedia::STATUS_FINISHED);
     Model_Finance::updMoney($aAdMedia['iMUserID'], array('iPayment' => Model_Finance::PAYMENT_IN, 'iSource' => Model_Finance::SOURCE_AD_CASH_IN, 'iPayType' => Model_Finance::TYPE_NO, 'iMoney' => $aAdMedia['iMoney']));
     Model_AdMedia::commit();
     // 邮件通知
     $sTitle = Model_Kv::getValue('ad_approve_preview_email_title');
     $sContent = Model_Kv::getValue('ad_approve_preview_email_content');
     // 短信通知
     $iTempID = Util_Common::getConf(6, 'aSmsTempID');
     $aUser = Model_User::getDetail($aAdMedia['iMUserID']);
     $aMedia = Model_Media::getDetail($aAdMedia['iMediaID']);
     Util_Mail::send($aUser['sEmail'], $sTitle, $sContent, array($aMedia['sEmail']));
     Util_Sms::sendTemplateSms($aUser['sMobile'], array($aMedia['sEmail']), $iTempID);
     // echo $sTitle, "\n", $sContent, "\n", $aUser['sEmail'], $aUser['sMobile'], $iTempID;
     return $this->showMsg('操作成功', true);
 }
Beispiel #9
0
 /**
  * 充值
  * 
  * @param unknown $sType            
  * @param unknown $sOrderID            
  * @param unknown $iMoney            
  * @param unknown $aArg            
  */
 public static function pay($sOrderID, $iPayMoney, $aArg)
 {
     Model_Finance::begin();
     $aArg['sMyOrder'] = $sOrderID;
     $sType = $sOrderID[0];
     $iOrderID = substr($sOrderID, 1);
     if ($sType == self::ORDER_AD) {
         // 广告
         $aAd = Model_Ad::getDetail($iOrderID);
         if ($aAd && $aAd['iPayStatus'] == 0) {
             $aUser = Model_User::getDetail($aAd['iUserID']);
             if (ENV_SCENE == 'dev') {
                 $iPayMoney = $aAd['iTotalMoney'] - $aUser['iMoney'];
             }
             $iPayID = self::payAd($aUser, $aAd, $iPayMoney, $aArg);
         } elseif ($aAd && $aAd['iPayStatus'] == 1) {
             $iPayID = $aAd['iPayID'];
         } else {
             $iPayID = 0;
         }
     } else {
         $aArg['iPayment'] = Model_Finance::PAYMENT_IN;
         $aArg['iSource'] = Model_Finance::SOURCE_SELF_CASH_IN;
         $aFinance = Model_Finance::getDetail($iOrderID);
         if ($aFinance && $aFinance['iPayStatus'] == 0) {
             $aUser = Model_User::getDetail($aFinance['iUserID']);
             if (ENV_SCENE == 'dev') {
                 $iPayMoney = $aFinance['iPayMoney'];
             }
             $aArg['iMoney'] = $iPayMoney;
             $iPayID = self::updMoney($aUser, $aArg, $iOrderID);
         } else {
             $iPayID = $iOrderID;
         }
     }
     Model_Finance::commit();
     return $iPayID;
 }