Пример #1
0
function SetShopDd($add, $userid, $username)
{
    global $empire, $dbtbpre;
    //验证权限
    CheckLevel($userid, $username, $classid, "shopdd");
    $ddid = $add['ddid'];
    $doing = $add['doing'];
    $checked = (int) $add['checked'];
    $haveprice = (int) $add['haveprice'];
    $outproduct = (int) $add['outproduct'];
    $count = count($ddid);
    if (empty($count)) {
        printerror("NotSetDdid", "history.go(-1)");
    }
    $shoppr = ShopSys_hReturnSet();
    $add = '';
    $ids = '';
    $dh = '';
    for ($i = 0; $i < $count; $i++) {
        $ddid[$i] = (int) $ddid[$i];
        $ids .= $dh . $ddid[$i];
        $dh = ',';
    }
    $add = 'ddid in (' . $ids . ')';
    $mess = 'ErrorUrl';
    $log = '';
    if ($doing == 1) {
        $sql = $empire->query("update {$dbtbpre}enewsshopdd set checked='{$checked}' where " . $add);
        $mess = "SetCheckedSuccess";
        $log = "doing={$doing}&do=SetChecked&checked={$checked}<br>ddid={$ids}";
        //订单日志
        $log_ecms = 'SetChecked';
        $log_bz = '';
        if ($checked == 1) {
            $log_addbz = '确认';
        } elseif ($checked == 2) {
            $log_addbz = '取消';
        } elseif ($checked == 3) {
            $log_addbz = '退货';
        } elseif ($checked == 0) {
            $log_addbz = '未确认';
        }
        //写入订单日志
        if ($ids) {
            $logsql = $empire->query("select ddid,havecutnum from {$dbtbpre}enewsshopdd where " . $add);
            while ($logr = $empire->fetch($logsql)) {
                ShopSys_DdInsertLog($logr['ddid'], $log_ecms, $log_bz, $log_addbz);
                //订单日志
                //库存
                if ($shoppr['cutnumtype'] == 0 && $checked == 2 && $logr['havecutnum']) {
                    $ddaddr = $empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='{$logr['ddid']}'");
                    Shopsys_hCutMaxnum($logr['ddid'], $ddaddr['buycar'], $logr['havecutnum'], $shoppr, 1);
                }
            }
        }
    } elseif ($doing == 2) {
        $sql = $empire->query("update {$dbtbpre}enewsshopdd set outproduct='{$outproduct}' where " . $add);
        $mess = "SetOutProductSuccess";
        $log = "doing={$doing}&do=SetOutProduct&outproduct={$outproduct}<br>ddid={$ids}";
        //订单日志
        $log_ecms = 'SetOutProduct';
        $log_bz = '';
        if ($outproduct == 1) {
            $log_addbz = '已发货';
        } elseif ($outproduct == 2) {
            $log_addbz = '备货中';
        } elseif ($outproduct == 0) {
            $log_addbz = '未发货';
        }
        //写入订单日志
        if ($ids) {
            $logsql = $empire->query("select ddid from {$dbtbpre}enewsshopdd where " . $add);
            while ($logr = $empire->fetch($logsql)) {
                ShopSys_DdInsertLog($logr['ddid'], $log_ecms, $log_bz, $log_addbz);
                //订单日志
            }
        }
    } elseif ($doing == 3) {
        $sql = $empire->query("update {$dbtbpre}enewsshopdd set haveprice='{$haveprice}' where " . $add);
        $mess = "SetHavepriceSuccess";
        $log = "doing={$doing}&do=SetHaveprice&haveprice={$haveprice}<br>ddid={$ids}";
        //订单日志
        $log_ecms = 'SetHaveprice';
        $log_bz = '';
        if ($haveprice == 1) {
            $log_addbz = '已付款';
        } elseif ($haveprice == 0) {
            $log_addbz = '未付款';
        }
        //写入订单日志
        if ($ids) {
            $logsql = $empire->query("select ddid,havecutnum from {$dbtbpre}enewsshopdd where " . $add);
            while ($logr = $empire->fetch($logsql)) {
                ShopSys_DdInsertLog($logr['ddid'], $log_ecms, $log_bz, $log_addbz);
                //订单日志
                //库存
                if ($shoppr['cutnumtype'] == 1 && $haveprice == 1 && !$logr['havecutnum']) {
                    $ddaddr = $empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='{$logr['ddid']}'");
                    Shopsys_hCutMaxnum($logr['ddid'], $ddaddr['buycar'], $logr['havecutnum'], $shoppr, 0);
                }
            }
        }
    } elseif ($doing == 4) {
        $log_ecms = 'DelDd';
        $log_bz = '';
        $log_addbz = '';
        //库存
        if ($ids) {
            $logsql = $empire->query("select ddid,havecutnum,checked,haveprice from {$dbtbpre}enewsshopdd where " . $add . " and havecutnum=1");
            while ($logr = $empire->fetch($logsql)) {
                if ($logr['haveprice'] == 1) {
                    continue;
                }
                if ($logr['havecutnum']) {
                    $ddaddr = $empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='{$logr['ddid']}'");
                    Shopsys_hCutMaxnum($logr['ddid'], $ddaddr['buycar'], $logr['havecutnum'], $shoppr, 1);
                }
            }
        }
        $sql = $empire->query("delete from {$dbtbpre}enewsshopdd where " . $add);
        $sql2 = $empire->query("delete from {$dbtbpre}enewsshopdd_add where " . $add);
        $sql3 = $empire->query("delete from {$dbtbpre}enewsshop_ddlog where " . $add);
        $mess = "DelDdSuccess";
        $log = "doing={$doing}&do=DelDd<br>ddid={$ids}";
    } else {
        printerror("ErrorUrl", "history.go(-1)");
    }
    if ($sql) {
        //操作日志
        insert_dolog($log);
        printerror($mess, $_SERVER['HTTP_REFERER']);
    } else {
        printerror("DbError", "history.go(-1)");
    }
}
Пример #2
0
function ShopSys_hTimeCutMaxnum($userid, $shoppr)
{
    global $empire, $dbtbpre, $class_r;
    if ($shoppr['cutnumtype'] == 1 || $shoppr['cutnumtime'] == 0) {
        return '';
    }
    $userid = (int) $userid;
    $where = $userid ? "userid='{$userid}' and " : "";
    $time = time() - $shoppr['cutnumtime'] * 60;
    $ddsql = $empire->query("select ddid,havecutnum from {$dbtbpre}enewsshopdd where " . $where . "haveprice=0 and checked=0 and havecutnum=1 and ddtruetime<{$time}");
    while ($ddr = $empire->fetch($ddsql)) {
        $ddaddr = $empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='{$ddr['ddid']}'");
        Shopsys_hCutMaxnum($ddr['ddid'], $ddaddr['buycar'], $ddr['havecutnum'], $shoppr, 1);
    }
    $empire->query("update {$dbtbpre}enewsshopdd set checked=2 where " . $where . "haveprice=0 and checked=0 and havecutnum=1 and ddtruetime<{$time}");
}