Esempio n. 1
0
<div id="content_wrapper">
	<div id="main_content" class="cf">
		<div class="sepH_c">
			<div id="infoMessage"><?php 
echo $message;
?>
</div>
			<div class="sepH_a">
				<p><?php 
echo anchor('domain/show/' . element('did', $domain), element('domainname', $domain), 'target="_blank"');
?>
</p>
			</div>
			<?php 
$did = element('did', $domain);
$isBreak = isDomainBreak($report);
?>
			<table cellpadding="0" cellspacing="0" border="0" class="display" id="data_table">
				<thead>
					<tr>
						<th><div class="th_wrapp"><?php 
echo lang('b_user_users_username');
?>
</div></th>
						<th><div class="th_wrapp"><?php 
echo lang('b_user_profiles_qq');
?>
</div></th>
						<th><div class="th_wrapp"><?php 
echo lang('b_user_users_email');
?>
 function updateOrderStatus($did, $oid, $opt)
 {
     $opts = array('break', 'pay');
     if (!in_array($opt, $opts)) {
         $this->session->set_flashdata('messages', '不允许的操作。');
         return false;
     }
     $domainOrder = $this->getDomainOrderQuery($did)->result_array();
     if (count($domainOrder) != 4) {
         $this->session->set_flashdata('messages', '数据有误, 请联系开发人员。');
         return false;
     }
     lm('bid_report_model');
     $bidReport = $this->bid_report_model->getDidReportAndDomainArray($did);
     if (element('status', $bidReport) == DOMAIN_SELL_FAILED) {
         $this->session->set_flashdata('messages', '域名流拍,无需处理。');
         return false;
     }
     if (element('optstatus', $bidReport) == DOMAIN_BID_REPORT_OPTSTATUS_DONE) {
         $this->session->set_flashdata('messages', '域名已处理,不能重复处理。');
         return false;
     }
     $isBreak = isDomainBreak($domainOrder);
     $seller = $domainOrder[0];
     $buyer = $domainOrder[1];
     $prize2 = $domainOrder[2];
     $prize3 = $domainOrder[3];
     $this->db->trans_start();
     $data = array();
     $data['update'] = time();
     switch ($opt) {
         case 'pay':
             lm('user_moneylog_model');
             $price = 0;
             $uid = 0;
             $data['optuid'] = uid();
             //卖家支付
             if ($oid == element('oid', $seller)) {
                 $data['status'] = DOMAIN_ORDER_PAID;
                 $uid = element('uid', $seller);
                 $price = element('price', $seller);
                 $this->updateStatusByData($did, $oid, $data);
                 /*暂不扣减站内余额 
                 		//修改站内余额 站内余额不够时回滚记录
                 		$res = $this->user_moneylog_model->addUserMoney($uid,$oid,$price,USER_MONEYLOG_LOGTYPE_GIVEBREAKFEE);
                 		if(!$res)
                 		{
                 			$this->session->set_flashdata('messages','支付出错,请确认是否余额不足。');
                 			$this->db->trans_rollback();
                 			return false;
                 		}
                 		*/
                 //如果是违约,给购买者违约金
                 if ($isBreak) {
                     $price = element('price', $buyer);
                     $uid = element('uid', $buyer);
                     $oid = element('oid', $buyer);
                     $data['status'] = DOMAIN_ORDER_RECEIVED;
                     $this->updateStatusByData($did, $oid, $data);
                     $this->user_moneylog_model->addUserMoney($uid, $oid, $price, USER_MONEYLOG_LOGTYPE_RECEIVEBREAKFEE);
                 }
             } else {
                 if ($oid == element('oid', $buyer)) {
                     $data['status'] = DOMAIN_ORDER_PAID;
                     $uid = element('uid', $buyer);
                     $price = element('price', $buyer);
                     $this->updateStatusByData($did, $oid, $data);
                     //暂不扣减站内余额
                     //修改站内余额 站内余额不够时回滚记录
                     /*$res = $this->user_moneylog_model->addUserMoney($uid,$oid,$price,USER_MONEYLOG_LOGTYPE_GIVEBREAKFEE);
                     		if(!$res)
                     		{
                     			$this->session->set_flashdata('messages','支付出错,请确认是否余额不足。');
                     			$this->db->trans_rollback();
                     			return false;
                     		}*/
                     //给卖家发违约金
                     $price = element('price', $seller);
                     $uid = element('uid', $seller);
                     $oid = element('oid', $seller);
                     $data['status'] = DOMAIN_ORDER_RECEIVED;
                     $this->updateStatusByData($did, $oid, $data);
                     $this->user_moneylog_model->addUserMoney($uid, $oid, $price, USER_MONEYLOG_LOGTYPE_RECEIVEBREAKFEE);
                 }
             }
             $logType = USER_MONEYLOG_LOGTYPE_RECEIVEPRIZE;
             if ($isBreak) {
                 $logType = USER_MONEYLOG_LOGTYPE_RECEIVEBREAKFEE;
             }
             // 付款给中奖的人
             $price = element('price', $prize2);
             $uid = element('uid', $prize2);
             $oid = element('oid', $prize2);
             $data['status'] = DOMAIN_ORDER_RECEIVED;
             $this->updateStatusByData($did, $oid, $data);
             $this->user_moneylog_model->addUserMoney($uid, $oid, $price, $logType, '收到' . element('domainname', $bidReport) . '的奖金,第2名');
             $price = element('price', $prize3);
             $uid = element('uid', $prize3);
             $oid = element('oid', $prize3);
             $data['status'] = DOMAIN_ORDER_RECEIVED;
             $this->updateStatusByData($did, $oid, $data);
             $this->user_moneylog_model->addUserMoney($uid, $oid, $price, $logType, '收到' . element('domainname', $bidReport) . '的奖金,第3名');
             //处理完成
             lm('bid_report_model');
             $bidStatus = array('optstatus' => DOMAIN_BID_REPORT_OPTSTATUS_DONE);
             $this->bid_report_model->updateFieldWithValueByDid($did, $bidStatus);
             //释放信用额度
             lm('user_creditlocklog_model');
             $this->user_creditlocklog_model->updateCreditlockLogIslockWithRange($did, array(element('uid', $buyer), element('uid', $seller)), array(), USER_CREDITLOCK_ISLOCK_FALSE);
             $this->user_creditlocklog_model->updateUserProfileCreditLock(element('uid', $buyer));
             $this->user_creditlocklog_model->updateUserProfileCreditLock(element('uid', $seller));
             break;
         case 'break':
             if (!$isBreak) {
                 $data['otype'] = DOMAIN_ORDER_TYPE_BREAK;
                 // 重新计算费用
                 $data['price'] = -getDomainBreakFee($bidReport, element('price2', $bidReport));
                 $data['status'] = DOMAIN_ORDER_UNPAID;
                 $this->updateStatusByData($did, $oid, $data);
                 //谁被违约了,计算被违约人费用 //默认卖家违约
                 $breakedId = element('oid', $buyer);
                 $reportStatus = DOMAIN_SELL_SELLERBREAK;
                 //买家违约
                 if ($oid == element('oid', $buyer)) {
                     $breakedId = element('oid', $seller);
                     $reportStatus = DOMAIN_SELL_BUYERBREAK;
                 }
                 $data['status'] = DOMAIN_ORDER_UNRECEIVED;
                 $data['otype'] = DOMAIN_ORDER_TYPE_BREAKED;
                 $data['price'] = getDomainBreakedFee($bidReport, element('price2', $bidReport));
                 $this->updateStatusByData($did, $breakedId, $data);
                 lm('bid_report_model');
                 $this->bid_report_model->updateDidReportStatus($did, $reportStatus);
             }
             break;
     }
     $this->db->trans_complete();
     return true;
 }