コード例 #1
0
ファイル: ajaxModule.class.php プロジェクト: macall/jsd
 public function load_delivery_form()
 {
     global_run();
     $s_account_info = $GLOBALS['account_info'];
     if (intval($s_account_info['id']) == 0) {
         $data['status'] = 1000;
         ajax_return($data);
     }
     if (!check_module_auth("goodso")) {
         $data['status'] = 0;
         $data['info'] = "权限不足";
         ajax_return($data);
     }
     $supplier_id = intval($s_account_info['supplier_id']);
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     $order_item_table_name = get_supplier_order_item_table_name($supplier_id);
     $id = intval($_REQUEST['id']);
     //发货商品的ID
     $item = $GLOBALS['db']->getRow("select doi.* from " . $order_item_table_name . " as doi left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id where doi.id = " . $id . " and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if ($item) {
         $location_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "supplier_location where id in (" . implode(",", $s_account_info['location_ids']) . ")");
         $express_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "express where is_effect = 1");
         $GLOBALS['tmpl']->assign("item", $item);
         $GLOBALS['tmpl']->assign("express_list", $express_list);
         $GLOBALS['tmpl']->assign("location_list", $location_list);
         $data['html'] = $GLOBALS['tmpl']->fetch("inc/delivery_form.html");
         $data['status'] = 1;
         ajax_return($data);
     } else {
         $data['status'] = 0;
         $data['info'] = "非法的数据";
         ajax_return($data);
     }
 }
コード例 #2
0
ファイル: dealoModule.class.php プロジェクト: macall/jsd
 public function index()
 {
     init_app_page();
     $s_account_info = $GLOBALS['account_info'];
     $supplier_id = intval($s_account_info['supplier_id']);
     $name = strim($_REQUEST['name']);
     $begin_time = strim($_REQUEST['begin_time']);
     $end_time = strim($_REQUEST['end_time']);
     $begin_time_s = to_timespan($begin_time, "Y-m-d H:i");
     $end_time_s = to_timespan($end_time, "Y-m-d H:i");
     $condition = "";
     if ($name != "") {
         $condition .= " and (doi.name like '%" . $name . "%' or doi.sub_name like '%" . $name . "%') ";
     }
     if ($begin_time_s) {
         $condition .= " and do.create_time > " . $begin_time_s . " ";
     }
     if ($end_time_s) {
         $condition .= " and do.create_time < " . $end_time_s . " ";
     }
     $GLOBALS['tmpl']->assign("name", $name);
     $GLOBALS['tmpl']->assign("begin_time", $begin_time);
     $GLOBALS['tmpl']->assign("end_time", $end_time);
     //分页
     $page_size = 10;
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     $order_item_table_name = get_supplier_order_item_table_name($supplier_id);
     $order_table_name = get_supplier_order_table_name($supplier_id);
     $sql = "select distinct(doi.id),doi.*,do.memo,do.create_time,do.order_sn,do.total_price,do.pay_amount,doi.refund_status from " . $order_item_table_name . " as doi left join " . $order_table_name . " as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id " . " where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.is_delete = 0 and do.type = 0 and doi.is_shop = 0 and do.pay_status = 2 {$condition} order by doi.id desc limit " . $limit;
     $sql_count = "select count(distinct(doi.id)) from " . $order_item_table_name . " as doi left join " . $order_table_name . " as do on doi.order_id = do.id left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id " . " where l.location_id in (" . implode(",", $s_account_info['location_ids']) . ") and do.is_delete = 0 and do.type = 0 and doi.is_shop = 0  and do.pay_status = 2 {$condition} ";
     $list = $GLOBALS['db']->getAll($sql);
     foreach ($list as $k => $v) {
         $uinfo = load_user($v['user_id']);
         $list[$k]['user_name'] = $uinfo['user_name'];
         $mobile = $uinfo['mobile'];
         //保护手机号
         // 	    	$mobile_end = substr($mobile,-4,4);
         // 	    	$mobile_show_length = strlen($mobile) - 4 - 3;
         // 	    	$mobile = substr($mobile,0,3);
         // 	    	for($i=0;$i<$mobile_show_length;$i++)
         // 	    	{
         // 	    		$mobile.="*";
         // 	    	}
         // 	    	$mobile.=$mobile_end;
         $list[$k]['user_mobile'] = $mobile;
         $list[$k]['create_time'] = to_date($v['create_time']);
         $deal_info = load_auto_cache("deal", array("id" => $v['deal_id']));
         $list[$k]['url'] = $deal_info['url'];
         $list[$k]['s_total_price'] = $v['balance_total_price'] + $v['add_balance_price_total'];
         $verify_count_0 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and confirm_time <> 0 and deal_type = 0");
         $verify_count_1 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and confirm_time <> 0 and deal_type = 1");
         $refund_status_1_0 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 1 and deal_type = 0");
         $refund_status_1_1 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 1 and deal_type = 1");
         $refund_status_2_0 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 2 and deal_type = 0");
         $refund_status_2_1 = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_coupon where order_deal_id = " . $v['id'] . " and refund_status = 2 and deal_type = 1");
         $list[$k]['verify_count'] = $verify_count_0 + $verify_count_1 * $v['number'];
         $list[$k]['refund_status_1'] = $refund_status_1_0 + $refund_status_1_1 * $v['number'];
         $list[$k]['refund_status_2'] = $refund_status_2_0 + $refund_status_2_1 * $v['number'];
     }
     $total = $GLOBALS['db']->getOne($sql_count);
     $page = new Page($total, $page_size);
     //初始化分页对象
     $p = $page->show();
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("list", $list);
     $GLOBALS['tmpl']->assign("head_title", "团购订单记录");
     $GLOBALS['tmpl']->display("pages/dealo/index.html");
 }
コード例 #3
0
ファイル: deal_order.php プロジェクト: macall/jsd
/**
 * 删除订单至回收站(历史订单)
 * @param unknown_type $order_id
 * 返回:true/false
 */
function del_order($order_id)
{
    $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $order_id . " and order_status = 1");
    if ($order_info) {
        unset($order_info['id']);
        unset($order_info['deal_order_item']);
        $order_items = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
        $order_info['history_deal_order_item'] = serialize($order_items);
        $order_info['history_deal_coupon'] = serialize($GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_coupon where order_id = " . $order_id));
        $order_info['history_deal_order_log'] = serialize($GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_order_log where order_id = " . $order_id));
        $order_info['history_delivery_notice'] = serialize($GLOBALS['db']->getAll("select * from " . DB_PREFIX . "delivery_notice where order_id = " . $order_id));
        $order_info['history_payment_notice'] = serialize($GLOBALS['db']->getAll("select * from " . DB_PREFIX . "payment_notice where order_id = " . $order_id));
        $order_info['history_message'] = serialize($GLOBALS['db']->getAll("select * from " . DB_PREFIX . "message where rel_table = 'deal_order' and rel_id = " . $order_id));
        $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order_history", $order_info, 'INSERT', '', 'SILENT');
        if ($GLOBALS['db']->insert_id()) {
            //删除会员相关分表
            $user_order_table = get_user_order_table_name($order_info['user_id']);
            $user_order_item_table = get_user_order_item_table_name($order_info['user_id']);
            $GLOBALS['db']->query("delete from " . $user_order_table . " where id = " . $order_id);
            $GLOBALS['db']->query("delete from " . $user_order_item_table . " where order_id = " . $order_id);
            //删除商户相关表
            foreach ($order_items as $item) {
                $supplier_order_table = get_supplier_order_table_name($item['supplier_id']);
                $supplier_order_item_table = get_supplier_order_item_table_name($item['supplier_id']);
                $GLOBALS['db']->query("delete from " . $supplier_order_table . " where id = " . $order_id);
                $GLOBALS['db']->query("delete from " . $supplier_order_item_table . " where order_id = " . $order_id);
            }
            $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_order where id = " . $order_id);
            $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_order_item where order_id = " . $order_id);
            //$GLOBALS['db']->query("delete from ".DB_PREFIX."deal_coupon where order_id = ".$order_id);
            $GLOBALS['db']->query("update " . DB_PREFIX . "deal_coupon set order_id = -1 where order_id = " . $order_id);
            $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_order_log where order_id = " . $order_id);
            $GLOBALS['db']->query("delete from " . DB_PREFIX . "delivery_notice where order_id = " . $order_id);
            $GLOBALS['db']->query("delete from " . DB_PREFIX . "payment_notice where order_id = " . $order_id);
            $GLOBALS['db']->query("delete from " . DB_PREFIX . "message where rel_table='deal_order' and rel_id = " . $order_id);
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
コード例 #4
0
ファイル: goodsoModule.class.php プロジェクト: macall/jsd
 public function do_delivery()
 {
     $s_account_info = $GLOBALS['account_info'];
     $supplier_id = intval($s_account_info['supplier_id']);
     require_once APP_ROOT_PATH . "system/model/deal_order.php";
     $order_item_table_name = get_supplier_order_item_table_name($supplier_id);
     $order_table_name = get_supplier_order_table_name($supplier_id);
     $id = intval($_REQUEST['id']);
     //发货商品的ID
     $delivery_sn = strim($_REQUEST['delivery_sn']);
     $memo = strim($_REQUEST['memo']);
     $express_id = intval($_REQUEST['express_id']);
     $location_id = intval($_REQUEST['location_id']);
     $order_id = $GLOBALS['db']->getOne("select order_id from " . $order_item_table_name . " where id = " . $id);
     $order_info = $GLOBALS['db']->getRow("select * from " . $order_table_name . " where id = '" . $order_id . "'");
     if (empty($delivery_sn)) {
         $data['status'] = 0;
         $data['info'] = "请输入快递单号";
         ajax_return($data);
     }
     $item = $GLOBALS['db']->getRow("select doi.* from " . $order_item_table_name . " as doi left join " . DB_PREFIX . "deal_location_link as l on doi.deal_id = l.deal_id where doi.id = " . $id . " and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if ($item) {
         $rs = make_delivery_notice($order_id, $id, $delivery_sn, $memo, $express_id, $location_id);
         if ($rs) {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order_item set delivery_status = 1 where id = " . $id);
         }
         send_delivery_mail($delivery_sn, $item['name'], $order_id);
         send_delivery_sms($delivery_sn, $item['name'], $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 ($v['delivery_status'] == 5) {
                 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,update_time = '" . NOW_TIME . "' 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,update_time = '" . NOW_TIME . "' where id = " . $order_id);
             //部分发
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set delivery_status = 2,update_time = '" . NOW_TIME . "' where id = " . $order_id);
             //全部发
         }
         order_log($item['name'] . "发货了,发货单号:" . $delivery_sn, $order_id);
         update_order_cache($order_id);
         distribute_order($order_id);
         send_msg($order_info['user_id'], $item['name'] . "发货了,发货单号:" . $delivery_sn, "orderitem", $item['id']);
         $data['status'] = 1;
         $data['info'] = "发货成功";
         ajax_return($data);
     } else {
         $data['status'] = 0;
         $data['info'] = "非法的数据";
         ajax_return($data);
     }
 }