Esempio n. 1
0
/**
 * 使用团购券
 * @param unknown_type $password 密码
 * @param unknown_type $location_id 所消费的门店ID
 * @param unknown_type $account_id 执行使用的商家账号ID
 * @param unknown_type $send_return 是否要发放奖励
 * @param unknown_type $send_notify 是否发放通知(短信/邮件)
 * return:true,false true:已使用掉  false:未使用掉
 */
function use_coupon($password, $location_id = 0, $account_id = 0, $send_return = false, $send_notify = false)
{
    $GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set is_balance = 1 ,location_id=" . $location_id . ", confirm_account = " . $account_id . ",confirm_time=" . NOW_TIME . " where password = '******' and confirm_time = 0");
    $coupon_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_coupon where password = '******'");
    if ($GLOBALS['db']->affected_rows() && $coupon_data) {
        $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set consume_count = consume_count + 1 where id = " . $coupon_data['order_deal_id']);
        update_order_cache($coupon_data['order_id']);
        distribute_order($coupon_data['order_id']);
        $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $coupon_data['order_id']);
        if ($order_info) {
            $order_msg = "订单号" . $order_info['order_sn'] . " ";
        }
        if ($send_return) {
            if ($coupon_data['coupon_money'] > 0 || $coupon_data['coupon_score'] > 0) {
                $money = $coupon_data['coupon_money'];
                $score = $coupon_data['coupon_score'];
                require_once APP_ROOT_PATH . "system/model/user.php";
                $log = $order_msg . $password . "消费券验证成功";
                modify_account(array("money" => $money, "score" => $score), $coupon_data['user_id'], $log);
            }
        }
        if ($send_notify) {
            send_use_coupon_sms(intval($coupon_data['id']));
            //发送团购券确认消息
            send_use_coupon_mail(intval($coupon_data['id']));
            //发送团购券确认消息
        }
        update_balance($coupon_data['id'], $coupon_data['deal_id']);
        $balance_price = $coupon_data['balance_price'] + $coupon_data['add_balance_price'];
        require_once APP_ROOT_PATH . "system/model/supplier.php";
        modify_supplier_account("-" . $balance_price, $coupon_data['supplier_id'], 1, $order_msg . $password . "消费券验证成功");
        //解冻资金
        modify_supplier_account($balance_price, $coupon_data['supplier_id'], 2, $order_msg . $password . "消费券验证成功");
        //等结算金额增加
        modify_statements($coupon_data['coupon_price'], 11, $order_msg . $password . "消费券验证成功");
        //增加消费额
        modify_statements($balance_price, 12, $order_msg . $password . "消费券验证成功");
        //增加消费额成本
        send_msg($coupon_data['user_id'], "消费券验证成功", "orderitem", $coupon_data['order_deal_id']);
        auto_over_status($coupon_data['order_id']);
        //检测自动结单
    }
    return $coupon_data['confirm_time'] > 0;
}
 public function check_coupon_batch()
 {
     $s_account_info = es_session::get("account_info");
     if (intval($s_account_info['id']) == 0) {
         $res['status'] = 0;
         ajax_return($res);
     } else {
         $now = get_gmtime();
         $supplier_id = intval($s_account_info['supplier_id']);
         $temp = explode(",", $_REQUEST['code']);
         $k = 0;
         foreach ($temp as $v) {
             $coupon = explode('-', $v);
             $deal_id = $coupon['0'];
             $sn = $coupon['1'];
             $pwd = $coupon['2'];
             $coupon_data = $GLOBALS['db']->getRow("select c.refund_status,c.begin_time,c.end_time, c.id as id,c.is_valid,c.deal_id,doi.name as name,doi.sub_name as sub_name,c.password as password,doi.number as number,c.sn as sn,c.supplier_id as supplier_id,c.confirm_time as confirm_time from " . DB_PREFIX . "deal_coupon as c left join " . DB_PREFIX . "deal_order_item as doi on c.order_deal_id = doi.id where c.sn = '" . $sn . "' and c.password = '******' and c.is_valid in(1,2) and c.is_delete = 0 ");
             if ($coupon_data) {
                 if ($coupon_data['is_valid'] == 2) {
                     //改团购劵因为退款被锁定
                     $result[$k]['msg'] = $GLOBALS['lang']['COUPON_IS_VALID_2'];
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 }
                 if ($coupon_data['refund_status'] > 0) {
                     $result[$k]['msg'] = "团购券提交了退款申请,无法验证";
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 }
                 if ($coupon_data['begin_time'] > 0 && $coupon_data['begin_time'] > get_gmtime()) {
                     //未启用
                     $result[$k]['msg'] = "团购券未生效";
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 }
                 if ($coupon_data['end_time'] > 0 && $coupon_data['end_time'] < get_gmtime()) {
                     //过期
                     $result[$k]['msg'] = "团购券已过期";
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 }
                 $sql = "select d.* from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where l.deal_id = " . $coupon_data['deal_id'] . " and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")";
                 $deal_info = $GLOBALS['db']->getRow($sql);
                 if (!$deal_info) {
                     $result[$k]['msg'] = $GLOBALS['lang']['NO_AUTH'];
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 }
                 if ($coupon_data['supplier_id'] != $supplier_id) {
                     $result[$k]['msg'] = $GLOBALS['lang']['COUPON_INVALID_SUPPLIER'];
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 } elseif ($coupon_data['confirm_time'] > 0) {
                     $result[$k]['msg'] = sprintf($GLOBALS['lang']['COUPON_INVALID_USED'], to_date($coupon_data['confirm_time']));
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 0;
                     $k++;
                     continue;
                 } else {
                     //开始确认
                     $GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set confirm_account = " . intval($s_account_info['id']) . ",confirm_time=" . $now . " where id = " . intval($coupon_data['id']));
                     $result[$k]['msg'] = $GLOBALS['lang']['COUPON_SUCCESS'];
                     $result[$k]['deal_id'] = $deal_id;
                     $result[$k]['id'] = $coupon_data['id'];
                     $result[$k]['name'] = $coupon_data['name'];
                     $result[$k]['sub_name'] = $coupon_data['sub_name'];
                     $result[$k]['password'] = $coupon_data['password'];
                     $result[$k]['sn'] = $sn;
                     $result[$k]['status'] = 1;
                     $k++;
                     //						$deal_type = intval($GLOBALS['db']->getOne("select deal_type from ".DB_PREFIX."deal where id = ".intval($coupon_data['deal_id'])));
                     //						if($deal_type == 1)
                     //						{
                     //							$result['msg'] = $coupon_data['name']."(购买数量:".$coupon_data['number'].")".sprintf($GLOBALS['lang']['COUPON_USED_OK'],to_date($now));;
                     //						}
                     //						else
                     //						{
                     //							$result['msg'] = $coupon_data['name'].sprintf($GLOBALS['lang']['COUPON_USED_OK'],to_date($now));;
                     //						}
                     send_use_coupon_sms(intval($coupon_data['id']));
                     //发送团购券确认消息
                     send_use_coupon_mail(intval($coupon_data['id']));
                     //发送团购券确认消息
                     update_balance($coupon_data['id'], $coupon_data['deal_id']);
                     continue;
                 }
             } else {
                 $result[$k]['msg'] = $GLOBALS['lang']['COUPON_INVALID'];
                 $result[$k]['deal_id'] = $deal_id;
                 $result[$k]['sn'] = $sn;
                 $result[$k]['id'] = 0;
                 $result[$k]['name'] = '-';
                 $result[$k]['sub_name'] = '-';
                 $result[$k]['password'] = '';
                 $result[$k]['status'] = 0;
                 $k++;
                 continue;
             }
         }
         $GLOBALS['tmpl']->assign('result', $result);
         $html = $GLOBALS['tmpl']->fetch("biz/user_coupon_batch_reult.html");
         $res['status'] = 1;
         $res['html'] = $html;
         header("Content-Type:text/html; charset=utf-8");
         ajax_return($res);
     }
 }
Esempio n. 3
0
 public function do_delivery()
 {
     $silent = intval($_REQUEST['silent']);
     $order_id = intval($_REQUEST['order_id']);
     $order_deals = $_REQUEST['order_deals'];
     $delivery_sn = $_REQUEST['delivery_sn'];
     $express_id = intval($_REQUEST['express_id']);
     $memo = $_REQUEST['memo'];
     if (!$order_deals) {
         if ($silent == 0) {
             $this->error(l("PLEASE_SELECT_DELIVERY_ITEM"));
         }
     } else {
         $deal_names = array();
         foreach ($order_deals as $order_deal_id) {
             $deal_info = $GLOBALS['db']->getRow("select d.*,doi.id as doiid from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_order_item as doi on doi.deal_id = d.id where doi.id = " . $order_deal_id);
             $deal_name = $deal_info['sub_name'];
             array_push($deal_names, $deal_name);
             $rs = make_delivery_notice($order_id, $order_deal_id, $delivery_sn, $memo, $express_id);
             if ($rs) {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set delivery_status = 1,is_arrival = 0 where id = " . $order_deal_id);
                 update_balance($order_deal_id, $deal_info['id']);
             }
         }
         $deal_names = implode(",", $deal_names);
         send_delivery_mail($delivery_sn, $deal_names, $order_id);
         send_delivery_sms($delivery_sn, $deal_names, $order_id);
         //开始同步订单的发货状态
         $order_deal_items = M("DealOrderItem")->where("order_id=" . $order_id)->findAll();
         foreach ($order_deal_items as $k => $v) {
             if (M("Deal")->where("id=" . $v['deal_id'])->getField("is_delivery") == 0) {
                 //无需发货的商品
                 unset($order_deal_items[$k]);
             }
         }
         $delivery_deal_items = $order_deal_items;
         foreach ($delivery_deal_items as $k => $v) {
             if ($v['delivery_status'] == 0) {
                 //未发货去除
                 unset($delivery_deal_items[$k]);
             }
         }
         if (count($delivery_deal_items) == 0 && count($order_deal_items) != 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 0 where id = " . $order_id);
             //未发货
         } elseif (count($delivery_deal_items) > 0 && count($order_deal_items) != 0 && count($delivery_deal_items) < count($order_deal_items)) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 1 where id = " . $order_id);
             //部分发
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 2 where id = " . $order_id);
             //全部发
         }
         M("DealOrder")->where("id=" . $order_id)->setField("update_time", NOW_TIME);
         M("DealOrder")->where("id=" . $order_id)->setField("is_refuse_delivery", 0);
         $refund_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order_item where (refund_status = 1 or is_arrival = 2) and order_id = " . $order_id);
         $coupon_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where refund_status = 1 and order_id = " . $order_id);
         if ($refund_item_count == 0 && $coupon_item_count == 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_status = 0,is_refuse_delivery=0 where id = " . $order_id);
         }
         $msg = l("DELIVERY_SUCCESS");
         //发货完毕,开始同步相应支付接口中的发货状态
         if (intval($_REQUEST['send_goods_to_payment']) == 1) {
             $payment_notices = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "payment_notice where order_id = " . $order_id);
             foreach ($payment_notices as $k => $v) {
                 $payment_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment where id = " . $v['payment_id']);
                 if ($v['outer_notice_sn'] != '') {
                     require_once APP_ROOT_PATH . "system/payment/" . $payment_info['class_name'] . "_payment.php";
                     $payment_class = $payment_info['class_name'] . "_payment";
                     $payment_object = new $payment_class();
                     if (method_exists($payment_object, "do_send_goods")) {
                         $result = $payment_object->do_send_goods($v['id'], $delivery_sn);
                         $msg = $msg . "[" . $payment_info['name'] . $result . "]";
                     } else {
                         $msg = $msg . "[" . $payment_info['name'] . l("NOT_SUPPORT_SEND_GOODS") . "]";
                     }
                 } else {
                     $msg = $msg . "[" . $payment_info['name'] . l("NOT_TRADE_SN") . "]";
                 }
             }
         }
         $this->assign("jumpUrl", U("DealOrder/view_order", array("id" => $order_id)));
         //查询快递名
         $express_name = M("Express")->where("id=" . $express_id)->getField("name");
         require_once APP_ROOT_PATH . "system/model/deal_order.php";
         order_log(l("DELIVERY_SUCCESS") . $express_name . $delivery_sn . $_REQUEST['memo'], $order_id);
         update_order_cache($order_id);
         distribute_order($order_id);
         $order_info = M("DealOrder")->getById($order_id);
         send_msg($order_info['user_id'], $deal_info['name'] . "等发货了,发货单号:" . $delivery_sn, "orderitem", $deal_info['doiid']);
         if ($silent == 0) {
             $this->success($msg);
         }
     }
 }
 public function do_delivery_form()
 {
     $s_account_info = es_session::get("account_info");
     $account_id = intval($s_account_info['id']);
     $account_data = $GLOBALS['db']->getRow("select a.allow_delivery,s.name as name,a.account_name as account_name, a.supplier_id as supplier_id from " . DB_PREFIX . "supplier_account as a left join " . DB_PREFIX . "supplier as s on a.supplier_id = s.id where a.id = " . $account_id);
     if (intval($account_data['allow_delivery']) == 0) {
         showErr($GLOBALS['lang']['NO_DELIVERY_AUTH']);
     }
     $order_id = intval($_REQUEST['order_id']);
     $supplier_id = intval($GLOBALS['db']->getOne("select supplier_id from " . DB_PREFIX . "supplier_account where id = " . intval($s_account_info['id'])));
     $order_info = $GLOBALS['db']->getAll("select do.*,d.name,d.sub_name,doi.number,doi.delivery_status,doi.id as doiid from " . DB_PREFIX . "deal_order_item as doi left join " . DB_PREFIX . "deal as d on doi.deal_id = d.id left join " . DB_PREFIX . "deal_order as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.id = " . $order_id . " and d.supplier_id = " . $supplier_id . " and do.is_delete = 0 and do.pay_status = 2 and d.is_delivery = 1");
     if (!$order_info) {
         showErr($GLOBALS['lang']['NO_AUTH']);
     }
     $order_deals = $_REQUEST['order_deals'];
     $delivery_sn = htmlspecialchars(addslashes($_REQUEST['delivery_sn']));
     $express_id = intval($_REQUEST['express_id']);
     $memo = htmlspecialchars(addslashes($_REQUEST['memo']));
     if (!$order_deals) {
         showErr($GLOBALS['lang']["PLEASE_SELECT_DELIVERY_ITEM"]);
     } else {
         $deal_names = array();
         foreach ($order_deals as $order_deal_id) {
             $order_deal_id = intval($order_deal_id);
             $deal_info = $GLOBALS['db']->getOne("select d.* from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_order_item as doi on doi.deal_id = d.id where doi.id = " . $order_deal_id);
             $deal_name = $deal_info['sub_name'];
             array_push($deal_names, $deal_name);
             $rs = make_delivery_notice($order_id, $order_deal_id, $delivery_sn, $memo, $express_id);
             if ($rs) {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set delivery_status = 1 where id = " . $order_deal_id);
                 update_balance($order_deal_id, $deal_info['id']);
             }
         }
         $deal_names = implode(",", $deal_names);
         send_delivery_mail($delivery_sn, $deal_names, $order_id);
         send_delivery_sms($delivery_sn, $deal_names, $order_id);
         //开始同步订单的发货状态
         $order_deal_items = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
         foreach ($order_deal_items as $k => $v) {
             if (intval($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "deal where id = " . $v['deal_id'])) == 0) {
                 unset($order_deal_items[$k]);
             }
         }
         $delivery_deal_items = $order_deal_items;
         foreach ($delivery_deal_items as $k => $v) {
             if ($v['delivery_status'] == 0) {
                 unset($delivery_deal_items[$k]);
             }
         }
         if (count($delivery_deal_items) == 0 && count($order_deal_items) != 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 0 where id = " . $order_id);
             //未发货
         } elseif (count($delivery_deal_items) > 0 && count($order_deal_items) != 0 && count($delivery_deal_items) < count($order_deal_items)) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 1 where id = " . $order_id);
             //部分发
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 2 where id = " . $order_id);
             //全部发
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set update_time = '" . get_gmtime() . "' where id = " . $order_id);
         order_log($account_data['name'] . $account_data['account_name'] . ":" . $GLOBALS['lang']["DELIVERY_SUCCESS"] . $delivery_sn . $_REQUEST['memo'], $order_id);
         showSuccess($GLOBALS['lang']["DELIVERY_SUCCESS"], 0, url("biz", "order#view", array("id" => $order_id)));
     }
 }
Esempio n. 5
0
    // if me, check to see if the dest account is a valid account
    if (!($stmt = $mysqli->prepare("SELECT accountNum FROM accounts where accountNum = ?"))) {
        echo "acct check Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
    }
    // bind new account num param
    if (!$stmt->bind_param("i", $dst_account_num)) {
        echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    if (!$stmt->execute()) {
        echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
    }
    // bind the results of the query to each field
    // if $dst_routing_num === $my_routing_num
    $stmt->bind_result($dst_acct);
    // if the account number is invalid in the local database, die
    $result = $stmt->store_result();
    if ($stmt->num_rows() !== 1) {
        echo "Unable to validate account number.";
        die;
    }
    // subtract the amount from the current balance, and set the new account balance
    $new_src_bal = get_balance(get_accountNum($_SESSION['username'])) - $amount;
    update_balance(get_accountNum($_SESSION['username']), $new_src_bal);
    // add new amount to dest balance
    $new_dst_bal = get_balance($dst_account_num) + $amount;
    update_balance($dst_account_num, $new_dst_bal);
    // write transaction log to the DB
    log_transaction("12345", get_accountNum($_SESSION['username']), $dst_routing_num, 3988282199, $amount);
    echo "Done processing transaction.";
    // if different bank, ask fed if account num is valid
}
Esempio n. 6
0
 public function index()
 {
     $id = intval($GLOBALS['request']['id']);
     if ($id == '') {
         $root['status'] = 0;
         $root['info'] = '订单号不能为空';
     }
     /*设置发货开始*/
     $silent = intval($_REQUEST['silent']);
     $order_id = $id;
     $order_items = $GLOBALS['db']->getAll("select id from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
     foreach ($order_items as $k => $v) {
         $order_deals[] = $v['id'];
     }
     $delivery_sn = $_REQUEST['delivery_sn'];
     $express_id = intval($_REQUEST['express_id']);
     $memo = $_REQUEST['memo'];
     if (!$order_deals) {
     } else {
         $deal_names = array();
         foreach ($order_deals as $order_deal_id) {
             $deal_info = $GLOBALS['db']->getRow("select d.*,doi.id as doiid from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_order_item as doi on doi.deal_id = d.id where doi.id = " . $order_deal_id);
             $deal_name = $deal_info['sub_name'];
             array_push($deal_names, $deal_name);
             $rs = make_delivery_notice($order_id, $order_deal_id, $delivery_sn, $memo, $express_id);
             if ($rs) {
                 $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set delivery_status = 1,is_arrival = 0 where id = " . $order_deal_id);
                 update_balance($order_deal_id, $deal_info['id']);
             }
         }
         $deal_names = implode(",", $deal_names);
         //开始同步订单的发货状态
         $order_deal_items = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
         foreach ($order_deal_items as $k => $v) {
             if ($GLOBALS['db']->getOne("select is_delivery from " . DB_PREFIX . "Deal where id = " . $v['deal_id']) == 0) {
                 unset($order_deal_items[$k]);
             }
         }
         $delivery_deal_items = $order_deal_items;
         foreach ($delivery_deal_items as $k => $v) {
             if ($v['delivery_status'] == 0) {
                 unset($delivery_deal_items[$k]);
             }
         }
         if (count($delivery_deal_items) == 0 && count($order_deal_items) != 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 0 where id = " . $order_id);
             //未发货
         } elseif (count($delivery_deal_items) > 0 && count($order_deal_items) != 0 && count($delivery_deal_items) < count($order_deal_items)) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 1 where id = " . $order_id);
             //部分发
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 2 where id = " . $order_id);
             //全部发
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set update_time = " . time() . ",is_refuse_delivery=0 where id = " . $order_id);
         //全部发
         $refund_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order_item where (refund_status = 1 or is_arrival = 2) and order_id = " . $order_id);
         $coupon_item_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where refund_status = 1 and order_id = " . $order_id);
         if ($refund_item_count == 0 && $coupon_item_count == 0) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set refund_status = 0,is_refuse_delivery=0 where id = " . $order_id);
         }
         //查询快递名
         $express_name = $GLOBALS['db']->getAll("select name from " . DB_PREFIX . "Express where id = " . $express_id);
         require_once APP_ROOT_PATH . "system/model/deal_order.php";
         order_log("发货成功" . $express_name . $delivery_sn . $_REQUEST['memo'], $order_id);
         update_order_cache($order_id);
         distribute_order($order_id);
     }
     /*设置发货结束*/
     $result = $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", array("service_start_time" => time()), "UPDATE", "id=" . intval($id));
     // 更新服务时间为当前时间
     if ($result) {
         $root['status'] = 1;
         $root['info'] = '服务开始';
     }
     output($root);
 }