function changeStatus($rid)
{
    global $db, $ecs;
    $sql = "select oi.order_id,oi.order_status,oi.shipping_status,oi.pay_status,IFNULL(bo.back_type,'-1') as backtype from " . $ecs->table('order_info') . " as oi left join " . $ecs->table('back_order') . " as bo on oi.order_id=bo.order_id and bo.status_back < 6 where oi.store_rebate_id=" . $rid . " and oi.store_rebate_ispay=1";
    $info = $db->getAll($sql);
    if (empty($info)) {
        //全部订单已经返佣
        return true;
    }
    foreach ($info as $key => $row) {
        $is_order = $is_shipping = $is_pay = 0;
        //订单状态
        if ($row['order_status'] == OS_CONFIRMED || $row['order_status'] == OS_SPLITED) {
            $is_order = 1;
        }
        //配送状态
        if ($row['shipping_status'] == SS_SHIPPED) {
            $is_shipping = 1;
        }
        if ($row['shipping_status'] == SS_RECEIVED) {
            return false;
        }
        //支付状态
        if ($row['pay_status'] == PS_PAYED) {
            $is_pay = 1;
        }
        if ($is_order && $is_shipping && $is_pay) {
            //订单状态,支付状,配送状态正常
            $cha = datecha($row['shipping_time']);
            $row['datas'] = $GLOBALS['_CFG']['okgoods_time'] - $cha;
            if ($row['datas'] <= 0) {
                //订单时间也已经超过了规定退换货的时间限制
                return false;
                //说明还有没有结算的订单
            }
            if ($row['backtype'] == 3) {
                //3表示申请维修的订单
                return false;
                //存在维修的订单,还没有结算
            }
        }
    }
    return true;
}
예제 #2
0
 /* 检查权限 */
 admin_priv('supplier_manage');
 /* 取得供货商返佣信息 */
 $id = $_REQUEST['id'];
 $is_pay_ok = $_REQUEST['is_pay_ok'] ? intval($_REQUEST['is_pay_ok']) : 0;
 $sql = "SELECT r.*, s.supplier_name, s.bank, s.supplier_rebate FROM " . $ecs->table('supplier_rebate') . " AS r left join " . $ecs->table('supplier') . "  AS s on r.supplier_id=s.supplier_id WHERE r.rebate_id = '{$id}'";
 $rebate = $db->getRow($sql);
 if (empty($rebate)) {
     sys_msg('该返佣记录不存在!');
 } else {
     $nowtime = time();
     $rebate['rebate_paytime_start'] = local_date('Y.m.d', $rebate['rebate_paytime_start']);
     $paytime_end = $rebate['rebate_paytime_end'];
     $rebate['rebate_paytime_end'] = local_date('Y.m.d', $paytime_end);
     $rebate['isdo'] = $paytime_end + $GLOBALS['_CFG']['tuihuan_days_qianshou'] * 3600 * 24 >= $nowtime ? 0 : 1;
     $rebate['chadata'] = datecha($paytime_end + $GLOBALS['_CFG']['tuihuan_days_qianshou'] * 3600 * 24);
     $rebate['all_money'] = $GLOBALS['db']->getOne("select sum(money_paid) from " . $GLOBALS['ecs']->table('order_info') . " where rebate_id=" . $rebate['rebate_id'] . " and rebate_ispay=2");
     $rebate['all_money_formated'] = price_format($rebate['all_money']);
     $rebate['rebate_money'] = round($rebate['all_money'] * $rebate['supplier_rebate'] / 100, 2);
     $rebate['rebate_money_formated'] = price_format($rebate['rebate_money']);
     $rebate['pay_money'] = $rebate['all_money'] - $rebate['rebate_money'];
     $rebate['pay_money_formated'] = price_format($rebate['pay_money']);
     $rebate_bank_arr = explode("\n", str_replace("\r\n", "\n", $rebate['bank']));
     $rebate['bank_arr'] = $rebate_bank_arr;
     $rebate['pay_status'] = $rebate['is_pay_ok'] ? "已处理,已返佣" : "未处理";
     $rebate['pay_time_formated'] = $rebate['pay_time'] ? local_date('Y.m.d', $rebate['pay_time']) : '';
     $sql = "select s.*, r.rank_name, u.user_name from " . $ecs->table('supplier') . " AS s left join " . $ecs->table('supplier_rank') . " AS r on s.rank_id=r.rank_id left join " . $ecs->table('users') . " AS u on s.user_id=u.user_id  where s.supplier_id='{$rebate['supplier_id']}' ";
     $supplier = $db->getRow($sql);
     if (!empty($supplier)) {
         $supplier['province'] = $db->getOne("select region_name from " . $ecs->table('region') . " where region_id='{$supplier['province']}' ");
         $supplier['city'] = $db->getOne("select region_name from " . $ecs->table('region') . " where region_id='{$supplier['city']}' ");