Mztk.php
6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/**
* tpshop
* ============================================================================
* 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
* 网站地址: http://www.tp-shop.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* Author: IT宇宙人
* Date: 2015-09-09
*/
namespace app\manager\controller;
use app\manager\logic\GoodsLogic;
use think\AjaxPage;
use think\Page;
use think\Db;
use qcloudcos\Conf;
use qcloudcos\Myqcloudcos;
class Mztk extends Base
{
/**
* 图库列表
*/
public function mztklist()
{
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$isedit = I('isedit') ? I('isedit') : '';
$getp = I('p');
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$this->assign('key_word', $key_word);
$this->assign('isedit', $isedit);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $getp);
return $this->fetch();
}
/**
* 图库列表
*/
public function ajaxmztklist()
{
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$isedit = I('isedit') ? I('isedit') : '';//是否修改
$cur_page = 1;//当前页数
if ((int)I('p/s') > 0) {
$cur_page = I('p/s');
}
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$where = ' 1 = 1 '; // 搜索条件
if ($isedit) {
$is = $isedit - 1;
$where = "$where and a.isedit= '$is'";
}
if ($key_word) {
$where = "$where and (a.goods_name like '%$key_word%' or a.sku like '%$key_word%' or a.goods_sn like '%$key_word%' or b.store_name like '%$key_word%')";
}
$count = M('barcodegoods')->alias('a')->join('store b', 'a.store_id=b.store_id', 'left')->where($where)->count();
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$goodsList = M('barcodegoods')->alias('a')->join('store b', 'a.store_id=b.store_id', 'left')->where($where)->field('a.*,b.store_name')->order('a.goods_id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
foreach ($goodsList as $k => $v) {
$res = M('goods')->where(['sku' => $v['sku'], 'is_enable' => 1])->find();
if (!empty($res)) {
$goodsList[$k]['url'] = 'href="/Mobile/Goods/goodsInfo/stoid/' . $res['store_id'] . '/id/' . $res['goods_id'] . '.html" target="_blank"';
} else {
$goodsList[$k]['url'] = 'href="javascript:void(0);"';
}
}
$this->assign('goodsList', $goodsList);
$this->assign('page', $show);// 赋值分页输出
$this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
$oldurl = U('Manager/mztk/mztklist', array(
"isedit" => $isedit,
"key_word" => $key_word,
"pagenum" => $pagenum,
"p" => $cur_page,
));
$this->assign('oldurl', urlencode($oldurl));
$this->assign('key_word', $key_word);
$this->assign('isedit', $isedit);
$this->assign('pagenum', $pagenum);
$this->assign('cur_page', $cur_page);
return $this->fetch();
}
// 图库编辑
public function mztk_edit()
{
$oldurl = I('oldurl/s');
$sku = I('sku/s');
$id = I('bar_id/s');
$this->assign('sku', $sku);
$this->assign('bar_id', $id);
$this->assign('oldurl', $oldurl);
$this->assign('pagenum', 10);
return $this->fetch();
}
// 图库编辑数据
public function ajaxmztkedit()
{
$sku = I('sku/s');
$key_word = I('key_word') ? trim(I('key_word')) : ''; // 关键词搜索
$cur_page = 1;//当前页数
if ((int)I('p/s') > 0) {
$cur_page = I('p/s');
}
$pagenum = 10;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$where = " a.sku = '$sku'"; // 搜索条件
if ($key_word) {
$where = "$where and (a.goods_name like '%$key_word%' or a.goods_sn like '%$key_word%')";
}
$count = M('goods')->alias('a')->where($where)->count();
$Page = new AjaxPage($count, $pagenum);
$show = $Page->show();
$goodsList = M('goods')->alias('a')->join('store s', 'a.store_id=s.store_id')->where($where)->field('a.*,s.store_name')->limit($Page->firstRow . ',' . $Page->listRows)->select();
foreach ($goodsList as $k => $v) {
$goodsList[$k]['url'] = 'href="/Mobile/Goods/goodsInfo/stoid/' . $v['store_id'] . '/id/' . $v['goods_id'] . '.html" target="_blank"';
}
$this->assign('goodsList', $goodsList);
$this->assign('page', $show);// 赋值分页输出
// $this->assign('pager', $Page);
$this->assign('pagenum', $pagenum);
$this->assign('key_word', $key_word);
return $this->fetch();
}
// 更改状态
public function change_enable()
{
$id = I('id');
$ed_id = I('ed_id', '');
$store=I('store');
$html = I('html');
$name = M('admin')->where('admin_id', getAdminId())->field('ERPName')->find()['ERPName'];
$newgoodsinfo=M('goods')->where('goods_id', $id)->find();
if ($newgoodsinfo)
{
$data['original_img'] = $newgoodsinfo['original_img'];
}
$bar_id = I('bar_id');
$data['goods_content'] = $html;
$data['isedit'] = 1;
$data['store_id'] = $store;
$data['edit_man'] = $name;
$data['edit_time'] = time();
$data['edit_ip'] = getIP();
M('goods')->where('goods_id', $id)->update(['is_enable' => 1]);
M('barcodegoods')->where('goods_id', $bar_id)->update($data);
if (!empty($ed_id)) {
M('goods')->where('goods_id', $ed_id)->update(['is_enable' => 0]);
}
return json(['msg' => '操作成功']);
}
// 删除图库
public function delmztk()
{
$id = trim(I('id'));
M('barcodegoods')->where('goods_id', $id)->delete();
M('barcodegoods_images')->where('goods_id', $id)->delete();
return json(['msg' => '操作成功']);
}
}