/new88li/plugins/app/tb_order_ctl/tb_notify.php
PHP | 313 lines | 274 code | 28 blank | 11 comment | 39 complexity | 8968569365768ac3898e323bb03892a5 MD5 | raw file
- <?php
- require_once(CORE_DIR.'/kernel.php');
- require_once(CORE_DIR.'/func_ext.php');
- class taobao_action extends kernel{
-
- function taobao_action(){
- //parent::kernel();
- echo '<META http-equiv=Content-Type content="text/html; charset=UTF-8">';
- $method=$_GET['action'];
- $result_msg = $this->taobao_error_list($_GET['result_code']);
- if($_GET['result_code']==27){
- $this->redirect_tb($this->getCallBack($method));
- exit;
- }
-
- if(!$result_msg||!isset($_GET['result_code'])){
- if(method_exists($this,$method)){
- $this->db = $this->database();
- if($_GET['op']=='center'){
- if(base64_decode($_GET['opsign'])==md5($_GET['seller_nick'].HOST_ID.$_GET['buyer_nick'])){
- echo $this->$method();
- exit;
- }else{
- echo 'sign error';
- exit;
- }
- }
- $func=$this->$method();
- if($func){
- $this->close_dialog($this->getCallBack($method));
- }else{
- echo '????';
- }
- }
- }else{
- echo "????:".$result_msg;
- }
-
- }
- function refund_create(){
- if(in_array($_GET['refund_status'],array(6,2,5,3,4))){
- $refund_status = $this->get_refund_status($_GET['refund_status']);
- }else{
- $refund_status = $this->get_refund_status($_GET['is_received_good'].$_GET['need_return']);
- }
- if(!$refund_status){
- return false;
- }
- $set_order_status = " ";
- if($refund_status==7){
- $set_order_status = "status='finish',";
- }else if($refund_status!=0){
- $set_order_status = "status='refund',";
- }else{
- $set_order_status = "status='wait',";
- }
- if($this->db->exec("UPDATE sdb_order_items SET ".$set_order_status."refund_status=".$refund_status.",refund_id=".$_GET['refund_id']." WHERE taobao_order=".$_GET['biz_order_id'])){
- $tmpdata = $this->db->selectrow("SELECT order_id FROM sdb_order_items WHERE taobao_order=".$_GET['biz_order_id']);
- $data = $this->db->select("SELECT order_id,refund_status FROM sdb_order_items WHERE order_id=".$tmpdata['order_id']);
- foreach($data as $key=>$value){
- if($value['refund_status']!=7){
- $nodelete = true;
- break;
- }
- }
- if(!$nodelete){
- $this->db->exec('UPDATE sdb_orders SET status="dead" where order_id = '.$tmpdata["order_id"]);
- }
- return true;
- }else{
- return false;
- }
- }
- function set_order_price(){
- /*
- ??????/??
- index.php?ctl=order/order&act=set_order_price
-
- */
-
- if($_GET['result_code']==11002){
- $this->close_dialog();
- exit;
- }
- $cost_freight = $_GET['transport_fee']/100?$_GET['transport_fee']/100:0;
- $total_amount = $_GET['totle_adjust_fee']/100?$_GET['totle_adjust_fee']/100:0;
- $a_result=$this->db->selectrow("select total_amount,cost_freight,discount,cost_item from sdb_orders WHERE order_id=".$_GET['biz_order_id']);
- $a_result['cost_freight']=$a_result['cost_freight']?$a_result['cost_freight']:0;
- $a_result['discount']=$a_result['discount']?$a_result['discount']:0;
- $a_result['total_amount']=$a_result['cost_item']+$cost_freight+$total_amount;
- if($_GET['close_reason']&&$_GET['is_all_closed']==='false'){
- $close_t_ids = explode(";",$_GET['need_close_ids']);
- foreach($close_t_ids as $key =>$value){
- $del_id = $_GET['biz_order_id']+$value;
- $this->db->exec("UPDATE sdb_order_items SET disabled = 'true' WHERE taobao_order =".$del_id);
- }
- if($this->db->exec("UPDATE sdb_orders SET cost_freight = ".$cost_freight.",discount=".$total_amount.",total_amount=".$a_result['total_amount'].",final_amount=".$a_result['total_amount']." WHERE order_id=".$_GET['biz_order_id'])){
- return true;
- }else{
- return false;
- };
- }
- if($_GET['is_all_closed']==='true'){
- if($this->db->exec('UPDATE sdb_orders SET status="dead" WHERE order_id = '.$_GET["biz_order_id"])){
- return true;
- }else{
- return false;
- }
- }
- if($_GET['result_code']==11000&&!$_GET['close_reason']){
- if($this->db->exec("UPDATE sdb_orders SET cost_freight = ".$cost_freight.",discount=".$total_amount.",total_amount=".$a_result['total_amount'].",final_amount=".$a_result['total_amount']." WHERE order_id=".$_GET['biz_order_id'])){
- return true;
- }else{
- return false;
- }
- }
- }
- function delay_delivery_time(){
- if($_GET['result_code']==13002){
- $this->close_dialog();
- }
- if($_GET['delay_days']){
- $dayas= $_GET['delay_days']*3600*24;
- if($this->db->query('UPDATE sdb_taobao_orders SET delivery_time=delivery_time+'.$dayas.' where order_id='.$_GET['biz_order_id'])){
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
- function close_order(){
- /*
- ??????
- index.php?ctl=order/order&act=close_order
- */
- if($_GET['result_code']=='12002'){
- $this->close_dialog();
- }
- if($_GET['result_code']=='12000'){
- if($this->db->exec('UPDATE sdb_orders SET status="dead" where order_id = '.$_GET["biz_order_id"])){
- return true;
- }else{
- return false;
- }
- }
- }
-
-
-
-
-
- function taobao_error_list($code){
- $error_code=array(
- '1'=>'????',
- '14002'=>'????????',
- '14003'=>'????????',
- '14004'=>'??????????',
- '14005'=>'??????????',
- '14006'=>'????????',
- '14007'=>'????????',
- '14008'=>'??????????',
- '14009'=>'??????????',
- '14010'=>'??????',
- '14011'=>'??????',
- '14014'=>'??????????',
- '14015'=>'????????????',
- '14016'=>'????????',
- '14017'=>'???????????????????????',
- '14018'=>'?????',
- '14019'=>'????????????????????',
- '14020'=>'????',
- '14021'=>'????????',
- '14101'=>'???????',
- '14102'=>'???????',
- '14103'=>'?????????',
- '14104'=>'?????????',
- '14105'=>'???????????',
- '14106'=>'???????',
- '14108'=>'???????????????',
- '14109'=>'??????????????',
- '14110'=>'???????????????',
- '14111'=>'?????????????????',
- '14112'=>'???????????',
- '14115'=>'??????',
- '14116'=>'??????',
- '14117'=>'??????',
- '16001'=>'??????',
- '16002'=>'?????????????',
- '16003'=>'?????????????',
- '16004'=>'??????(???????????????)',
- '16005'=>'???????????????????????????????',
- '12001'=>'????',
- '12003'=>'??????',
- '12004'=>'????',
- '12005'=>'????????????',
- '13001'=>'????',
- '11001'=>'????',
- '11003'=>'????',
- '11004'=>'????????????',
- '11005'=>'????????',
- '11008'=>'??????????0'
- );
- if($error_code[$code]){
- return $error_code[$code];
- }else{
- return false;
- }
- }
-
- function set_pay_status(){
- //to_do???????????strtotime($_GET['pay_time']);
- if(!isset($_GET['pay_time'])){
- $_GET['pay_time'] = date('Y-m-d H:i:s');
- }
- if(isset($_GET['biz_order_id'])){
- if($this->db->exec("UPDATE sdb_orders SET pay_status = 1,pay_time=".strtotime($_GET['pay_time'])." WHERE taobao_order = ".$_GET['biz_order_id'])){
- return true;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
-
-
- function goods_confirm(){
- $this->db->exec("UPDATE sdb_orders SET status = 'finish',consign_time = ".time()." WHERE taobao_order = '".$_GET['biz_order_id']."'");
- $tmporder = $this->db->selectrow("SELECT order_id,member_id FROM sdb_orders WHERE taobao_order=".$_GET['biz_order_id']);
- $oMemberPoint=$this->loadModel('trading/memberPoint');
- $oMemberPoint->payAllGetPoint($tmporder['member_id'],$tmporder['order_id']);
- if($tmporder){
- $this->db->exec("UPDATE sdb_order_items SET refund_status = 0 WHERE refund_status !=7 AND order_id = ".$tmporder['order_id']);
- }
- $this->db->exec("UPDATE sdb_order_items SET status = 'finish',refund_status=0 WHERE taobao_order = ".$_GET['biz_order_id']);
- $tmpdata = $this->db->selectrow("SELECT order_id FROM sdb_order_items WHERE taobao_order=".$_GET['biz_order_id']);
- if($tmpdata){
- if(!$this->db->select("SELECT order_id FROM sdb_order_items WHERE (status='wait' or status ='refund') AND order_id=".$tmpdata['order_id'])){
- $this->db->exec("UPDATE sdb_orders SET status = 'finish',consign_time = ".time()." WHERE order_id=".$tmpdata['order_id']);
- }
- }
- return true;
- }
-
-
- function close_dialog($op='admin'){
- if($op=='admin'){
- echo "<script> for(var f in window.finderGroup){
- if(!!window.finderGroup[f].isVisibile()){
- window.finderGroup[f].refresh();
- }else{
- delete (window.finderGroup[f]);
- }
- }
- parent.$('dialogContent').getParent('.dialog').retrieve('instance').close();</script>";
- echo "";
- }else{
- if(isset($_GET['op'])){
- echo '<script>alert("????");window.location.href="'.$this->base_url().'shopadmin/index.php"</script>';
- }else{
- echo '<script>alert("????");window.location.href="'.$this->base_url().'?member.html"</script>';
- }
-
- }
- }
-
-
-
-
- function getCallBack($key){
- $list = array('goods_confirm'=>'shop',
- 'close_order'=>'admin',
- 'set_order_price'=>'admin',
- 'delay_delivery_time'=>'admin',
- 'refund_create'=>'shop',
- );
- return $list[$key];
- }
-
-
-
- function redirect_tb($redirect){
- if($redirect=='admin'){
- echo '????,??????????';
- }else{
- echo '????,??????????';
- }
- }
-
-
-
-
- function get_refund_status($num){
- $list = array('10'=>2,
- '20'=>6,
- '21'=>1,
- 6=>3,
- 2=>8,
- 5=>7,
- 3=>5,
- 4=>0);
- if($list[$num]){
- return $list[$num];
- }else{
- return false;
- }
- }
- }
-
-
- ?>