checkout.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <?php
  2. namespace WY\app\controller\mobile;
  3. use WY\app\libs\Controller;
  4. use WY\app\libs\Http;
  5. use WY\app\model\Pushorder;
  6. use WY\app\model\Checkacc;
  7. if (!defined('WY_ROOT')) {
  8. exit;
  9. }
  10. class checkout extends Controller
  11. {
  12. public $paytpe = '';
  13. public $bankcode = '';
  14. public $sign = '';
  15. public $orders = '';
  16. function __construct()
  17. {
  18. parent::__construct();
  19. if ($this->config['is_checkout_state'] == 1) {
  20. $this->put('retmsg.php', array('msg' => '收银台暂时关闭,请联系客服!'));
  21. exit;
  22. }
  23. // var_dump($_REQUEST);
  24. if ($this->config['is_checkout_jump'] && $this->config['checkout_jump_url'] && $this->config['checkout_jump_url'] != $this->req->server('HTTP_HOST') && isset($_REQUEST)) {
  25. $urlstr = '';
  26. foreach ($_REQUEST as $key => $val) {
  27. $urlstr .= $urlstr ? '&' : '';
  28. $urlstr .= $key . '=' . $val;
  29. }
  30. header('location:http://' . $this->config['checkout_jump_url'] . '/checkout?' . $urlstr);
  31. exit;
  32. }
  33. $this->checkacc = new Checkacc();
  34. }
  35. public function index()
  36. {
  37. $version = '1.0';
  38. $customerid = $this->req->request('customerid');
  39. $sdorderno = $this->req->request('sdorderno');
  40. $total_fee = $this->req->request('total_fee');
  41. $notifyurl = $this->req->request('notifyurl');
  42. $returnurl = $this->req->request('returnurl');
  43. $remark = $this->req->request('remark');
  44. $sign = $this->req->request('sign');
  45. if ($version == '' || $customerid == '' || $sdorderno == '' || $total_fee == '' || $notifyurl == '' || $returnurl == '' || $sign == '') {
  46. $ret['code'] = '200';
  47. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  48. $this->put('retmsg.php', $ret);
  49. exit;
  50. }
  51. if (strlen($sdorderno) > 50) {
  52. $ret['code'] = '203';
  53. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  54. $this->put('retmsg.php', $ret);
  55. exit;
  56. }
  57. if ($total_fee > 5000) {
  58. $ret['code'] = '207';
  59. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  60. $this->put('retmsg.php', $ret);
  61. exit;
  62. }
  63. if ($remark && strlen($remark) > 50) {
  64. $ret['code'] = '204';
  65. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  66. $this->put('retmsg.php', $ret);
  67. exit;
  68. }
  69. $userData = $this->model()->select()->from('users')->where(array('fields' => 'id=?', 'values' => array($customerid)))->fetchRow();
  70. if (!$userData) {
  71. $ret['code'] = '001';
  72. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  73. $this->put('retmsg.php', $ret);
  74. exit;
  75. }
  76. if ($userData['is_state'] == '0') {
  77. $ret['code'] = '002';
  78. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  79. $this->put('retmsg.php', $ret);
  80. exit;
  81. }
  82. if ($userData['is_state'] == '2') {
  83. $ret['code'] = '003';
  84. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  85. $this->put('retmsg.php', $ret);
  86. exit;
  87. }
  88. if (!$userData['is_checkout']) {
  89. $ret['code'] = '105';
  90. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  91. $this->put('retmsg.php', $ret);
  92. exit;
  93. }
  94. if ($userData['is_verify_siteurl']) {
  95. $userInfo = $this->model()->select('siteurl')->from('userinfo')->where(array('fields' => 'userid=?', 'values' => array($customerid)))->fetchRow();
  96. if ($userInfo) {
  97. $fromUrl = $this->req->server('HTTP_REFERER');
  98. if (strpos($fromUrl, $userInfo['siteurl']) === false) {
  99. $ret['code'] = '206';
  100. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  101. $this->put('retmsg.php', $ret);
  102. exit;
  103. }
  104. }
  105. }
  106. $total_fee = number_format($total_fee, 2, '.', '');
  107. $signStr = 'version=' . $version . '&customerid=' . $customerid . '&total_fee=' . $total_fee . '&sdorderno=' . $sdorderno . '&notifyurl=' . $notifyurl . '&returnurl=' . $returnurl . '&' . $userData['apikey'];
  108. $mysign = md5($signStr);
  109. if ($sign != $mysign) {
  110. $ret['code'] = '201';
  111. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  112. $this->put('retmsg.php', $ret);
  113. exit;
  114. }
  115. if ($this->model()->select()->from('orders')->where(array('fields' => 'userid=? and sdorderno=?', 'values' => array($customerid, $sdorderno)))->count()) {
  116. $ret['code'] = '205';
  117. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  118. $this->put('retmsg.php', $ret);
  119. exit;
  120. }
  121. $orderid = $this->res->getOrderID();
  122. $token = sha1($this->res->getRandomString(40));
  123. $addtime = time();
  124. $orderinfo = array('userid' => $customerid, 'notifyurl' => $notifyurl, 'returnurl' => $returnurl, 'remark' => $remark, 'addtime' => $addtime);
  125. if (!($orderinfoid = $this->model()->from('orderinfo')->insertData($orderinfo)->insert())) {
  126. $ret['code'] = '209';
  127. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  128. $this->put('retmsg.php', $ret);
  129. exit;
  130. }
  131. $orderdata = array('userid' => $customerid, 'agentid' => $userData['superid'], 'orderid' => $orderid, 'sdorderno' => $sdorderno, 'total_fee' => $total_fee, 'addtime' => $addtime, 'lastime' => $addtime, 'is_paytype' => 1, 'orderinfoid' => $orderinfoid);
  132. if (!($orid = $this->model()->from('orders')->insertData($orderdata)->insert())) {
  133. $ret['code'] = '210';
  134. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  135. $this->put('retmsg.php', $ret);
  136. exit;
  137. }
  138. $ordernotify = array('orid' => $orid, 'addtime' => $addtime);
  139. if (!$this->model()->from('ordernotify')->insertData($ordernotify)->insert()) {
  140. $ret['code'] = '211';
  141. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  142. $this->put('retmsg.php', $ret);
  143. exit;
  144. }
  145. if (!$this->model()->from('checkout')->insertData(array('orid' => $orid, 'token' => $token))->insert()) {
  146. $ret['code'] = '212';
  147. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  148. $this->put('retmsg.php', $ret);
  149. exit;
  150. }
  151. $this->res->redirect('/checkout/pay?sign=' . $token);
  152. }
  153. public function pay()
  154. {
  155. $sign = $this->req->get('sign');
  156. if ($sign == '' || !($checkout = $this->model()->select()->from('checkout')->where(array('fields' => 'token=?', 'values' => array($sign)))->fetchRow())) {
  157. $ret['code'] = '213';
  158. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  159. $this->put('retmsg.php', $ret);
  160. exit;
  161. }
  162. if (!($orders = $this->model()->select()->from('orders')->where(array('fields' => 'id=?', 'values' => array($checkout['orid'])))->fetchRow())) {
  163. $ret['code'] = '214';
  164. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  165. $this->put('retmsg.php', $ret);
  166. exit;
  167. }
  168. if ($orders['is_state'] == '1') {
  169. $ret['code'] = '215';
  170. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  171. $this->put('retmsg.php', $ret);
  172. exit;
  173. }
  174. if ($orders['is_state'] == '3') {
  175. $ret['code'] = '216';
  176. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  177. $this->put('retmsg.php', $ret);
  178. exit;
  179. }
  180. if ($orders['is_state'] == '0' && time() - $orders['addtime'] >= 60 * 30) {
  181. $this->model()->from('orders')->updateSet(array('is_state' => 3))->where(array('fields' => 'id=?', 'values' => array($checkout['orid'])))->update();
  182. $ret['code'] = '217';
  183. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  184. $this->put('retmsg.php', $ret);
  185. exit;
  186. }
  187. $orderinfo = $this->model()->select()->from('orderinfo')->where(array('fields' => 'id=?', 'values' => array($orders['orderinfoid'])))->fetchRow();
  188. $userinfo = $this->model()->select()->from('userinfo')->where(array('fields' => 'userid=?', 'values' => array($orders['userid'])))->fetchRow();
  189. $banklist = $this->model()->select()->from('acb')->where(array('fields' => 'is_state=?', 'values' => array(0)))->fetchAll();
  190. $cardlist = array();
  191. $acc = $this->model()->select('acwid,id,gateway')->from('acc')->where(array('fields' => 'is_state=? and is_card=?', 'values' => array(0, 1)))->fetchAll();
  192. if ($acc) {
  193. $userprice = $this->model()->select('channelid')->from('userprice')->where(array('fields' => 'userid=? and is_state=?', 'values' => array($orders['userid'], 0)))->fetchAll();
  194. foreach ($acc as $key => $val) {
  195. foreach ($userprice as $key2 => $val2) {
  196. if ($val['id'] == $val2['channelid']) {
  197. $cardlist[] = array('acwid' => $val['acwid'], 'gateway' => $val['gateway']);
  198. }
  199. }
  200. }
  201. $acw = $this->model()->select()->from('acw')->where(array('fields' => 'price<>?', 'values' => array('')))->fetchAll();
  202. if ($cardlist && $acw) {
  203. foreach ($cardlist as $key => $val) {
  204. foreach ($acw as $key2 => $val2) {
  205. if ($val['acwid'] == $val2['id']) {
  206. $cardlist[$key]['img'] = $val2['img'];
  207. }
  208. }
  209. }
  210. }
  211. }
  212. $data = array('title' => '收银台', 'userinfo' => $userinfo, 'banklist' => $banklist, 'cardlist' => $cardlist, 'orders' => $orders, 'orderinfo' => $orderinfo, 'token' => $sign);
  213. if ($this->res->isMobile()) {
  214. $this->put('checkoutwap.php', $data);
  215. exit;
  216. }
  217. $this->put('checkout.php', $data);
  218. }
  219. public function subpay()
  220. {
  221. $sign = $this->req->get('sign');
  222. $paytype = $this->req->post('paytype');
  223. $bankcode = $this->req->post('bankcode');
  224. $bankcode = $paytype == 'bank' || $paytype == 'card' ? $bankcode : $paytype;
  225. if ($sign == '' || $paytype == '' || $bankcode == '') {
  226. $ret['code'] = '208';
  227. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  228. $this->put('retmsg.php', $ret);
  229. exit;
  230. }
  231. if (!($checkout = $this->model()->select()->from('checkout')->where(array('fields' => 'token=?', 'values' => array($sign)))->fetchRow())) {
  232. $ret['code'] = '213';
  233. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  234. $this->put('retmsg.php', $ret);
  235. exit;
  236. }
  237. if (!($orders = $this->model()->select()->from('orders')->where(array('fields' => 'id=?', 'values' => array($checkout['orid'])))->fetchRow())) {
  238. $ret['code'] = '214';
  239. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  240. $this->put('retmsg.php', $ret);
  241. exit;
  242. }
  243. if ($orders['is_state'] == '1') {
  244. $ret['code'] = '215';
  245. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  246. $this->put('retmsg.php', $ret);
  247. exit;
  248. }
  249. if ($orders['is_state'] == '3') {
  250. $ret['code'] = '216';
  251. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  252. $this->put('retmsg.php', $ret);
  253. exit;
  254. }
  255. if ($orders['is_state'] == '0' && time() - $orders['addtime'] >= 60 * 30) {
  256. $this->model()->from('orders')->updateSet(array('is_state' => 3))->where(array('fields' => 'id=?', 'values' => array($checkout['orid'])))->update();
  257. $ret['code'] = '217';
  258. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  259. $this->put('retmsg.php', $ret);
  260. exit;
  261. }
  262. $this->orders = $orders;
  263. $this->paytype = $paytype;
  264. $this->bankcode = $bankcode;
  265. $this->sign = $sign;
  266. if ($paytype == 'card') {
  267. $this->card();
  268. } else {
  269. $this->uncard();
  270. }
  271. }
  272. public function card()
  273. {
  274. $acc = $this->model()->select()->from('acc')->where(array('fields' => 'gateway=?', 'values' => array($this->bankcode)))->fetchRow();
  275. if (!$acc) {
  276. $ret['code'] = '103';
  277. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  278. $this->put('retmsg.php', $ret);
  279. exit;
  280. }
  281. if ($acc['is_state'] == '1') {
  282. $ret['code'] = '102';
  283. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  284. $this->put('retmsg.php', $ret);
  285. exit;
  286. }
  287. $userprice = $this->model()->select()->from('userprice')->where(array('fields' => 'channelid=? and userid=?', 'values' => array($acc['id'], $this->orders['userid'])))->fetchRow();
  288. if (!$userprice) {
  289. $ret['code'] = '101';
  290. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  291. $this->put('retmsg.php', $ret);
  292. exit;
  293. }
  294. if ($userprice['is_state'] == '1') {
  295. $ret['code'] = '100';
  296. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  297. $this->put('retmsg.php', $ret);
  298. exit;
  299. }
  300. $this->model()->from('orders')->updateSet(array('channelid' => $acc['id']))->where(array('fields' => 'id=?', 'values' => array($this->orders['id'])))->update();
  301. $userinfo = $this->model()->select()->from('userinfo')->where(array('fields' => 'userid=?', 'values' => array($this->orders['userid'])))->fetchRow();
  302. $orderinfo = $this->model()->select()->from('orderinfo')->where(array('fields' => 'id=?', 'values' => array($this->orders['orderinfoid'])))->fetchRow();
  303. $acw = $this->model()->select()->from('acw')->where(array('fields' => 'id=?', 'values' => array($acc['acwid'])))->fetchRow();
  304. $data = array('title' => '收银台', 'userinfo' => $userinfo, 'orderinfo' => $orderinfo, 'cardvalue' => json_decode($acw['price']), 'cardname' => $acw['name'], 'cardlength' => json_decode($acw['length']), 'orders' => $this->orders, 'token' => $this->sign, 'acc' => $acc);
  305. $this->put('cards.php', $data);
  306. exit;
  307. }
  308. private function uncard()
  309. {
  310. $acw = $this->model()->select()->from('acw')->where(array('fields' => 'code=?', 'values' => array($this->paytype)))->fetchRow();
  311. if (!$acw) {
  312. $ret['code'] = '500';
  313. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  314. $this->put('retmsg.php', $ret);
  315. exit;
  316. }
  317. /*$acc=$this->model()->select()->from('acc')->where(array('fields'=>'acwid=?','values'=>array($acw['id'])))->fetchAll();if(!$acc){$ret['code']='103';$ret['msg']=$this->setConfig->retMsg($ret['code']);$this->put('retmsg.php',$ret);exit;}$userprice=$this->model()->select()->from('userprice')->where(array('fields'=>'userid=?','values'=>array($this->orders['userid'])))->fetchAll();if(!$userprice){$ret['code']='101';$ret['msg']=$this->setConfig->retMsg($ret['code']);$this->put('retmsg.php',$ret);exit;}$is_state=$channelid=$acpcode=$gateway=$is_state_acc='';foreach($userprice as $key=>$val){foreach($acc as $key2=>$val2){if($val['channelid']==$val2['id']){$is_state=$val['is_state'];$channelid=$val['channelid'];$acpcode=$val2['acpcode'];$gateway=$val2['gateway'];$is_state_acc=$val2['is_state'];break;}}}if($acpcode=='' || $gateway==''){$ret['code']='103';$ret['msg']=$this->setConfig->retMsg($ret['code']);$this->put('retmsg.php',$ret);exit;}if($is_state=='1'){$ret['code']='100';$ret['msg']=$this->setConfig->retMsg($ret['code']);$this->put('retmsg.php',$ret);exit;}if($is_state_acc=='1'){$ret['code']='102';$ret['msg']=$this->setConfig->retMsg($ret['code']);$this->put('retmsg.php',$ret);exit;}*/
  318. $acc = $this->model()->select('a.id,a.acpcode,a.gateway,a.is_state,b.is_state as is_state_acc,b.channelid')->from('acc a')->left('userprice b')->on('b.channelid=a.id')->join()->where(array('fields' => 'b.userid=? and a.acwid=?', 'values' => array($this->orders['userid'], $acw['id'])))->fetchRow();
  319. if (!$acc) {
  320. $ret['code'] = '103';
  321. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  322. $this->put('retmsg.php', $ret);
  323. exit;
  324. }
  325. if ($acc['is_state'] == '1') {
  326. $ret['code'] = '100';
  327. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  328. $this->put('retmsg.php', $ret);
  329. exit;
  330. }
  331. if ($acc['is_state_acc'] == '1') {
  332. $ret['code'] = '102';
  333. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  334. $this->put('retmsg.php', $ret);
  335. exit;
  336. }
  337. $channelid = $acc['channelid'];
  338. $acpcode = $acc['acpcode'];
  339. $gateway = $acc['gateway'];
  340. $data = array('channelid' => $acc['id']);
  341. $this->model()->from('orders')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($this->orders['id'])))->update();
  342. $data = array('paytype' => $this->paytype, 'bankcode' => $this->bankcode, 'faceno' => '', 'cardnum' => '', 'cardpwd' => '');
  343. $this->model()->from('orderinfo')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($this->orders['orderinfoid'])))->update();
  344. $orderinfo = $this->model()->select()->from('orderinfo')->where(array('fields' => 'id=?', 'values' => array($this->orders['orderinfoid'])))->fetchRow();
  345. $url = 'http://' . $this->req->server('HTTP_HOST') . '/pay/' . $acpcode . '_' . $gateway . '/send.php';
  346. $url .= '?orderid=' . $this->orders['orderid'] . '&price=' . $this->orders['total_fee'] . '&bankcode=' . $this->bankcode . '&remark=' . $orderinfo['remark'];
  347. $this->res->redirect($url);
  348. }
  349. public function cardpay()
  350. {
  351. $sign = $this->req->post('sign');
  352. $cardvalue = $this->req->post('cardvalue');
  353. $cardnum = $this->req->post('cardnum');
  354. $cardpwd = $this->req->post('cardpwd');
  355. $accid = $this->req->post('accid');
  356. if ($sign == '' || $cardvalue == '' || $cardnum == '' || $cardpwd == '' || $accid == '') {
  357. echo json_encode(array('status' => 0, 'msg' => '选项填写不完整'));
  358. exit;
  359. }
  360. if (!($checkout = $this->model()->select()->from('checkout')->where(array('fields' => 'token=?', 'values' => array($sign)))->fetchRow())) {
  361. echo json_encode(array('status' => 0, 'msg' => '订单不存在'));
  362. exit;
  363. }
  364. if (!($orders = $this->model()->select()->from('orders')->where(array('fields' => 'id=?', 'values' => array($checkout['orid'])))->fetchRow())) {
  365. echo json_encode(array('status' => 0, 'msg' => '订单不存在'));
  366. exit;
  367. }
  368. if ($cardvalue * 100 < $orders['total_fee'] * 100) {
  369. echo json_encode(array('status' => 0, 'msg' => '卡面值金额不能小于订单金额'));
  370. exit;
  371. }
  372. if (!($acc = $this->model()->select()->from('acc')->where(array('fields' => 'id=? and is_state=?', 'values' => array($accid, 0)))->fetchRow())) {
  373. echo json_encode(array('status' => 0, 'msg' => '点卡通道不存在'));
  374. exit;
  375. }
  376. $acw = $this->model()->select()->from('acw')->where(array('fields' => 'id=?', 'values' => array($acc['acwid'])))->fetchRow();
  377. if ($acw['length']) {
  378. $cardLength = json_decode($acw['length'], true);
  379. if (strlen($cardnum) != $cardLength[0]) {
  380. echo json_encode(array('status' => 0, 'msg' => '充值卡号长度应为' . $cardLength[0] . '位'));
  381. exit;
  382. }
  383. if (strlen($cardpwd) != $cardLength[1]) {
  384. echo json_encode(array('status' => 0, 'msg' => '充值卡密长度应为' . $cardLength[1] . '位'));
  385. exit;
  386. }
  387. }
  388. $data = array('channelid' => $acc['id']);
  389. $this->model()->from('orders')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($orders['id'])))->update();
  390. $data = array('paytype' => $acc['acpcode'], 'bankcode' => $acc['gateway'], 'cardnum' => $cardnum, 'cardpwd' => $cardpwd, 'faceno' => $cardvalue);
  391. $this->model()->from('orderinfo')->updateSet($data)->where(array('fields' => 'id=?', 'values' => array($orders['orderinfoid'])))->update();
  392. $url = 'http://' . $this->req->server('HTTP_HOST') . '/pay/' . $acc['acpcode'] . '_card/';
  393. $submitUrl = $url . 'send.php';
  394. $returnUrl = $url . 'returnUrl.php';
  395. $params = array('orderid' => $orders['orderid'], 'price' => $orders['total_fee'], 'cardnum' => $cardnum, 'cardpwd' => $cardpwd, 'cardvalue' => $cardvalue, 'gateway' => $acc['gateway']);
  396. $http = new Http($submitUrl, $params);
  397. $http->toUrl();
  398. $content = $http->getResContent();
  399. $code = $http->getResCode();
  400. $errinfo = $http->getErrInfo();
  401. $data = array('code' => $code, 'content' => $this->res->subString($content, 0, 50), 'info' => $errinfo);
  402. $this->model()->from('orderinfo')->updateSet(array('retmsg' => json_encode($data)))->where(array('fields' => 'id=?', 'values' => array($orders['orderinfoid'])))->update();
  403. if ($content == 'ok') {
  404. echo json_encode(array('status' => 1, 'msg' => '充值卡已提交成功,请稍候查看支付结果', 'url' => $returnUrl . '?orderid=' . $orders['orderid']));
  405. exit;
  406. }
  407. echo json_encode(array('status' => 0, 'msg' => '' . $content));
  408. }
  409. public function payresult()
  410. {
  411. $sign = $this->req->get('sign');
  412. if ($sign == '' || !($checkout = $this->model()->select()->from('checkout')->where(array('fields' => 'token=?', 'values' => array($sign)))->fetchRow())) {
  413. $ret['code'] = '213';
  414. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  415. $this->put('retmsg.php', $ret);
  416. exit;
  417. }
  418. if (!($orders = $this->model()->select()->from('orders')->where(array('fields' => 'id=?', 'values' => array($checkout['orid'])))->fetchRow())) {
  419. $ret['code'] = '214';
  420. $ret['msg'] = $this->setConfig->retMsg($ret['code']);
  421. $this->put('retmsg.php', $ret);
  422. exit;
  423. }
  424. $push = new Pushorder($orders['orderid']);
  425. $push->sync();
  426. }
  427. }
  428. ?>