Example #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)");
    }
}
Example #2
0
function Shopsys_DoCutMaxnum($add, $userid, $username)
{
    global $empire, $dbtbpre;
    //验证权限
    CheckLevel($userid, $username, $classid, "shopdd");
    $ddid = $add['ddid'];
    $ecms = (int) $add['cutmaxnum'];
    $count = count($ddid);
    if (!$count) {
        printerror('NotSetDdid', '');
    }
    $log_ecms = 'DoCutMaxnum';
    $log_bz = '';
    $log_addbz = "ecms={$ecms}";
    $shoppr = ShopSys_hReturnSet();
    $ids = '';
    $dh = '';
    for ($i = 0; $i < $count; $i++) {
        $doddid = (int) $ddid[$i];
        if (!$doddid) {
            continue;
        }
        $ddaddr = $empire->fetch1("select buycar from {$dbtbpre}enewsshopdd_add where ddid='{$doddid}'");
        if (empty($ddaddr['buycar'])) {
            continue;
        }
        $ddr = $empire->fetch1("select havecutnum from {$dbtbpre}enewsshopdd where ddid='{$doddid}'");
        Shopsys_hCutMaxnum($doddid, $ddaddr['buycar'], $ddr['havecutnum'], $shoppr, $ecms);
        $ids .= $dh . $doddid;
        $dh = ',';
        //写入订单日志
        ShopSys_DdInsertLog($doddid, $log_ecms, $log_bz, $log_addbz);
    }
    insert_dolog("ddid={$ids}<br>ecms={$ecms}");
    //操作日志
    printerror('CutMaxnumSuccess', $_SERVER['HTTP_REFERER']);
}