PageRenderTime 27ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/new88li/plugins/app/tb_order_ctl/tb_notify.php

http://phpfor.googlecode.com/
PHP | 313 lines | 274 code | 28 blank | 11 comment | 39 complexity | 8968569365768ac3898e323bb03892a5 MD5 | raw file
  1. <?php
  2. require_once(CORE_DIR.'/kernel.php');
  3. require_once(CORE_DIR.'/func_ext.php');
  4. class taobao_action extends kernel{
  5. function taobao_action(){
  6. //parent::kernel();
  7. echo '<META http-equiv=Content-Type content="text/html; charset=UTF-8">';
  8. $method=$_GET['action'];
  9. $result_msg = $this->taobao_error_list($_GET['result_code']);
  10. if($_GET['result_code']==27){
  11. $this->redirect_tb($this->getCallBack($method));
  12. exit;
  13. }
  14. if(!$result_msg||!isset($_GET['result_code'])){
  15. if(method_exists($this,$method)){
  16. $this->db = $this->database();
  17. if($_GET['op']=='center'){
  18. if(base64_decode($_GET['opsign'])==md5($_GET['seller_nick'].HOST_ID.$_GET['buyer_nick'])){
  19. echo $this->$method();
  20. exit;
  21. }else{
  22. echo 'sign error';
  23. exit;
  24. }
  25. }
  26. $func=$this->$method();
  27. if($func){
  28. $this->close_dialog($this->getCallBack($method));
  29. }else{
  30. echo '????';
  31. }
  32. }
  33. }else{
  34. echo "????:".$result_msg;
  35. }
  36. }
  37. function refund_create(){
  38. if(in_array($_GET['refund_status'],array(6,2,5,3,4))){
  39. $refund_status = $this->get_refund_status($_GET['refund_status']);
  40. }else{
  41. $refund_status = $this->get_refund_status($_GET['is_received_good'].$_GET['need_return']);
  42. }
  43. if(!$refund_status){
  44. return false;
  45. }
  46. $set_order_status = " ";
  47. if($refund_status==7){
  48. $set_order_status = "status='finish',";
  49. }else if($refund_status!=0){
  50. $set_order_status = "status='refund',";
  51. }else{
  52. $set_order_status = "status='wait',";
  53. }
  54. 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'])){
  55. $tmpdata = $this->db->selectrow("SELECT order_id FROM sdb_order_items WHERE taobao_order=".$_GET['biz_order_id']);
  56. $data = $this->db->select("SELECT order_id,refund_status FROM sdb_order_items WHERE order_id=".$tmpdata['order_id']);
  57. foreach($data as $key=>$value){
  58. if($value['refund_status']!=7){
  59. $nodelete = true;
  60. break;
  61. }
  62. }
  63. if(!$nodelete){
  64. $this->db->exec('UPDATE sdb_orders SET status="dead" where order_id = '.$tmpdata["order_id"]);
  65. }
  66. return true;
  67. }else{
  68. return false;
  69. }
  70. }
  71. function set_order_price(){
  72. /*
  73. ??????/??
  74. index.php?ctl=order/order&act=set_order_price
  75. */
  76. if($_GET['result_code']==11002){
  77. $this->close_dialog();
  78. exit;
  79. }
  80. $cost_freight = $_GET['transport_fee']/100?$_GET['transport_fee']/100:0;
  81. $total_amount = $_GET['totle_adjust_fee']/100?$_GET['totle_adjust_fee']/100:0;
  82. $a_result=$this->db->selectrow("select total_amount,cost_freight,discount,cost_item from sdb_orders WHERE order_id=".$_GET['biz_order_id']);
  83. $a_result['cost_freight']=$a_result['cost_freight']?$a_result['cost_freight']:0;
  84. $a_result['discount']=$a_result['discount']?$a_result['discount']:0;
  85. $a_result['total_amount']=$a_result['cost_item']+$cost_freight+$total_amount;
  86. if($_GET['close_reason']&&$_GET['is_all_closed']==='false'){
  87. $close_t_ids = explode(";",$_GET['need_close_ids']);
  88. foreach($close_t_ids as $key =>$value){
  89. $del_id = $_GET['biz_order_id']+$value;
  90. $this->db->exec("UPDATE sdb_order_items SET disabled = 'true' WHERE taobao_order =".$del_id);
  91. }
  92. 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'])){
  93. return true;
  94. }else{
  95. return false;
  96. };
  97. }
  98. if($_GET['is_all_closed']==='true'){
  99. if($this->db->exec('UPDATE sdb_orders SET status="dead" WHERE order_id = '.$_GET["biz_order_id"])){
  100. return true;
  101. }else{
  102. return false;
  103. }
  104. }
  105. if($_GET['result_code']==11000&&!$_GET['close_reason']){
  106. 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'])){
  107. return true;
  108. }else{
  109. return false;
  110. }
  111. }
  112. }
  113. function delay_delivery_time(){
  114. if($_GET['result_code']==13002){
  115. $this->close_dialog();
  116. }
  117. if($_GET['delay_days']){
  118. $dayas= $_GET['delay_days']*3600*24;
  119. if($this->db->query('UPDATE sdb_taobao_orders SET delivery_time=delivery_time+'.$dayas.' where order_id='.$_GET['biz_order_id'])){
  120. return true;
  121. }else{
  122. return false;
  123. }
  124. }else{
  125. return false;
  126. }
  127. }
  128. function close_order(){
  129. /*
  130. ??????
  131. index.php?ctl=order/order&act=close_order
  132. */
  133. if($_GET['result_code']=='12002'){
  134. $this->close_dialog();
  135. }
  136. if($_GET['result_code']=='12000'){
  137. if($this->db->exec('UPDATE sdb_orders SET status="dead" where order_id = '.$_GET["biz_order_id"])){
  138. return true;
  139. }else{
  140. return false;
  141. }
  142. }
  143. }
  144. function taobao_error_list($code){
  145. $error_code=array(
  146. '1'=>'????',
  147. '14002'=>'????????',
  148. '14003'=>'????????',
  149. '14004'=>'??????????',
  150. '14005'=>'??????????',
  151. '14006'=>'????????',
  152. '14007'=>'????????',
  153. '14008'=>'??????????',
  154. '14009'=>'??????????',
  155. '14010'=>'??????',
  156. '14011'=>'??????',
  157. '14014'=>'??????????',
  158. '14015'=>'????????????',
  159. '14016'=>'????????',
  160. '14017'=>'???????????????????????',
  161. '14018'=>'?????',
  162. '14019'=>'????????????????????',
  163. '14020'=>'????',
  164. '14021'=>'????????',
  165. '14101'=>'???????',
  166. '14102'=>'???????',
  167. '14103'=>'?????????',
  168. '14104'=>'?????????',
  169. '14105'=>'???????????',
  170. '14106'=>'???????',
  171. '14108'=>'???????????????',
  172. '14109'=>'??????????????',
  173. '14110'=>'???????????????',
  174. '14111'=>'?????????????????',
  175. '14112'=>'???????????',
  176. '14115'=>'??????',
  177. '14116'=>'??????',
  178. '14117'=>'??????',
  179. '16001'=>'??????',
  180. '16002'=>'?????????????',
  181. '16003'=>'?????????????',
  182. '16004'=>'??????(???????????????)',
  183. '16005'=>'???????????????????????????????',
  184. '12001'=>'????',
  185. '12003'=>'??????',
  186. '12004'=>'????',
  187. '12005'=>'????????????',
  188. '13001'=>'????',
  189. '11001'=>'????',
  190. '11003'=>'????',
  191. '11004'=>'????????????',
  192. '11005'=>'????????',
  193. '11008'=>'??????????0'
  194. );
  195. if($error_code[$code]){
  196. return $error_code[$code];
  197. }else{
  198. return false;
  199. }
  200. }
  201. function set_pay_status(){
  202. //to_do???????????strtotime($_GET['pay_time']);
  203. if(!isset($_GET['pay_time'])){
  204. $_GET['pay_time'] = date('Y-m-d H:i:s');
  205. }
  206. if(isset($_GET['biz_order_id'])){
  207. if($this->db->exec("UPDATE sdb_orders SET pay_status = 1,pay_time=".strtotime($_GET['pay_time'])." WHERE taobao_order = ".$_GET['biz_order_id'])){
  208. return true;
  209. }else{
  210. return false;
  211. }
  212. }else{
  213. return false;
  214. }
  215. }
  216. function goods_confirm(){
  217. $this->db->exec("UPDATE sdb_orders SET status = 'finish',consign_time = ".time()." WHERE taobao_order = '".$_GET['biz_order_id']."'");
  218. $tmporder = $this->db->selectrow("SELECT order_id,member_id FROM sdb_orders WHERE taobao_order=".$_GET['biz_order_id']);
  219. $oMemberPoint=$this->loadModel('trading/memberPoint');
  220. $oMemberPoint->payAllGetPoint($tmporder['member_id'],$tmporder['order_id']);
  221. if($tmporder){
  222. $this->db->exec("UPDATE sdb_order_items SET refund_status = 0 WHERE refund_status !=7 AND order_id = ".$tmporder['order_id']);
  223. }
  224. $this->db->exec("UPDATE sdb_order_items SET status = 'finish',refund_status=0 WHERE taobao_order = ".$_GET['biz_order_id']);
  225. $tmpdata = $this->db->selectrow("SELECT order_id FROM sdb_order_items WHERE taobao_order=".$_GET['biz_order_id']);
  226. if($tmpdata){
  227. if(!$this->db->select("SELECT order_id FROM sdb_order_items WHERE (status='wait' or status ='refund') AND order_id=".$tmpdata['order_id'])){
  228. $this->db->exec("UPDATE sdb_orders SET status = 'finish',consign_time = ".time()." WHERE order_id=".$tmpdata['order_id']);
  229. }
  230. }
  231. return true;
  232. }
  233. function close_dialog($op='admin'){
  234. if($op=='admin'){
  235. echo "<script> for(var f in window.finderGroup){
  236. if(!!window.finderGroup[f].isVisibile()){
  237. window.finderGroup[f].refresh();
  238. }else{
  239. delete (window.finderGroup[f]);
  240. }
  241. }
  242. parent.$('dialogContent').getParent('.dialog').retrieve('instance').close();</script>";
  243. echo "";
  244. }else{
  245. if(isset($_GET['op'])){
  246. echo '<script>alert("????");window.location.href="'.$this->base_url().'shopadmin/index.php"</script>';
  247. }else{
  248. echo '<script>alert("????");window.location.href="'.$this->base_url().'?member.html"</script>';
  249. }
  250. }
  251. }
  252. function getCallBack($key){
  253. $list = array('goods_confirm'=>'shop',
  254. 'close_order'=>'admin',
  255. 'set_order_price'=>'admin',
  256. 'delay_delivery_time'=>'admin',
  257. 'refund_create'=>'shop',
  258. );
  259. return $list[$key];
  260. }
  261. function redirect_tb($redirect){
  262. if($redirect=='admin'){
  263. echo '????,??????????';
  264. }else{
  265. echo '????,??????????';
  266. }
  267. }
  268. function get_refund_status($num){
  269. $list = array('10'=>2,
  270. '20'=>6,
  271. '21'=>1,
  272. 6=>3,
  273. 2=>8,
  274. 5=>7,
  275. 3=>5,
  276. 4=>0);
  277. if($list[$num]){
  278. return $list[$num];
  279. }else{
  280. return false;
  281. }
  282. }
  283. }
  284. ?>