Commit dcd1573a authored by hezhen's avatar hezhen

修改最新问题

parent 5bef6b3b
...@@ -82,6 +82,13 @@ if ($_GPC['action'] == 'delete') { ...@@ -82,6 +82,13 @@ if ($_GPC['action'] == 'delete') {
message('删除失败', '', 'error'); message('删除失败', '', 'error');
} }
if($_GPC['action']=='region'){
$parent_id= isset($_GPC["id"])?$_GPC["id"]:1;
$sql = "select * from ".tablename('sys_region')." where parent_id =".$parent_id;
$list=pdo_fetchall($sql);
exit(json_encode(array('errno'=>0,'message'=>'','data'=>$list)));
}
if ($_GPC['action'] == 'edit') { if ($_GPC['action'] == 'edit') {
$time = time(); $time = time();
......
...@@ -18,12 +18,6 @@ if ($id) { ...@@ -18,12 +18,6 @@ if ($id) {
$company['culture'] = explode(',', $company['culture']); $company['culture'] = explode(',', $company['culture']);
} }
if($_GPC['action']=='region'){
$parent_id= isset($_GPC["parent_id"])?$_GPC["parent_id"]:1;
$sql = "select * from ".tablename('sys_region')." where parent_id =".$parent_id;
$list=pdo_fetchall($sql);
exit(json_encode(array('errno'=>0,'message'=>'','data'=>$list)));
}
load()->func('tpl'); load()->func('tpl');
include $this->template('manage/companyEdit'); include $this->template('manage/companyEdit');
......
...@@ -22,6 +22,37 @@ if (function_exists('longbing_check_redis')) { ...@@ -22,6 +22,37 @@ if (function_exists('longbing_check_redis')) {
list($redis_sup_v3, $redis_server_v3) = longbing_check_redis($config['server'], $config['port'], $password); list($redis_sup_v3, $redis_server_v3) = longbing_check_redis($config['server'], $config['port'], $password);
} }
} }
function getCompanys($good_id){
$sql="SELECT c.id,c.name FROM".tablename('longbing_company_company')." c LEFT JOIN ".tablename('longbing_company_goods_company')." g
ON c.id=g.company_id WHERE g.good_id=$good_id and g.isdel=0 and c.status=1";
$list=pdo_fetchall($sql);
return $list;
}
function updateCompany($ids,$good_id){
if(!$ids){
$sql="delete FROM ".tablename('longbing_company_goods_company')."WHERE good_id = $good_id";
pdo_query($sql);
return;
}else{
$sql="delete FROM ".tablename('longbing_company_goods_company')."WHERE good_id = $good_id and company_id not in ( $ids )";
pdo_query($sql);
}
$ids = explode(',',$ids);
foreach ($ids as $val){
$info=pdo_get('longbing_company_goods_company',array('good_id'=>$good_id,'company_id'=>$val,'isdel'=>0));
if(!$info){
pdo_insert('longbing_company_goods_company', array('good_id' => $good_id, 'company_id' => $val));
}
}
}
if ($_GPC['action'] == 'company') {
if($_GPC['city']){
$list = pdo_getall('ims_longbing_company_company', array('status' => 1, 'uniacid' => $_W['uniacid'], 'city' => $_GPC['city']));
}
exit(json_encode(array('errno'=>0,'message'=>'','data'=>$list)));
}
if ($_GPC['action'] == 'edit') { if ($_GPC['action'] == 'edit') {
foreach ($_GPC['formData'] as $k => $v) { foreach ($_GPC['formData'] as $k => $v) {
...@@ -29,10 +60,17 @@ if ($_GPC['action'] == 'edit') { ...@@ -29,10 +60,17 @@ if ($_GPC['action'] == 'edit') {
$data['images'][] = $v; $data['images'][] = $v;
} }
else { else {
$data[$k] = $v; if($k=='ids'){
$ids=$v;
}elseif($k=='city'||$k=='province'){
continue;
}
else{
$data[$k] = $v;
}
} }
} }
if (isset($data['images'])) { if (isset($data['images'])) {
$data['images'] = implode(',', $data['images']); $data['images'] = implode(',', $data['images']);
} }
...@@ -46,12 +84,12 @@ if ($_GPC['action'] == 'edit') { ...@@ -46,12 +84,12 @@ if ($_GPC['action'] == 'edit') {
$data['type_p'] = $type['pid'] ? $type['pid'] : $type['id']; $data['type_p'] = $type['pid'] ? $type['pid'] : $type['id'];
$id = $_GPC['id']; $id = $_GPC['id'];
$result = false; $result = false;
if ($id) { if ($id) {
$result = pdo_update('longbing_company_goods', $data, array('id' => $id)); $result = pdo_update('longbing_company_goods', $data, array('id' => $id));
$destination_folder = ATTACHMENT_ROOT . '/images' . ('/longbing_company/' . $_W['uniacid']); $destination_folder = ATTACHMENT_ROOT . '/images' . ('/longbing_company/' . $_W['uniacid']);
$image2 = $destination_folder . '/' . $_W['uniacid'] . '-goods-' . $id . '.png'; $image2 = $destination_folder . '/' . $_W['uniacid'] . '-goods-' . $id . '.png';
@unlink($image2); @unlink($image2);
$good_id=$id;
} }
else { else {
if (LONGBING_AUTH_GOODS) { if (LONGBING_AUTH_GOODS) {
...@@ -66,6 +104,7 @@ if ($_GPC['action'] == 'edit') { ...@@ -66,6 +104,7 @@ if ($_GPC['action'] == 'edit') {
$data['create_time'] = time(); $data['create_time'] = time();
$data['uniacid'] = $_W['uniacid']; $data['uniacid'] = $_W['uniacid'];
$result = pdo_insert('longbing_company_goods', $data); $result = pdo_insert('longbing_company_goods', $data);
$good_id=pdo_insertid();
} }
if ($result && !$id) { if ($result && !$id) {
...@@ -76,6 +115,8 @@ if ($_GPC['action'] == 'edit') { ...@@ -76,6 +115,8 @@ if ($_GPC['action'] == 'edit') {
$spe_id = pdo_insertid(); $spe_id = pdo_insertid();
pdo_insert('longbing_company_shop_spe_price', array('goods_id' => $goodsId, 'uniacid' => $_W['uniacid'], 'spe_id_1' => $spe_id, 'create_time' => time(), 'update_time' => time(), 'price' => $data['price'], 'stock' => $data['stock'])); pdo_insert('longbing_company_shop_spe_price', array('goods_id' => $goodsId, 'uniacid' => $_W['uniacid'], 'spe_id_1' => $spe_id, 'create_time' => time(), 'update_time' => time(), 'price' => $data['price'], 'stock' => $data['stock']));
} }
updateCompany($ids,$good_id);
if ($result) { if ($result) {
if ($redis_sup_v3) { if ($redis_sup_v3) {
...@@ -100,14 +141,13 @@ if (isset($_GPC['id'])) { ...@@ -100,14 +141,13 @@ if (isset($_GPC['id'])) {
$where['id'] = $_GPC['id']; $where['id'] = $_GPC['id'];
$id = $_GPC['id']; $id = $_GPC['id'];
$info = pdo_get('longbing_company_goods', $where); $info = pdo_get('longbing_company_goods', $where);
$companyList =getCompanys($_GPC['id']);
if ($info['images']) { if ($info['images']) {
$info['images'] = explode(',', $info['images']); $info['images'] = explode(',', $info['images']);
} }
}
}
$typeList = pdo_getall('longbing_company_shop_type', array('status' => 1, 'uniacid' => $_W['uniacid'])); $typeList = pdo_getall('longbing_company_shop_type', array('status' => 1, 'uniacid' => $_W['uniacid']));
foreach ($typeList as $k => $v) { foreach ($typeList as $k => $v) {
if ($v['pid'] != 0) { if ($v['pid'] != 0) {
foreach ($typeList as $k2 => $v2) { foreach ($typeList as $k2 => $v2) {
...@@ -118,6 +158,7 @@ foreach ($typeList as $k => $v) { ...@@ -118,6 +158,7 @@ foreach ($typeList as $k => $v) {
} }
} }
foreach ($typeList as $k => $v) { foreach ($typeList as $k => $v) {
if ($v['pid'] == 0) { if ($v['pid'] == 0) {
$typeList[$k]['title'] = $v['title']; $typeList[$k]['title'] = $v['title'];
......
...@@ -221,10 +221,13 @@ foreach ($list as $k => $v) { ...@@ -221,10 +221,13 @@ foreach ($list as $k => $v) {
foreach ($items as $k2 => $v2) { foreach ($items as $k2 => $v2) {
$names .= '; ' . $v2['name'] . ': ' . $v2['content'] . ',数量:' . $v2['number']; $names .= '; ' . $v2['name'] . ': ' . $v2['content'] . ',数量:' . $v2['number'];
$company_name .= '; ' . $v2['company_name'];
} }
$company_name = trim($company_name, '; ');
$names = trim($names, '; '); $names = trim($names, '; ');
$list[$k]['names'] = $names; $list[$k]['names'] = $names;
$list[$k]['company_name'] = $company_name;
$list[$k]['user_info'] = pdo_get('longbing_company_user', array('id' => $v['user_id'])); $list[$k]['user_info'] = pdo_get('longbing_company_user', array('id' => $v['user_id']));
if ($v['to_uid']) { if ($v['to_uid']) {
......
...@@ -122,6 +122,14 @@ function curlPostTmp($url, $data) ...@@ -122,6 +122,14 @@ function curlPostTmp($url, $data)
return $output; return $output;
} }
function getCompanys($good_id){
$sql="SELECT c.id,c.name FROM".tablename('longbing_company_company')." c LEFT JOIN ".tablename('longbing_company_goods_company')." g
ON c.id=g.company_id WHERE g.good_id=$good_id and g.isdel=0 and c.status=1";
$list=pdo_fetchall($sql);
return $list;
}
define('ROOT_PATH', IA_ROOT . '/addons/longbing_company/'); define('ROOT_PATH', IA_ROOT . '/addons/longbing_company/');
is_file(ROOT_PATH . '/inc/we7.php') || exit('Access Denied Longbing'); is_file(ROOT_PATH . '/inc/we7.php') || exit('Access Denied Longbing');
require_once ROOT_PATH . '/inc/we7.php'; require_once ROOT_PATH . '/inc/we7.php';
...@@ -136,7 +144,7 @@ if (!$to_uid) { ...@@ -136,7 +144,7 @@ if (!$to_uid) {
return $this->result(-1, '', array()); return $this->result(-1, '', array());
} }
$goods = pdo_get('longbing_company_goods', array('id' => $goods_id), array('id', 'name', 'cover', 'images', 'price', 'view_count', 'sale_count', 'desc', 'content', 'collage_count', 'is_collage', 'freight', 'recommend', 'stock', 'image_url', 'unit')); $goods = pdo_get('longbing_company_goods', array('id' => $goods_id), array('id', 'name', 'cover', 'images', 'price', 'view_count', 'sale_count', 'desc', 'content', 'collage_count', 'is_collage', 'freight', 'recommend', 'stock', 'image_url', 'unit','start_time','end_time'));
if (empty($goods)) { if (empty($goods)) {
return $this->result(-1, '', array()); return $this->result(-1, '', array());
...@@ -169,7 +177,7 @@ foreach ($speList as $k => $v) { ...@@ -169,7 +177,7 @@ foreach ($speList as $k => $v) {
} }
} }
} }
$goods['companyList']=getCompanys($goods['id']);
$goods['spe_list'] = $speList; $goods['spe_list'] = $speList;
$spe_price = pdo_getall('longbing_company_shop_spe_price', array('goods_id' => $goods_id, 'status' => 1, 'uniacid' => $uniacid), array('id', 'spe_id_1', 'price', 'stock')); $spe_price = pdo_getall('longbing_company_shop_spe_price', array('goods_id' => $goods_id, 'status' => 1, 'uniacid' => $uniacid), array('id', 'spe_id_1', 'price', 'stock'));
$goods['spe_price'] = $spe_price; $goods['spe_price'] = $spe_price;
......
...@@ -12,6 +12,9 @@ $to_uid = $_GPC['to_uid']; ...@@ -12,6 +12,9 @@ $to_uid = $_GPC['to_uid'];
$record_id = $_GPC['record_id']; $record_id = $_GPC['record_id'];
$number = $_GPC['number']; $number = $_GPC['number'];
$goods_id = $_GPC['goods_id']; $goods_id = $_GPC['goods_id'];
$trip_time = $_GPC['trip_time'];
$company_id = $_GPC['company_id'];
$company_name = $_GPC['company_name'];
$spe_id = $_GPC['spe_price_id']; $spe_id = $_GPC['spe_price_id'];
/*if (!$address_id || !$number || !$goods_id) { /*if (!$address_id || !$number || !$goods_id) {
return $this->result(-1, '', array()); return $this->result(-1, '', array());
...@@ -101,7 +104,7 @@ $result = pdo_insert('longbing_company_shop_order', $insertOrder); ...@@ -101,7 +104,7 @@ $result = pdo_insert('longbing_company_shop_order', $insertOrder);
if (!empty($result)) { if (!empty($result)) {
$order_id = pdo_insertid(); $order_id = pdo_insertid();
$insertItem = array('order_id' => $order_id, 'goods_id' => $goods_id, 'name' => $goods_info['name'], 'cover' => $goods_info['cover'], 'spe_price_id' => $spe_id, 'content' => $titles, 'number' => $number, 'price' => sprintf('%.2f', $spe_info['price'] * $number), 'uniacid' => $uniacid, 'create_time' => $time, 'update_time' => $time); $insertItem = array('order_id' => $order_id, 'goods_id' => $goods_id, 'name' => $goods_info['name'], 'cover' => $goods_info['cover'], 'spe_price_id' => $spe_id, 'content' => $titles, 'number' => $number, 'price' => sprintf('%.2f', $spe_info['price'] * $number), 'uniacid' => $uniacid, 'create_time' => $time, 'update_time' => $time,'company_id' => $company_id,'trip_time' => $trip_time,'company_name' => $company_name);
$result = pdo_insert('longbing_company_shop_order_item', $insertItem); $result = pdo_insert('longbing_company_shop_order_item', $insertItem);
return $this->result(0, '', array('order_id' => $order_id)); return $this->result(0, '', array('order_id' => $order_id));
} }
......
...@@ -79,7 +79,102 @@ ...@@ -79,7 +79,102 @@
<input type="text" name="addr" required lay-verify="required" placeholder="请输入公司地址" autocomplete="off" class="layui-input" value="{$company['addr']}"> <input type="text" name="addr" required lay-verify="required" placeholder="请输入公司地址" autocomplete="off" class="layui-input" value="{$company['addr']}">
</div> </div>
</div> </div>
<div class="layui-form-item">
<label class="layui-form-label">地址联动</label>
<div class="layui-input-inline">
<select name="province" vua_id="{$company['province']}" lay-filter="province">
<option value="省">选择省</option>
</select>
</div>
<div class="layui-input-inline">
<select name="city" vua_id="{$company['city']}">
<option value="市">选择市</option>
</select>
</div>
</div>
<script type="text/javascript">
var shengUrl="{php echo $this->createWebUrl('manage/company')}";//获取省份的接口信息;直接返回所有省份的列表,不要带其他参数;没有返回空
var shiUrl="{php echo $this->createWebUrl('manage/company')}";//获取市的接口信息;直接返回所在市的列表,不要带其他参数;没有返回空
//定义异步调用方法
function ajaxFun(e,fun){
var json_mun=false;
$.ajax({
type : "post",
url : e.url,
data : e.json,
async:false,
dataType : "json",
success : function(resp){
json_mun=resp;
if(fun){
fun(json_mun);
return false;
}
},error:function(){
if(fun){
fun(json_mun)
return false;
}
}
});
}
//获取省
function getSheng(){
ajaxFun({
url:shengUrl,
json:{action:'region'}
},function(e){
if(e){
setSheng(e.data);
}
})
}
//设置省份
function setSheng(e){
var vua_id=$("select[name='province']").attr("vua_id");
var l = e.length;
var html = "";
for(var i=0;i<l;i++){
if(e[i].id==vua_id){
html+='<option value="'+e[i].id+'" selected="selected">'+e[i].name+'</option>';
}else{
html+='<option value="'+e[i].id+'">'+e[i].name+'</option>';
}
}
$("select[name='province']").html(html);
if(vua_id){
getShi(vua_id);
}else{
getShi(e[0].id);
}
}
//获取市
function getShi(id){
ajaxFun({
url:shiUrl,
json:{action:'region',id:id}
},function(e){
if(e){
setShi(e.data);
}
})
}
//设置市
function setShi(e){
var vua_id=$("select[name='city']").attr("vua_id");
var l = e.length;
var html = "";
for(var i=0;i<l;i++){
if(e[i].id==vua_id){
html+='<option value="'+e[i].id+'" selected="selected">'+e[i].name+'</option>';
}else{
html+='<option value="'+e[i].id+'">'+e[i].name+'</option>';
}
}
$("select[name='city']").html(html);
form.render('select');
}
</script>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">公司logo</label> <label class="layui-form-label">公司logo</label>
<div class="layui-input-block"> <div class="layui-input-block">
...@@ -163,9 +258,16 @@ ...@@ -163,9 +258,16 @@
<script> <script>
layui.use(['layer', 'form'], function () { layui.use(['layer', 'form'], function () {
var layer = layui.layer var layer = layui.layer;
, form = layui.form form = layui.form
$(function(){
getSheng();
})
form.on('select(province)', function(data){
console.log(data.value);
getShi(data.value);
});
form.on('submit(formSub)', function(data){ form.on('submit(formSub)', function(data){
var formData = data.field; var formData = data.field;
layer.load(); layer.load();
...@@ -181,7 +283,6 @@ ...@@ -181,7 +283,6 @@
data.id = id; data.id = id;
} }
postData(url, data); postData(url, data);
return false; return false;
}); });
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>商品名</th> <th>商品名</th>
<th>出行公司</th>
<th>下单用户id</th> <th>下单用户id</th>
<th>下单用户微信昵称</th> <th>下单用户微信昵称</th>
<th>所属名片</th> <th>所属名片</th>
...@@ -43,6 +44,7 @@ ...@@ -43,6 +44,7 @@
{loop $list $item} {loop $list $item}
<tr> <tr>
<td>{$item['id']}</td> <td>{$item['id']}</td>
<td style="max-width: 200px">{$item['company_name']}</td>
<td style="max-width: 200px">{$item['names']}</td> <td style="max-width: 200px">{$item['names']}</td>
<td>{$item['user_id']}</td> <td>{$item['user_id']}</td>
<td>{$item['user_info']['nickName']}</td> <td>{$item['user_info']['nickName']}</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment