/**
  * 完成提现
  * 1.更改记录状态为已成功
  * 2.添加平台资金记录
  * @author						李东
  * @date						2015-08-08
  */
 public function drawals()
 {
     if (IS_GET) {
         $id = I('get.record_id');
         $record_info = get_info($this->table, array('id' => $id));
         if ($record_info['status'] == 0 || !empty($record_info)) {
             /* 开启事务 */
             $Model = M();
             $Model->startTrans();
             /* 更改记录状态 */
             $_POST = array('id' => $id, 'status' => '1');
             $res = update_data($this->table);
             /* 添加平台自己记录 */
             $res2 = platform_funds($record_info['from_member_id'], -$record_info['money'], 3, $record_info['order_num'], 0);
             if (is_numeric($res) && $res2) {
                 /* 事务提交 */
                 $Model->commit();
                 $this->success('操作成功');
             } else {
                 /*事务回滚*/
                 $Model->rollback();
                 $this->error('操作失败');
             }
         } elseif ($record_info['status'] == 1) {
             $this->error('已支付');
         } elseif ($record_info['status'] == 2) {
             $this->error('此订单已退款');
         } else {
             $this->error('订单不存在');
         }
     } else {
         $this->error('请求错误');
     }
 }
Example #2
0
 public function pay($payinfo)
 {
     $posts = $payinfo;
     /*将接收到的参数生成文件Start*/
     open_file($posts, 'posts');
     /*将接收到的参数生成文件End*/
     if (!empty($payinfo)) {
         $Model = M();
         $Model->startTrans();
         /*将订单历史记录更新*/
         $step = $payinfo['type'] == 1 ? '' : 3;
         $_POST = array('order_id' => $payinfo['id'], 'description' => '在线支付成功', 'order_status' => '2', 'step' => $step);
         $res = update_data($this->history_table);
         /*添加用户资金流动记录*/
         $description = $payinfo['type'] == 1 ? '余额充值' : '购买商品支付';
         $type = $payinfo['type'] == 1 ? 1 : 2;
         $_POST = array('order_num' => $payinfo['order_num'], 'frozen' => 3, 'member_id' => C('PLATFORM_ID'), 'money' => $payinfo['total_price'], 'from_member_id' => $payinfo['member_id'], 'description' => $description, 'type' => $type, 'status' => 3, 'recharge_type' => '1');
         $res2 = update_data($this->money_table);
         $status = true;
         if ($payinfo['type'] == 1) {
             /*如果是充值,用户账户余额增加*/
             $sql = 'update __MEMBER__ SET balance = balance+' . $payinfo['total_price'] . ' WHERE id = ' . $payinfo['member_id'];
             /*将接收到的参数生成文件Start*/
             open_file($sql, 'sql');
             /*将接收到的参数生成文件End*/
             $result = M()->execute($sql);
             if ($result <= 0) {
                 $status = false;
             }
         }
         /* 在后台资金记录表中更新记录 */
         $res3 = platform_funds($payinfo['member_id'], $payinfo['total_price'], $type, $payinfo['order_num'], 1);
         if (is_numeric($res) && is_numeric($res2) && $res3 && $status) {
             $Model->commit();
             return true;
         } else {
             $Model->rollback();
             return false;
         }
     }
     return false;
 }