public function confirm()
 {
     if (IS_GET) {
         $gets = I('get.');
         /*获取订单ID*/
         $member_id = session('home_member_id');
         $order_id = $gets['order_id'];
         $map['member_id'] = $member_id;
         $map['id'] = $order_id;
         $info = get_info($this->table, $map);
         /*获取初期金额百分比*/
         $precent = C('EARLY_PERCENT') / 100;
         if (!$info) {
             $tips_msg = array('status' => '0', 'msg' => '请登录后再操作');
             /* 跳转到输出位置 */
             goto export;
         }
         if ($info['status'] != 6) {
             $tips_msg = array('status' => '0', 'msg' => '该订单无法进行此操作');
             /* 跳转到输出位置 */
             goto export;
         }
         /* 开启事务 */
         $Model = M();
         $Model->startTrans();
         /*将订单状态更新为已确认*/
         $_POST = array('id' => $gets['order_id'], 'status' => '7', 'step' => 5, 'confirm_time' => date('Y-m-d H:i:s'));
         $result = update_data($this->table);
         /* 查询订单涉及的店铺所属的用户信息 */
         $shop_member_info = get_info(D('MemberShopView'), array('shop_id' => $info['shop_id']));
         /*金额从平台账户转入商家账户*/
         $platform_info = get_info($this->member_table, array('id' => C('PLATFORM_ID')));
         $_POST = array('id' => trim(C('PLATFORM_ID')), 'withdrawals' => $platform_info['withdrawals'] - $info['total_price'] * $precent);
         /*金额从平台账户转出*/
         $result1 = update_data($this->member_table);
         /*金额转入商家账户*/
         $_POST = array('id' => $shop_member_info['member_id'], 'withdrawals' => $shop_member_info['withdrawals'] + $info['total_price'] * $precent);
         $result2 = update_data('member');
         /*更新店铺的服务次数以及服务时长或字数*/
         $result3 = update_shop_data($info);
         /*将订单变更记录记录到订单历史记录表*/
         $_POST = array('order_id' => $info['id'], 'order_status' => '7', 'description' => '用户确认订单');
         $result4 = update_data($this->history_table);
         /*添加商家用户的资金记录*/
         $res4 = add_money_record($info['order_num'], trim(C('PLATFORM_ID')), $shop_member_info['member_id'], $info['total_price'] * $precent, 4, 2, $info['pay_type']);
         if (is_numeric($result) && is_numeric($result1) && is_numeric($result2) && is_numeric($result3) && is_numeric($result4)) {
             /*事务提交*/
             $Model->commit();
             F('site_index', null);
             //清除网站指数缓存
             $tips_msg = array('status' => '1', 'msg' => '操作成功');
         } else {
             /*事务回滚*/
             $Model->rollback();
             $tips_msg = array('status' => '0', 'msg' => '操作失败');
         }
     } else {
         $tips_msg = array('status' => '0', 'msg' => '请求错误!');
     }
     /*输出部分*/
     export:
     if ($tips_msg['status'] > 0) {
         $this->success($tips_msg['msg']);
     } else {
         $this->error($tips_msg['msg']);
     }
 }
Example #2
0
/**
 * 支付尾款
 * ①查询订单信息
 * ②查询订单相关店铺所属用户信息
 * ③查询平台账户信息
 * ④从平台账户扣除尾款金额
 * ⑤将尾款转入商家账户
 * ⑥更新订单状态
 * ⑦记录订单状态变更
 * ⑧添加商家资金记录
 * ⑨
 * ⑩
 * @param int $order_id					订单
 * @return boolean						返回执行状态
 * @author								李东
 * @date								2015-08-07
 */
function pay_balance_due($order_id)
{
    $surplus_precent = 1 - C('EARLY_PERCENT') / 100;
    /*获取系统定义的比例,并将其转换为百分比,计算剩余百分比*/
    $order_info = get_info('orders', array('id' => $order_id));
    $status = false;
    if ($order_info) {
        /*判断信息是否存在*/
        $shop_member_info = get_info(D('MemberShopView'), array('shop_id' => $order_info['shop_id']));
        /* 开启事务 */
        $Model = M();
        $Model->startTrans();
        /*金额从平台账户转入商家账户*/
        $platform_info = get_info('member', array('id' => C('PLATFORM_ID')));
        $_POST = array('id' => trim(C('PLATFORM_ID')), 'withdrawals' => $platform_info['withdrawals'] - $order_info['total_price'] * $surplus_precent);
        /*金额从平台账户转出*/
        $res = update_data('member');
        /*金额转入商家账户*/
        $_POST = array('id' => $shop_member_info['member_id'], 'withdrawals' => $shop_member_info['withdrawals'] + $order_info['total_price'] * $surplus_precent);
        $res1 = update_data('member');
        /*将订单状态更新为已完成,已支付尾款*/
        $_POST = array('id' => $order_info['id'], 'status' => '3', 'is_pay_due' => '1');
        $res2 = update_data('orders');
        /*将订单变更记录记录到订单历史记录表*/
        $_POST = array('order_id' => $order_info['id'], 'order_status' => '3', 'description' => '确认支付尾款');
        $res3 = update_data('order_history');
        /*添加商家用户的资金记录*/
        $res4 = add_money_record($order_info['order_num'], trim(C('PLATFORM_ID')), $shop_member_info['member_id'], $order_info['total_price'] * $surplus_precent, 4, 2, $order_info['pay_type']);
        if (is_numeric($res) && is_numeric($res1) && is_numeric($res2) && is_numeric($res3) && is_numeric($res4)) {
            /*事务提交*/
            $Model->commit();
            $status = true;
        } else {
            /*事务回滚*/
            $Model->rollback();
            $status = false;
        }
    }
    return $status;
}