Example #1
0
function sms($sp_moblie, $msg_str, $set)
{
    return mobile_sms($sp_moblie, $msg_str, $set);
}
 public function alipay()
 {
     $success = 'success';
     $fail = 'fail';
     $out_trade_no = ggp('out_trade_no');
     $trade_status = ggp('trade_status');
     $trade_status_array = array('WAIT_SELLER_SEND_GOODS', 'TRADE_FINISHED', 'TRADE_SUCCESS');
     if (ggp('op') == 'callback') {
         if (in_array($trade_status, $trade_status_array)) {
             $order = M('order')->where("order_id='{$out_trade_no}' or order_sn='{$out_trade_no}'")->find();
             $this->mySuccess('msg_common_add_success', $this->my['uid'] ? "index.php?m=home&a=order" : "index.php?m=order&vieworder&order_id={$order['order_id']}");
         }
         $this->myError('error_common_error', U('home/order'));
     } else {
         if (ggp('op') == 'notify') {
             if ($trade_status == 'WAIT_BUYER_PAY') {
                 exit($success);
             } else {
                 if (in_array($trade_status, $trade_status_array)) {
                     if (count(explode(',', $out_trade_no)) > 1) {
                         $wheresql = "order_id in({$out_trade_no})";
                     } else {
                         $wheresql = "(order_sn='{$out_trade_no}' or order_id='{$out_trade_no}')";
                     }
                     $wheresql .= " and state=6";
                     M('order')->where($wheresql)->save(array('state' => '2'));
                     $order = M('order')->where($wheresql)->select();
                     Vendor('notification.android.AndroidUnicast');
                     foreach ($order as $key => $val) {
                         $msg = "您有新的订单!订单号为:{$val['order_sn']}";
                         $store = M("store")->where("sid={$val['store_id']}")->find();
                         mobile_sms($store['mobile'], $msg, $this->setting);
                         if ($store['device_token']) {
                             $unicast = new AndroidUnicast($msg, $msg, $msg, $store['device_token'], 1, "{order_id:{$val['order_id']}}");
                             $unicast->send();
                         }
                     }
                     exit($success);
                 } else {
                     if ($trade_status == 'WAIT_BUYER_CONFIRM_GOODS') {
                         //卖家已经发货等待买家确认收货
                         exit($success);
                     }
                 }
             }
             exit($fail);
         }
     }
 }