123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace Scm_servicer\Lib;
- use Dever;
- class Manage
- {
- public function __construct()
- {
- Dever::load('manage/auth.init');
- }
- public function getStore($id)
- {
- $table = array();
- $table['head'] = array('仓库名称', '仓库编码', '操作');
- $table['body'] = array();
- $data = Dever::db('scm_servicer/store')->select(array('servicer_id' => $id));
- if ($data) {
- $status = Dever::db('scm_servicer/store')->config['status'];
- foreach ($data as $k => $v) {
- $status_name = '';
- if ($v['status'] == 2) {
- $status_name = '(已禁用)';
- }
- $oper = '<a class="layui-btn" href="'.Dever::url('lib/set.home?role=servicer/store&id=' . $v['id'], 'scm_product').'">仓库明细</a>';
- $table['body'][$k][] = $v['name'] . $status_name;
- $table['body'][$k][] = $v['code'];
- $table['body'][$k][] = $oper;
- }
- }
- $body[''] = array
- (
- 'type' => 'table',
- 'content' => $table,
- );
- if ($table['body']) {
- return Dever::show('', $body);
- } else {
- return '暂无';
- }
- }
- public function getGoods($id)
- {
- $table = array();
- $table['head'] = array('名称', '单价', '数量', '状态');
- $table['body'] = array();
- $data = Dever::db('scm_servicer/in_order_goods')->select(array('order_id' => $id));
- if ($data) {
- $status = Dever::db('scm_servicer/in_order_goods')->config['status'];
- foreach ($data as $k => $v) {
- $status_name = Dever::status($status, $v['status']);
- $table['body'][$k][] = $v['goods'];
- $table['body'][$k][] = $v['cash'];
- $table['body'][$k][] = $v['num'];
- $table['body'][$k][] = $status_name;
- }
- }
- $body[''] = array
- (
- 'type' => 'table',
- 'content' => $table,
- );
- if ($table['body']) {
- return Dever::show('', $body);
- } else {
- return '暂无';
- }
- }
- public function updateGoods($id, $name, $data)
- {
- $table = Dever::input('table');
- $goods = Dever::param('goods', $data);
- if ($goods) {
- $info = Dever::db('scm_servicer/' . $table . '_goods')->find($id);
- if ($info) {
- $order = Dever::db('scm_servicer/' . $table)->find($info['order_id']);
- $update['where_id'] = $info['order_id'];
- $update['order_num'] = $this->getOrderId($table);
- Dever::db('scm_servicer/' . $table)->update($update);
- $temp = explode('-', $goods);
- $update = array();
- $update['where_id'] = $id;
- $update['goods_id'] = $temp[0];
- $update['sku_id'] = $temp[1];
- $update['cash'] = $temp[2];
- Dever::db('scm_servicer/' . $table . '_goods')->update($update);
- Dever::config('base')->hook = false;
- }
- }
- }
- # 生成订单号
- public function getOrderId($table)
- {
- $first = ucfirst(substr($table, 0, 1));
- $where['order_num'] = Dever::order('C' . $first);
- $state = Dever::db('scm_servicer/' . $table)->one($where);
- if (!$state) {
- return $where['order_num'];
- } else {
- return $this->getOrderId($table);
- }
- }
- }
|