Example #1
0
 /**
  * 支付宝异步通知
  * @return [type] [description]
  */
 public function alipayNotify()
 {
     if (empty($_POST)) {
         $this->error('您查看的页面不存在');
     }
     $alipay = new Alipay();
     if (!$alipay->isAlipay($_POST)) {
         $this->error('请不要做违法行为!');
     }
     $alipay_no = I('post.trade_no');
     $order_id = I('post.out_trade_no');
     $status = I('post.trade_status');
     if ($status == 'TRADE_FINISHED' || $status == 'TRADE_SUCCESS') {
         /**
          * 生成账单
          */
         $pay_amount = $this->mod->where(array('order_id' => $order_id))->getField('order_amount');
         M('Seller')->where(array('seller_id' => $this->mid))->setInc('predeposit', $pay_amount);
         $predeposit = M('Seller')->where(array('seller_id' => $this->mid))->getField('predeposit');
         $bill_data['seller_id'] = $this->mid;
         $bill_data['bill_log'] = '充值金币,订单号:' . $order_id . '充值' . $pay_amount;
         $bill_data['amount'] = $pay_amount;
         $bill_data['balance'] = $predeposit;
         $bill_data['addtime'] = NOW_TIME;
         $bill_data['bill_type'] = 1;
         //充值
         M('SellerBill')->add($bill_data);
         $this->mod->where(array('order_id' => $order_id))->setField('order_state', 20);
         echo 'success';
     }
 }
 public function jdpay()
 {
     $order_sn = trim($_GET['order_sn']);
     $member_id = $this->mid;
     $where['order_sn'] = $order_sn;
     $where['member_id'] = $member_id;
     $order = $this->mod->where($where)->find();
     if (is_array($order) && !empty($order)) {
         if ($order['order_state'] != 10) {
             $this->error('该订单号无法进行支付,请联系客服.');
         } else {
             $alipay_data['total_fee'] = $order['order_amount'];
             //订单总金额
             $alipay_data['out_trade_no'] = $order['order_sn'];
             //商户订单ID
             $alipay_data['subject'] = '佐西卡购物支付';
             //订单商品标题
             $alipay_data['body'] = '订单号:' . $order['order_sn'];
             //订单商品描述
             $alipay_data['show_url'] = 'http://' . $_SERVER['SERVER_NAME'] . U('Member/order', array('sn' => $order['order_sn']));
             //订单商品地址
             $alipay_data['notify_url'] = U('Home/Pay/alipayNotify', '', true, true);
             $alipay_data['return_url'] = U('Home/Pay/alipayReturn', '', true, true);
             $alipay = new Alipay();
             $alipay->toAlipay($alipay_data);
         }
     } else {
         $this->error('非法操作');
     }
 }