Exemple #1
0
function timely_stock_alarm()
{
    /*仓库管理员操作*/
    if (admin_priv('stock_alarm_confirm', '', false) && !admin_priv('all', '', false)) {
        $mod_stock_quantity = true;
        $where = " AND confirm_sto_admin<>{$_SESSION['admin_id']} AND confirm_sto_times<30 AND edit_status = 0 ";
    }
    $time_now = $_SERVER['REQUEST_TIME'];
    $sql_select = 'SELECT g.goods_sn,g.goods_name,SUM(s.quantity) AS quantity,warn_number, add_sto_order_time,predict_arrival_time FROM ' . $GLOBALS['ecs']->table('stock_goods') . ' s LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' g ON g.goods_sn=s.goods_sn' . " WHERE g.is_delete=0 AND s.status=1 {$where} AND warn_number<>0 GROUP BY s.goods_sn ";
    $stock_goods = $GLOBALS['db']->getAll($sql_select . 'ORDER BY quantity DESC');
    foreach ($stock_goods as $val) {
        if ($val['quantity'] <= $val['warn_number'] && $val['quantity'] != 0) {
            $alarm_stock_goods[] = $val;
        } elseif ($val['confirm_sto_admin']) {
            $sql_update = 'UPDATE ' . $GLOBALS['ecs']->table('stock_goods') . " SET confirm_sto_admin=0,confirm_sto_times=0,predict_arrival_time=0,edit_status=0" . " WHERE goods_sn='{$val['goods_sn']}'";
            $GLOBALS['db']->query($sql_update);
        }
    }
    if ($mod_stock_quantity) {
        $alarm_stock_goods = $GLOBALS['db']->getRow($sql_select . ' HAVING quantity<warn_number LIMIT 1');
        if (!$_REQUEST['sto_alarm_repeat']) {
            $sql_update = 'UPDATE ' . $GLOBALS['ecs']->table('stock_goods') . ' SET edit_status=1 ' . " WHERE goods_sn='{$alarm_stock_goods['goods_sn']}'";
            $GLOBALS['db']->query($sql_update);
            record_operate($sql_update, 'stock_goods');
        }
        if ($alarm_stock_goods) {
            $alarm_stock_goods['add_sto_order_time'] = $alarm_stock_goods['add_sto_order_time'] ? date('Y-m-d', $alarm_stock_goods['add_sto_order_time']) : 0;
            $alarm_stock_goods['predict_arrival_time'] = $alarm_stock_goods['predict_arrival_time'] ? date('Y-m-d H:i', $alarm_stock_goods['predict_arrival_time']) : 0;
        }
    }
    return $alarm_stock_goods;
}
Exemple #2
0
         }
         $sql_select = 'SELECT marketing_name FROM ' . $GLOBALS['ecs']->table('marketing') . ' m LEFT JOIN ' . $GLOBALS['ecs']->table('user_marketing') . " u ON u.marketing_id=m.marketing_id WHERE u.user_id={$user_id}";
         $now_marketing = $GLOBALS['db']->getCol($sql_select);
         $res['main'] = implode('、', $now_marketing);
         $res['message'] = $failure_msg[$change];
     } else {
         $sql_delete = 'DELETE FROM ' . $GLOBALS['ecs']->table('user_marketing') . " WHERE user_id={$user_id}";
         if ($GLOBALS['db']->query($sql_delete)) {
             $res['main'] = '';
             $res['type'] = 'checkbox';
         }
     }
     $res['type'] = 'checkbox';
 }
 // 记录客服操作
 record_operate($sql_update, 'ordersyn_info');
 // 需要修改的数据是否是顾客出生日期
 if (isset($request['lunar'])) {
     // && $request['lunar'] == 2) {
     /* 阳历转为阴历
              require_once 'includes/cls_lunar.php';
              $lunar = new Lunar;
     
              list($year, $month, $date) = explode('-', $request['value']);
     
              $lunar_date = $lunar->convertSolarToLunar($year, $month, $date);
     
              $request['value'] = "$lunar_date[0]-$lunar_date[4]-$lunar_date[5]";
               */
     $sql_update = 'UPDATE ' . $GLOBALS['ecs']->table('users') . " SET calendar={$request['lunar']} WHERE user_id={$user_id}";
     $GLOBALS['db']->query($sql_update);
Exemple #3
0
     $res['message'] = '该订单已不符合退货条件';
     die($json->encode($res));
 }
 // 恢复库存
 $result = restore_storage($order_id);
 if ($result) {
     $res['message'] = '退货失败,请检查订单信息后,再次尝试!';
     die($json->encode($res));
 }
 $return = array('order_id' => intval($_REQUEST['order_id']), 'express_number' => mysql_real_escape_string(trim($_REQUEST['express_number'])), 'return_reason' => mysql_real_escape_string(trim($_REQUEST['return_reason'])), 'return_time' => time(), 'initiate_admin_id' => $_SESSION['admin_id']);
 $fields = implode(',', array_keys($return));
 $values = implode("','", array_values($return));
 // 保存退货信息
 $sql_insert = 'INSERT INTO ' . $GLOBALS['ecs']->table('returns_order') . "({$fields})VALUES('{$values}')";
 if ($GLOBALS['db']->query($sql_insert)) {
     record_operate($sql_insert, 'order_info');
     // 记录退货操作
     // 修改订单状态为退货状态
     $sql_update = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET shipping_status=4 WHERE order_id={$order_id}";
     if ($GLOBALS['db']->query($sql_update)) {
         $res['code'] = 1;
         $res['message'] = '系统已受理您的退货请求!';
         $sql_delete = 'DELETE FROM ' . $GLOBALS['ecs']->table('repeat_purchase') . " WHERE order_id={$order_id}";
         $GLOBALS['db']->query($sql_delete);
         $sql_select = 'SELECT user_id FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id={$order_id}";
         $user_id = $GLOBALS['db']->getOne($sql_select);
         $sql_select = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE user_id={$user_id} AND order_status=5 AND shipping_status=2";
         $deal_order_number = $GLOBALS['db']->getOne($sql_select);
         if ($deal_order_number <= 0) {
             $sql_update = 'UPDATE ' . $GLOBALS['ecs']->table('users') . " SET customer_type=IF(customer_type<>1,2,1) WHERE user_id={$user_id}";
             $GLOBALS['db']->query($sql_update);