123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- namespace factory\Lib;
- use Dever;
- class Manage
- {
-
- public function infoUpdate($id, $name, $data)
- {
- $update = array();
- $area = Dever::param('area', $data);
- if ($area) {
- $temp = is_string($area) ? explode(',', $area) : $area;
- $update['province'] = $temp[0];
- $update['city'] = $temp[1];
- }
- $map = Dever::param('map', $data);
- if ($map) {
- $temp = is_string($map) ? explode(',', $map) : $map;
- $update['lng'] = $temp[1];
- $update['lat'] = $temp[2];
- }
- if (isset($update) && $update) {
- $update['where_id'] = $id;
- Dever::db('factory/info')->update($update);
- }
- }
-
- public function goodsUpdate($id, $name, $data)
- {
- $update = array();
- $goods_id = Dever::param('goods_id', $data);
- if ($goods_id) {
- $info = Dever::db('goods/info')->find($goods_id);
- $update['price_type'] = $info['price_type'];
- }
- if (isset($update) && $update) {
- $update['where_id'] = $id;
- Dever::db('factory/goods')->update($update);
- }
- }
- public function skuConfig()
- {
- $data['action'] = Dever::url('factory/lib/manage.skuUp');
- $data['info_id'] = Dever::input('search_option_factory_goods_id');
- return $data;
- }
- public function skuUp_api()
- {
- $factory_goods_id = Dever::input('info_id');
- $key = Dever::input('key');
- $c_price = Dever::input('c_price');
- $factory_goods = Dever::db('factory/goods')->one($factory_goods_id);
- if ($key) {
- foreach ($key as $k => $v) {
- if (isset($c_price[$k]) && $c_price[$k]) {
- $info = Dever::db('goods/info_sku')->one(array('key' => $v));
- $data = array();
- $data['factory_id'] = $factory_goods['factory_id'];
- $data['goods_id'] = $factory_goods['goods_id'];
- $data['factory_goods_id'] = $factory_goods_id;
- $data['sku_id'] = $info['id'];
- $factory_info = Dever::db('factory/goods_sku')->one($data);
- $data['c_price'] = $c_price[$k];
- if (!$factory_info) {
- Dever::db('factory/goods_sku')->insert($data);
- } else {
- $data['where_id'] = $info['id'];
- Dever::db('factory/goods_sku')->update($data);
- }
- }
- }
- }
- Dever::out('yes');
- }
- public function skuInput()
- {
- $id = Dever::input('search_option_factory_goods_id');
- $factory_goods = Dever::db('factory/goods')->one($id);
- $sku = Dever::db('goods/info_sku')->getData(array('info_id' => $factory_goods['goods_id']));
- $sku_num = Dever::db('factory/goods_sku')->getData(array('factory_goods_id' => $id));
- $info = Dever::db('goods/info')->one($factory_goods['goods_id']);
- $info = \Goods\Lib\Info::init(-1)->info($info, 'list_reorder');
- $html = '请先选择属性';
- if ($info['sell_attr']) {
- $head = '<thead><tr>';
- $body = '<tbody>';
- $option = array();
- foreach ($info['sell_attr'] as $k => $v) {
- $head .= '<th>'.$v['name'].'</th>';
- if (isset($v['option_sku'])) {
- $option[$k] = $v['option_sku'];
- }
- }
- $head .= '<th>出厂价</th>';
- $head .= '</tr></thead>';
- if ($option) {
- $option = Dever::cartesian($option);
- foreach ($option as $k => $v) {
- $body .= '<tr data-row="' .($k+1). '">';
- $key = $id = array();
- foreach ($v['name'] as $k1 => $v1) {
- $rows = 1;
- $body .= '<td width="50" rowspan="'.$rows.'">'.$v1.'</td>';
- $id[] = array
- (
- 'id' => $v['id'][$k1],
- 'attr_id' => $v['info_id'][$k1],
- );
- $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
- }
- $key = implode('_', $key);
- $c_price = '';
- if (isset($sku[$key]) && isset($sku_num[$sku[$key]['id']])) {
- $c_price = $sku_num[$sku[$key]['id']]['c_price'];
- }
- $body .= '<td width="30"><input type="text" class="layui-input" name="c_price['.$k.']" value="'.$c_price.'"/></td>';
- $body .= '<input type="hidden" name="key['.$k.']" value="'.$key.'"/>';
- $body .= '</tr>';
- }
- }
- $body .= '</tbody>';
-
- $html = $head . $body;
- }
- return $html;
- }
- }
|