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']);
     }
 }
Esempio n. 2
0
/**
 * 自动确认订单
 * 将用户未确认的商家已经翻译完成的并且超过系统设置确认时间的订单支付系统预定的百分比金额
 * 1.将商家已上传,用户未确认,已超过系统设置时间的的订单搜索出来
 *
 * 2.将所有订单查询出来后,循环获取订单金额,并且从平台账户将 比例金额转入商家账户
 * 	①获取每个订单参与的店铺,
 * 	②获取店铺所属人,
 * 	③将金额更新到每个店铺的所属人账户
 * 	④
 * 3.生成金额流动记录
 * 
 * @param		$member_id		登录用户ID(参与订单)
 * @param		$shop_id		店铺ID(参与订单)
 * @author						李东
 * @date						2015-07-14
 */
function check_complete($member_id = 0, $shop_id = 0)
{
    $temp = $_POST;
    /*设置查询条件*/
    $time_limit = C('PAY_TIME');
    /*获取系统定义的提交完成稿之后等待时间长度/单位为(天)*/
    $deadline = date('Y-m-d H:i:s', time() - $time_limit * 24 * 3600);
    /*截止时间*/
    $precent = C('EARLY_PERCENT') / 100;
    /*获取系统定义的比例,并将其转换为百分比*/
    if (intval($member_id) > 0) {
        /*用户相关的的订单*/
        $map['member_id'] = $member_id;
    }
    if (intval($shop_id) > 0) {
        /*查询店铺相关的订单*/
        $map['shop_id'] = $shop_id;
    }
    $map['upload_time'] = array('lt', $deadline);
    /*判断等待截止时间是否已经超过*/
    $map['status'] = 6;
    /*判断商家上传完成稿用户未确认的订单*/
    /*查询订单*/
    $pending_result = get_result('orders', $map);
    foreach ($pending_result as $row) {
        /* 开启事务 */
        $Model = M();
        $Model->startTrans();
        /* 查询订单涉及的店铺所属的用户信息 */
        $shop_member_info = get_info(D('MemberShopView'), array('shop_id' => $row['shop_id']));
        /*金额从平台账户转入商家账户*/
        $platform_info = get_info('member', array('id' => C('PLATFORM_ID')));
        $_POST = array('id' => trim(C('PLATFORM_ID')), 'withdrawals' => $platform_info['withdrawals'] - $row['total_price'] * $precent);
        /*金额从平台账户转出*/
        $res1 = update_data('member');
        /*金额转入商家账户*/
        $_POST = array('id' => $shop_member_info['member_id'], 'withdrawals' => $shop_member_info['withdrawals'] + $row['total_price'] * $precent);
        $res = update_data('member');
        /*将订单状态更新为已确认*/
        $_POST = array('id' => $row['id'], 'status' => '7', 'step' => 5, 'confirm_time' => date('Y-m-d H:i:s'));
        $res2 = update_data('orders');
        /*将订单变更记录记录到订单历史记录表*/
        $_POST = array('order_id' => $row['id'], 'order_status' => '7', 'description' => '系统自动确认订单');
        $res3 = update_data('order_history');
        /*更新店铺服务字数等数据*/
        $res4 = update_shop_data($row);
        /*添加商家用户的资金记录*/
        $res4 = add_money_record($row['order_num'], trim(C('PLATFORM_ID')), $shop_member_info['member_id'], $row['total_price'] * $precent, 4, 2, $row['pay_type']);
        if (is_numeric($res) && is_numeric($res1) && is_numeric($res2) && is_numeric($res3) && is_numeric($res4)) {
            /*事务提交*/
            $Model->commit();
            F('site_index', null);
            //清除网站指数缓存
        } else {
            /*事务回滚*/
            $Model->rollback();
        }
    }
    $_POST = $temp;
}