} } $res = crm_msg('一键分类成功'); } else { $res = crm_msg('一键分类失败'); } die($json->encode($res)); } elseif ('set_access' == $_REQUEST['act']) { $contact_id = intval($_REQUEST['id']); $access_time = strtotime($_REQUEST['access_time']); $sql = 'UPDATE ' . $GLOBALS['ecs']->table('user_contact') . " SET access=1,access_time={$access_time} WHERE contact_id={$contact_id}"; $code = $GLOBALS['db']->query($sql); if ($code) { $res = crm_msg('验证通过', true); } else { $res = crm_msg('失败', false); } die($json->encode($res)); } elseif ('set_user_level' == $_REQUEST['act']) { $id = intval($_REQUEST['id']); $level = intval($_REQUEST['level']); $table = mysql_real_escape_string($_REQUEST['table']); if ($id && $table == 'order') { $sql = 'SELECT user_id FROM ' . $GLOBALS['ecs']->table('ordersyn_info') . " WHERE order_id={$id}"; $user_id = $GLOBALS['db']->getOne($sql); $table = 'userssyn'; } else { $table = 'users'; $user_id = $id; } if ($user_id) {
if (empty($_REQUEST['take_days'])) { $_REQUEST['take_days'] = $_REQUEST['per_unit_number'] / $_REQUEST['every_num'] / $_REQUEST['everyday_use'] * 24 * 3600; } } $fields = array_keys($_REQUEST); $values = array_values($_REQUEST); $fields = '(' . implode(',', $fields) . ')'; $values = "VALUES('" . implode("','", $values) . "')"; $sql_insert = 'INSERT INTO ' . $GLOBALS['ecs']->table('goods') . $fields . $values; $result = $GLOBALS['db']->query($sql_insert); if ($result) { record_operate($sql_insert, 'goods'); $res = crm_msg('新商品添加成功。商品编号为' . $_REQUEST['goods_sn']); die($json->encode($res)); } else { $res = crm_msg('添加失败'); die($json->encode($res)); } } elseif ($_REQUEST['act'] == 'edit_goods') { $goods_id = $_GET['goods_id']; $sql_select = 'SELECT g.*,c.cat_name,b.brand_name FROM ' . $GLOBALS['ecs']->table('goods') . ' g,' . $GLOBALS['ecs']->table('category') . ' c,' . $GLOBALS['ecs']->table('brand') . " b WHERE goods_id={$goods_id} " . ' AND g.cat_id=c.cat_id AND g.brand_id=b.brand_id'; $goods = $GLOBALS['db']->getRow($sql_select); //给商品分类赋值 $smarty->assign('cat_list', cat_list(0, $goods['cat_id'])); //给品牌赋值 $smarty->assign('brand_list', get_brand_list()); $smarty->assign('goods', $goods); $res['main'] = $smarty->fetch('edit_goods.htm'); die($json->encode($res)); } elseif ($_REQUEST['act'] == 'get_detail') { $goods_id = intval($_REQUEST['goods_id']);
case 'sch': $order_sn = mysql_real_escape_string($_REQUEST['order_sn']); $sql = 'SELECT o.express_fee,o.consignee,r.region_name,s.shipping_name FROM ' . $GLOBALS['ecs']->table('order_info') . ' o,' . $GLOBALS['ecs']->table('region') . ' r,' . $GLOBALS['ecs']->table('shipping') . " s WHERE o.province=r.region_id AND o.shipping_id=s.shipping_id AND o.order_sn={$order_sn}"; $info = $GLOBALS['db']->getRow($sql); $smarty->assign('order_sn', $order_sn); $smarty->assign('info', $info); $res['main'] = $smarty->fetch('modify_express_fee.htm'); break; case 'done': $express_fee = floatval($_REQUEST['express_fee']); $order_sn = mysql_real_escape_string($_REQUEST['order_sn']); $sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') . " SET express_fee={$express_fee} WHERE order_sn='{$order_sn}'"; if ($GLOBALS['db']->query($sql)) { $res = crm_msg('修改成功'); } else { $res = crm_msg('修改失败'); } break; } die($json->encode($res)); } /** * 订单列表 */ function order_list() { $now_time = time() + 8 * 3600; $temp_fields = ''; $table_admin = ''; $order_status = ''; $condition = '';
} $GLOBALS['db']->query('COMMIT'); } else { $code = true; } if ($feature) { $sql = 'SELECT article_id FROM ' . $GLOBALS['ecs']->table('article') . $where . ' AND cat_id=5'; $article_id = $GLOBALS['db']->getOne($sql); if ($article_id) { $sql = 'UPDATE ' . $GLOBALS['ecs']->table('article') . " SET content='{$feature}' WHERE article_id={$article_id}"; } else { $sql = "INSERT INTO " . $GLOBALS['ecs']->table('article') . "(goods_sn,title,cat_id,content,add_time) " . "VALUES('{$goods_sn}','{$goods_sn}的卖点',5,'{$feature}',{$_SERVER['REQUEST_TIME']})"; } $cdoe = $GLOBALS['db']->query($sql); } $res = !$code ? crm_msg('编辑失败') : crm_msg('编辑成功'); } die($json->encode($res)); } elseif ($_REQUEST['act'] == 'save_article') { $goods_cat_id = intval($_REQUEST['cat_id']); $cat_name = mysql_real_escape_string($_REQUEST['cat_name']); $talk_skill = $_REQUEST['talk_skill']; $effect = $_REQUEST['effect']; $add_time = $_SERVER['REQUEST_TIME']; if ($goods_cat_id) { $sql_insert = "INSERT INTO " . $GLOBALS['ecs']->table('article') . "(goods_cat_id,title,cat_id,content, add_time) "; $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('article') . " WHERE cat_id=%d AND goods_cat_id={$goods_cat_id}"; $sql_upd = 'UPDATE ' . $GLOBALS['ecs']->table('article') . " SET content='%s',add_time={$add_time}" . " WHERE goods_cat_id={$goods_cat_id} AND cat_id=%d"; if ($talk_skill) { if ($GLOBALS['db']->getOne(sprintf($sql, 4))) { $GLOBALS['db']->query(sprintf($sql_upd, $talk_skill, 4));
//$GLOBALS['db']->query($sql_insert); ////获取工作总结对应的id //$work_id = $GLOBALS['db']->insert_id(); //插入推广表 $today = strtotime(date('Y-m-d 00:00:00')); //$sql_select = 'SELECT COUNT(1) FROM ' // .$GLOBALS['ecs']->table('spread')." WHERE platform={$_SESSION['role_id']} AND admin_id={$_SESSION['admin_id']} AND add_time>$today"; //if ($GLOBALS['db']->getOne($sql_select)) { // $res = crm_msg('一天只能提交一次'); //}else{ $sql_insert = 'INSERT INTO ' . $GLOBALS['ecs']->table('spread') . '(pc_spread_uv,pc_order_num,pc_sale,m_spread_uv,m_order_num,m_sale,admin_id,add_time,report_time,scalping_amount,scalping_num,platform,ad_amount,activity_sale)' . "VALUES({$pc_spread_uv},{$pc_order_num},{$pc_sale},{$m_spread_uv},{$m_order_num},{$m_sale},{$_SESSION['admin_id']},{$_SERVER['REQUEST_TIME']},{$report_time},{$scalping_amount},{$scalping_num},{$_SESSION['role_id']},{$ad_amount},{$activity_sale})"; $code = $GLOBALS['db']->query($sql_insert); if ($code) { $res = crm_msg('提交成功'); } else { $res = crm_msg('提交失败', $code); } //} die($json->encode($res)); } elseif ($_REQUEST['act'] == 'spread_edit') { $sid = isset($_GET['sid']) ? intval($_GET['sid']) : 1; //根据传过来的sid查找对应多条记录 $sql_select = 'SELECT * FROM ' . $GLOBALS['ecs']->table('spread') . ' AS s,' . $GLOBALS['ecs']->table('spread_ad') . ' d,' . $GLOBALS['ecs']->table('work_summary') . ' w,' . $GLOBALS['ecs']->table('advertisement') . " ad WHERE s.spread_id={$sid} AND \n s.spread_id=d.spread_id AND s.work_id=w.work_id AND d.adname_id=ad.id"; $row = $GLOBALS['db']->getAll($sql_select); //查询推广表的记录 $sql_select = 'SELECT * FROM ' . $GLOBALS['ecs']->table('spread') . ' s,' . $GLOBALS['ecs']->table('work_summary') . " w WHERE s.spread_id={$sid} AND s.work_id=w.work_id"; $spread_list = $GLOBALS['db']->getRow($sql_select); //获取所属商城的所有名字 $sql_select = 'SELECT role_id,role_name FROM ' . $GLOBALS['ecs']->table('role'); $role_list = $GLOBALS['db']->getAll($sql_select); $smarty->assign('role_list', $role_list);
function batch_fill_order_shipping() { $_REQUEST['act'] = 'current_order'; $res['error'] = ''; $has_used = array(); $un_match = array(); $success = array(); $error = array(); if (!empty($_GET['tracking_start']) && !empty($_GET['order_num'])) { $order_list = order_list(); if ($order_list) { $order_list = $order_list['orders']; $tracking_start = mysql_real_escape_string(trim($_GET['tracking_start'])); $shipping_id = $_REQUEST['shipping_id']; $total = $_GET['order_num'] < count($order_list) ? $_GET['order_num'] : count($order_list); for ($i = 0; $i < $total; $i++) { $tracking[$i] = $tracking_start + $i; } $list = array(); unset($k); foreach ($order_list as $o) { if (!trim($o['tracking_sn'])) { $list[]['order_id'] = $o['order_id']; } } $order_list = $list; unset($o); foreach ($order_list as $k => $o) { if ($k > $total) { break; } else { $sql = 'SELECT order_id FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id<>{$o['order_id']} AND shipping_status NOT IN (3,4) AND tracking_sn='{$tracking[$k]}'"; if ($GLOBALS['db']->getOne($sql)) { $has_used[] = $tracking[$k]; continue; } else { // 验证运单号与快递公司是否一致 $sql_select = 'SELECT code_regexp FROM ' . $GLOBALS['ecs']->table('shipping') . ' s, ' . $GLOBALS['ecs']->table('order_info') . " i WHERE i.shipping_id=s.shipping_id AND i.order_id={$o['order_id']}"; $regexp = $GLOBALS['db']->getOne($sql_select); if ($shipping_id == 39) { $tracking[$k] = "{$tracking[$k]}"; } if ($regexp && !preg_match($regexp, $tracking[$k])) { $un_match[] = $tracking[$k]; } else { $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET tracking_sn='{$tracking[$k]}'," . " shipping_time={$_SERVER['REQUEST_TIME']} WHERE order_id={$o['order_id']} AND tracking_sn<>'{$tracking[$k]}'"; if ($GLOBALS['db']->query($sql)) { $syn_info = shipping_synchro($o['order_id']); if (!empty($syn_info['message'])) { $error[] = $syn_info['message']; } else { $success[] = array('order_id' => $o['order_id'], 'tracking_sn' => $tracking[$k]); } } else { $error[] = $tracking_sn; } } } } } $res = array('has_used' => $has_used, 'un_match' => $un_match, 'error' => $error, 'success' => $success); } else { $res = crm_msg('没有相应订单'); } } else { $res['message'] = '请输入正确的运单号!'; } return $res; }
if (!empty($role_id)) { $sql = 'SELECT role_id FROM ' . $GLOBALS['ecs']->table('admin_user') . " WHERE user_id={$user_id}"; $pre_role_id = $GLOBALS['db']->getOne($sql); if ($pre_role_id != $role_id) { $sql = 'SELECT action_list FROM ' . $GLOBALS['ecs']->table('role') . " WHERE role_id={$role_id}"; $row = $GLOBALS['db']->getRow($sql); $upd .= ",action_list='" . $row['action_list'] . "',role_id={$role_id},"; } } //更新管理员信息 $sql_update = 'UPDATE ' . $ecs->table('admin_user') . " SET {$upd} WHERE user_id={$user_id}"; $code = $GLOBALS['db']->query($sql_update); if ($code) { $res = crm_msg('修改成功', $code); } elseif ($code) { $res = crm_msg('修改失败', $code); } die($json->encode($res)); } } elseif ($_REQUEST['act'] == 'assign_authority') { if ($_REQUEST['user_id'] != '') { $user_id = intval($_REQUEST['user_id']); $smarty->assign('user_id', $user_id); $sql_select = 'SELECT * FROM ' . $GLOBALS['ecs']->table('admin_user') . " WHERE user_id={$user_id}"; } elseif ($_REQUEST['role_id'] != '') { $role_id = intval($_REQUEST['role_id']); $smarty->assign('role_id', $role_id); $sql_select = 'SELECT * FROM ' . $GLOBALS['ecs']->table('role') . " WHERE role_id={$role_id}"; } $result = $GLOBALS['db']->getRow($sql_select); $action_list = explode(',', $result['action_list']);
$depart_list = get_department(' AND depart_id IN(' . SALE_DEPART . ')'); $smarty->assign('role_list', $role_list); $smarty->assign('depart_list', $depart_list); $res['main'] = $smarty->fetch('main_sale_report.htm'); } die($json->encode($res)); } elseif ($_REQUEST['act'] == 'del_main_sale') { $role_id = intval($_REQUEST['role_id']); $goods_id = intval($_REQUEST['goods_id']); $sql = 'DELETE FROM' . $GLOBALS['ecs']->table('main_sale') . " WHERE main_key='{$role_id}{$goods_id}'"; $code = $GLOBALS['db']->query($sql); if ($code) { $res = crm_msg('删除成功', $code); $res['id'] = "{$role_id}{$goods_id}"; } else { $res = crm_msg('删除失败'); } die($json->encode($res)); } } /*------------------------------------------------------ */ //--排行统计需要的函数 /*------------------------------------------------------ */ /** * 取得销售排行数据信息 * @param bool $is_pagination 是否分页 * @return array 销售排行数据 */ function sales_rank($is_pagination = true) { $condition = '';