ソースを参照

更改价格,金额的处理方式,避免浮点数进度问题

huwhois 4 年 前
コミット
da36911fa5

+ 14 - 0
app/common.php

@ -1,2 +1,16 @@
1 1
<?php
2 2
// 应用公共文件
3
4
/**
5
 * 格式化金额 将分为单位的金额以元输出
6
 * @param $price
7
 * @return string
8
 */
9
function format_money($price)
10
{
11
    if (!is_numeric($price)) {
12
        $price = 0;
13
    }
14
15
    return number_format(bcdiv($price, 100, 2), 2);
16
}

+ 4 - 4
app/controller/Company.php

@ -38,7 +38,7 @@ class Company extends Base
38 38
    {
39 39
        if ($this->request->isPost()) {
40 40
            $param = $this->request->param();
41
            
41
42 42
            try {
43 43
                if ($param['id']) {
44 44
                    $company = $this->model->find(intval($param['id']));
@ -47,8 +47,8 @@ class Company extends Base
47 47
                    $company->create_time = time();
48 48
                }
49 49
                $company->name = $param['name'];
50
                $company->initial_balance = $param['initial_balance'];
51
                
50
                $company->initial_balance = intval(bcmul($param['initial_balance'], 100));
51
52 52
                $company->save();
53 53
            } catch (\Exception $e) {
54 54
                $this->error($e->getMessage());
@ -64,7 +64,7 @@ class Company extends Base
64 64
                $data = [
65 65
                    'id' => 0,
66 66
                    'name' => '',
67
                    'initial_balance' => 1,
67
                    'initial_balance' => 0,
68 68
                ];
69 69
            }
70 70
            return View::fetch('', [

+ 67 - 0
app/controller/Department.php

@ -0,0 +1,67 @@
1
<?php
2
namespace app\controller;
3
4
use think\App;
5
use think\facade\View;
6
use app\model\Department as DepartmentModel;
7
8
class Department extends Base
9
{
10
    protected $model;
11
12
    public function __construct(App $app)
13
    {
14
        parent::__construct($app);
15
        $this->model = new DepartmentModel();
16
    }
17
18
    public function index()
19
    {
20
        $list = $this->model->select();
21
22
        return View::fetch('',['list'=>$list]);
23
    }
24
25
    public function info($id)
26
    {
27
        $data = $this->model->find($id);
28
        
29
        if ($this->request->isAjax()) {
30
            return json(['code'=>2, 'data'=>$data]);
31
        }
32
    }
33
34
    public function save()
35
    {
36
        if ($this->request->isPost()) {
37
            $param = $this->request->param();
38
            
39
            try {
40
                if ($param['id']) {
41
                    $department = $this->model->find(intval($param['id']));
42
                } else {
43
                    $department = new DepartmentModel();
44
                    $department->create_time = time();
45
                }
46
                $department->name = $param['name'];
47
                
48
                $department->save();
49
            } catch (\Exception $e) {
50
                    return json(['code'=>0, 'msg'=>$e->getMessage()]);
51
            }
52
53
            return json(['code'=>2]);
54
        }
55
    }
56
57
    public function delete($id)
58
    {
59
        if ($this->request->isPost()) {
60
            if ($this->model->destroy($id)) {
61
                return json(['code'=>2]);
62
            } else {
63
                return json(['code'=>0]);
64
            }
65
        }
66
    }
67
}

+ 17 - 7
app/controller/Goods.php

@ -16,13 +16,19 @@ class Goods extends Base
16 16
        $this->model = new GoodsModel();
17 17
    }
18 18
19
    public function index($key="")
19
    public function index($cid=0, $key="")
20 20
    {
21 21
        $map = [];
22 22
        if ($key) {
23 23
            $map[] = ['name', 'LIKE', '%'.$key.'%'];
24 24
        }
25 25
26
        $category_name = '';
27
        if ($cid) {
28
            $map[] = ['category_id', '=', $cid];
29
            $category_name = CategoryModel::where('id', $cid)->value('name');
30
        }
31
        
26 32
        $limit = $this->request->cookie('limit') ? : 50;
27 33
28 34
        $list = $this->model->where($map)->paginate($limit);
@ -33,7 +39,9 @@ class Goods extends Base
33 39
            'list' => $list,
34 40
            'key' => $key,
35 41
            'page' => $page,
36
            'limit' => $limit
42
            'limit' => $limit,
43
            'cid' => $cid,
44
            'category_name' => $category_name
37 45
        ]);
38 46
    }
39 47
@ -52,7 +60,7 @@ class Goods extends Base
52 60
                    $seller->create_time = time();
53 61
                }
54 62
                $seller->name = $param['name'];
55
                $seller->price = $param['price'];
63
                $seller->price = intval(bcmul($param['price'], 100));
56 64
                $seller->category_id = $param['category_id'];
57 65
                $seller->category_name = $categories[$param['category_id']];
58 66
                
@ -85,10 +93,12 @@ class Goods extends Base
85 93
86 94
    public function delete($id)
87 95
    {
88
        if ($this->model->destroy($id)) {
89
            return json(['code'=>2]);
90
        } else {
91
            return json(['code'=>0]);
96
        if ($this->request->isPost()){
97
            if ($this->model->destroy($id)) {
98
                return json(['code'=>2]);
99
            } else {
100
                return json(['code'=>0]);
101
            }
92 102
        }
93 103
    }
94 104
}

+ 25 - 34
app/controller/GoodsCategory.php

@ -3,7 +3,7 @@ namespace app\controller;
3 3
4 4
use think\App;
5 5
use think\facade\View;
6
use app\model\Seller as SellerModel;
6
use app\model\GoodsCategory as CategoryModel;
7 7
use app\model\Department as DepartmentModel;
8 8
9 9
class GoodsCategory extends Base
@ -13,7 +13,7 @@ class GoodsCategory extends Base
13 13
    public function __construct(App $app)
14 14
    {
15 15
        parent::__construct($app);
16
        $this->model = new SellerModel();
16
        $this->model = new CategoryModel();
17 17
    }
18 18
19 19
    public function index()
@ -23,55 +23,46 @@ class GoodsCategory extends Base
23 23
        return View::fetch('',['list'=>$list]);
24 24
    }
25 25
26
    public function info($id)
27
    {
28
        $data = $this->model->find($id);
29
        
30
        if ($this->request->isAjax()) {
31
            return json(['code'=>2, 'data'=>$data]);
32
        }
33
    }
34
26 35
    public function save()
27 36
    {
28
        $departmentModel = new DepartmentModel();
29
        $departments = $departmentModel->column('name', 'id');
30 37
        if ($this->request->isPost()) {
31 38
            $param = $this->request->param();
32
            
39
33 40
            try {
34 41
                if ($param['id']) {
35
                    $seller = $this->model->find(intval($param['id']));
42
                    $goodsCategory = $this->model->find(intval($param['id']));
36 43
                } else {
37
                    $seller = new SellerModel();
38
                    $seller->create_time = time();
44
                    $goodsCategory = new CategoryModel();
45
                    $goodsCategory->create_time = time();
39 46
                }
40
                $seller->name = $param['name'];
41
                $seller->department_id = $param['department_id'];
42
                $seller->department_name = $departments[$param['department_id']];
47
                $goodsCategory->name = $param['name'];
43 48
                
44
                $seller->save();
49
                $goodsCategory->save();
45 50
            } catch (\Exception $e) {
46
                $this->error($e->getMessage());
51
                    return json(['code'=>0, 'msg'=>$e->getMessage()]);
47 52
            }
48 53
49
            $this->success('操作成功', 'seller/index');
50
        } else {
51
            $id = $this->request->has('id','route') ? intval($this->request->param('id')) : 0;
52
53
            if ($id) {
54
                $data = $this->model->find($id);
55
            } else {
56
                $data = [
57
                    'id' => 0,
58
                    'name' => '',
59
                    'department_id' => 1,
60
                ];
61
            }
62
            return View::fetch('', [
63
                'data' => $data,
64
                'departments' => $departments
65
            ]);
54
            return json(['code'=>2]);
66 55
        }
67 56
    }
68 57
69 58
    public function delete($id)
70 59
    {
71
        if ($this->model->destroy($id)) {
72
            return json(['code'=>2]);
73
        } else {
74
            return json(['code'=>0]);
60
        if ($this->request->isPost()) {
61
            if ($this->model->destroy($id)) {
62
                return json(['code'=>2]);
63
            } else {
64
                return json(['code'=>0]);
65
            }
75 66
        }
76 67
    }
77 68
}

+ 16 - 78
app/controller/Order.php

@ -49,24 +49,31 @@ class Order extends Base
49 49
            'query' => $this->request->param()
50 50
        ]);
51 51
        // 统计去除已取消合同
52
        $map[] = ['status', '<>', -1];
53
        $total_contract_money = $this->detailsModel->where($map)->sum('contract_money');
54
        $total_payment = $this->detailsModel->where($map)->sum('payment');
52
        // $map[] = ['status', '=', 0];
53
        // $total_contract_money = $this->detailsModel->where($map)->sum('contract_money');
54
        // $total_payment = $this->detailsModel->where($map)->sum('payment');
55 55
56 56
        $page = $list->render();
57 57
58
        // return View::fetch();
59
58 60
        return View::fetch('',[
59
            'year' => $year,
61
            // 'year' => $year,
60 62
            'list' => $list,
61 63
            'page' => $page,
62
            'key' => $key,
63
            'month' => $month,
64
            'limit' => $limit,
65
            'total_contract_money' => round($total_contract_money, 2),
66
            'total_payment' => round($total_payment, 2)
64
            // 'key' => $key,
65
            // 'month' => $month,
66
            // 'limit' => $limit,
67
            // 'total_contract_money' => round($total_contract_money, 2),
68
            // 'total_payment' => round($total_payment, 2)
67 69
        ]);
68 70
    }
69 71
72
    public function info($id=0)
73
    {
74
        
75
    }
76
70 77
    public function save($year=0)
71 78
    {
72 79
@ -132,73 +139,4 @@ class Order extends Base
132 139
            return json(['code'=>0]);
133 140
        }
134 141
    }
135
136
137
138
    public function item($order_id)
139
    {
140
        $list = $this->itemModel->where('order_id', $order_id)->select();
141
        $orderInfo = $this->model->field('id,no,contract_no,company_name,contract_time')->find($order_id);
142
        $year = date('Y', strtotime($orderInfo->contract_time));
143
144
        return View::fetch('',[
145
            'list' => $list,
146
            'order_id' => $order_id,
147
            'orderInfo' => $orderInfo,
148
            'year' => $year,
149
        ]);
150
    }
151
152
    public function itemInfo($id)
153
    {
154
        $data = $this->itemModel->find($id);
155
        if ($this->request->isAjax()) {
156
            return json(['code'=>2, 'data'=>$data]);
157
        }
158
    }
159
160
    public function itemSave()
161
    {
162
        if ($this->request->isAjax()) {
163
            $param = $this->request->param();
164
            // var_dump($param);
165
            // exit;
166
            try {
167
                if ($param['id']) {
168
                    $order = $this->itemModel->find(intval($param['id']));
169
                } else {
170
                    $order = new OrderItemModel();
171
                }
172
                $order->order_id = intval($param['order_id']);
173
                $order->goods_category = $param['goods_category'];
174
                $order->goods_name = $param['goods_name'];
175
                $order->goods_price = $param['goods_price'];
176
                $order->sales_amount = $param['sales_amount'];
177
                $order->sales_price = $param['sales_price'];
178
                $order->actual_amount = $param['actual_amount'];
179
                $order->actual_price = $param['actual_price'];
180
                $order->agency = $param['agency'];
181
                $order->fare = $param['fare'];
182
                $order->type = intval($param['type']);
183
                $order->remark = $param['remark'];
184
                
185
                $order->save();
186
            } catch (\Exception $e) {
187
                // $this->error($e->getMessage());
188
                return json(['code'=>0, 'msg'=>$e->getMessage()]);
189
            }
190
            return json(['code'=>2]);
191
        }
192
    }
193
194
    public function itemDelete($id)
195
    {
196
        if ($this->request->isPost()) {
197
            if ($this->itemModel->destroy($id)) {
198
                return json(['code'=>2]);
199
            } else {
200
                return json(['code'=>0]);
201
            }
202
        }
203
    }
204 142
}

+ 93 - 0
app/controller/OrderItem.php

@ -0,0 +1,93 @@
1
<?php
2
namespace app\controller;
3
4
use think\App;
5
use think\facade\View;
6
use app\model\Order as OrderModel;
7
use app\model\OrderItem as OrderItemModel;
8
use app\model\OrderDetails as OrderDetailsModel;
9
use app\model\Department as DepartmentModel;
10
use think\facade\Db;
11
12
class OrderItem extends Base
13
{
14
    protected $model;
15
    protected $orderModel;
16
    protected $detailsModel;
17
18
    public function __construct(App $app)
19
    {
20
        parent::__construct($app);
21
        $this->model = new OrderItemModel();
22
        $this->orderModel = new OrderModel();
23
        $this->detailsModel = new OrderDetailsModel();
24
    }
25
26
    public function index($order_id)
27
    {
28
        $list = $this->model->where('order_id', $order_id)->select();
29
        $orderInfo = $this->detailsModel->field('id,no,contract_no,company_name,contract_time')->find($order_id);
30
        $year = date('Y', strtotime($orderInfo->contract_time));
31
32
        return View::fetch('',[
33
            'list' => $list,
34
            'order_id' => $order_id,
35
            'orderInfo' => $orderInfo,
36
            'year' => $year,
37
        ]);
38
    }
39
40
    
41
    public function info($id)
42
    {
43
        $data = $this->model->find($id);
44
        if ($this->request->isAjax()) {
45
            return json(['code'=>2, 'data'=>$data]);
46
        }
47
    }
48
49
    public function save()
50
    {
51
        if ($this->request->isAjax()) {
52
            $param = $this->request->param();
53
            // var_dump($param);
54
            // exit;
55
            try {
56
                if ($param['id']) {
57
                    $order = $this->model->find(intval($param['id']));
58
                } else {
59
                    $order = new OrderItemModel();
60
                }
61
                $order->order_id = intval($param['order_id']);
62
                $order->goods_category = $param['goods_category'];
63
                $order->goods_name = $param['goods_name'];
64
                $order->goods_price = $param['goods_price'];
65
                $order->sales_amount = $param['sales_amount'];
66
                $order->sales_price = $param['sales_price'];
67
                $order->actual_amount = $param['actual_amount'];
68
                $order->actual_price = $param['actual_price'];
69
                $order->agency = $param['agency'];
70
                $order->fare = $param['fare'];
71
                $order->type = intval($param['type']);
72
                $order->remark = $param['remark'];
73
                
74
                $order->save();
75
            } catch (\Exception $e) {
76
                // $this->error($e->getMessage());
77
                return json(['code'=>0, 'msg'=>$e->getMessage()]);
78
            }
79
            return json(['code'=>2]);
80
        }
81
    }
82
83
    public function delete($id)
84
    {
85
        if ($this->request->isPost()) {
86
            if ($this->model->destroy($id)) {
87
                return json(['code'=>2]);
88
            } else {
89
                return json(['code'=>0]);
90
            }
91
        }
92
    }
93
}

+ 7 - 3
app/controller/Seller.php

@ -16,11 +16,15 @@ class Seller extends Base
16 16
        $this->model = new SellerModel();
17 17
    }
18 18
19
    public function index()
19
    public function index($did=0)
20 20
    {
21
        $list = $this->model->select();
21
        if ($did) {
22
            $list = $this->model->where('department_id', $did)->select();
23
        } else {
24
            $list = $this->model->select();
25
        }
22 26
23
        return View::fetch('',['list'=>$list]);
27
        return View::fetch('',['list'=>$list, 'did'=>$did]);
24 28
    }
25 29
26 30
    public function save()

+ 7 - 0
app/model/Company.php

@ -3,4 +3,11 @@ namespace app\model;
3 3
4 4
class Company extends \think\Model
5 5
{
6
    protected $schema = [
7
        'id' => 'int',
8
        'name' => 'string',
9
        'initial_balance' => 'int',
10
        'current_balance' => 'int',
11
        'create_time' => 'int'
12
    ];
6 13
}

+ 5 - 0
app/model/Department.php

@ -3,4 +3,9 @@ namespace app\model;
3 3
4 4
class Department extends \think\Model
5 5
{
6
    protected $schema = [
7
        'id' => 'int',
8
        'name' => 'string',
9
        'create_time' => 'int'
10
    ];
6 11
}

+ 14 - 0
app/model/Goods.php

@ -1,7 +1,21 @@
1 1
<?php
2 2
namespace app\model;
3 3
use app\model\GoodsCategory;
4
use think\model\concern\SoftDelete;
4 5
5 6
class Goods extends \think\Model
6 7
{
8
    protected $schema = [
9
        'id' => 'int',
10
        'category_id' => 'int',
11
        'category_name' => 'string',
12
        'name' => 'string',
13
        'price' => 'int',   // 单位分
14
        'create_time' => 'int',
15
        'is_del' => 'int'
16
    ];
17
18
    use SoftDelete;
19
    protected $deleteTime = 'is_del';
20
    protected $defaultSoftDelete = 0;
7 21
}

+ 5 - 0
app/model/GoodsCategory.php

@ -3,4 +3,9 @@ namespace app\model;
3 3
4 4
class GoodsCategory extends \think\Model
5 5
{
6
    protected $schema = [
7
        'id' => 'int',
8
        'name' => 'string',
9
        'create_time' => 'int'
10
    ];
6 11
}

+ 3 - 0
app/model/Order.php

@ -3,4 +3,7 @@ namespace app\model;
3 3
4 4
class Order extends \think\Model
5 5
{
6
6 7
}
8
9
// select `o`.`id` AS `id`,`o`.`no` AS `no`,`o`.`contract_no` AS `contract_no`,(select sum((`oi`.`sales_amount` * `oi`.`sales_price`)) from `sale_order_item` `oi` where (`oi`.`order_id` = `o`.`id`)) AS `contract_money`,`o`.`contract_time` AS `contract_time`,`o`.`commany_id` AS `commany_id`,`o`.`company_name` AS `company_name`,`o`.`department_id` AS `department_id`,`o`.`department_name` AS `department_name`,`o`.`seller_id` AS `seller_id`,`o`.`seller_name` AS `seller_name`,`o`.`consignor` AS `consignor`,`o`.`fare` AS `fare`,`o`.`urgently` AS `urgently`,`o`.`waybill` AS `waybill`,`o`.`pay_type` AS `pay_type`,`o`.`pay_time` AS `pay_time`,`o`.`payment` AS `payment`,`o`.`uncollected` AS `uncollected`,`o`.`other_payment_date` AS `other_payment_date`,`o`.`other_payment_money` AS `other_payment_money`,`o`.`is_tax` AS `is_tax`,`o`.`tax_time` AS `tax_time`,`o`.`tax_money` AS `tax_money`,`o`.`other__tax_date` AS `other__tax_date`,`o`.`other_money` AS `other_money`,`o`.`tax_no` AS `tax_no`,`o`.`remark` AS `remark`,`o`.`is_commission` AS `is_commission`,`o`.`create_time` AS `create_time`,`o`.`agency` AS `agency`,month(`o`.`contract_time`) AS `month`,year(`o`.`contract_time`) AS `year`,`o`.`status` AS `status` from `sale_order` `o`

+ 21 - 0
app/model/OrderItem.php

@ -3,4 +3,25 @@ namespace app\model;
3 3
4 4
class OrderItem extends \think\Model
5 5
{
6
    protected $schema = [
7
        'id' => 'int',
8
        'order_id' => 'int',
9
        'goods_category_id' => 'int',
10
        'goods_category_name' => 'string',
11
        'goods_id' => 'int',
12
        'goods_name' => 'string',
13
        'goods_price' => 'int',
14
        'sales_amount' => 'string',
15
        'sales_price' => 'int',   // 单位分
16
        'sales_money' => 'int',   // 单位分
17
        'actual_amount' => 'string',
18
        'actual_price' => 'int',   // 单位分
19
        'actual_money' => 'int',   // 单位分
20
        'status' => 'int',
21
        'remark' => 'string',
22
        'fare' => 'int',  // 单位分
23
        'agency' => 'int',  // 单位分
24
        'type' => 'int',
25
        'create_time' => 'int'
26
    ];
6 27
}

+ 7 - 0
app/model/Seller.php

@ -3,4 +3,11 @@ namespace app\model;
3 3
4 4
class Seller extends \think\Model
5 5
{
6
    protected $schema = [
7
        'id' => 'int',
8
        'name' => 'string',
9
        'department_id' => 'int',
10
        'department_name' => 'string',
11
        'create_time' => 'int'
12
    ];
6 13
}

+ 14 - 9
route/app.php

@ -18,14 +18,19 @@ Route::pattern([
18 18
    'order_id'   => '\d+',
19 19
]);
20 20
21
Route::get('seller/index', 'seller/index');
22
Route::rule('seller/save/[:id]', 'seller/save');
21
Route::get('company/index/[:key]', 'company/index');
22
Route::rule('company/save/:id', 'company/save');
23
Route::get('seller/index/[:did]', 'seller/index')->pattern(['did'=>'\d+']);
24
Route::rule('seller/save/:id', 'seller/save');
25
Route::get('department/index', 'department/index');
26
Route::get('department/info', 'department/info');
27
Route::post('department/save', 'department/save');
28
Route::get('goods_category/index', 'goods_category/index');
29
Route::get('goods_category/info', 'goods_category/info');
30
Route::post('goods_category/save', 'goods_category/save');
31
Route::get('goods/index/[:cid]', 'goods/index')->pattern(['cid'=>'\d+']);
32
Route::rule('goods/save/:id', 'goods/save');
23 33
Route::get('order/index', 'order/index');
24 34
Route::get('order/lists/:year', 'order/lists');
25
Route::rule('order/item/:order_id', 'order/item');
26
Route::get('order/save/:year/:id', 'order/save');
27
Route::get('order/save/:year/:id', 'order/save');
28
Route::get('goods/save/:id', 'goods/save');
29
30
Route::get('company/index/[:key]', 'company/index');
31
Route::rule('company/save/[:id]', 'company/save');
35
Route::rule('order/save/:id', 'order/save');
36
Route::get('order_item/index/:order_id', 'order_item/index')->pattern(['order_id'=>'\d+']);

+ 3 - 3
view/company/index.html

@ -53,15 +53,15 @@
53 53
                </tr>
54 54
            </thead>
55 55
            <tbody>
56
                        {foreach $list as $value}
56
                {foreach $list as $value}
57 57
                <tr>
58 58
                    <td>
59 59
                        <input type="checkbox" value="{$value.id}" name="checkbox[]">
60 60
                    </td>
61 61
                    <td class="text-center">{$value.id}</td>
62 62
                    <td class="text-center">{$value['name']}</td>
63
                    <td class="text-center">{$value['initial_balance']}</td>
64
                    <td class="text-center">{$value['current_balance']}</td>
63
                    <td class="text-center">{:number_format(bcdiv($value['initial_balance'],100,2),2)}</td>
64
                    <td class="text-center">{:number_format(bcdiv($value['current_balance'],100,2),2)}</td>
65 65
                    <td class="text-center">
66 66
                        <a href="/company/save/{$value['id']}">修改</a>
67 67
                        <a href="javascript:void(0);" class="ml-10" onClick="del('{$value.id}', this)">删除</a> 

+ 1 - 1
view/company/save.html

@ -36,7 +36,7 @@
36 36
            </div>
37 37
            <div class="col-md-4">
38 38
                <div class="form-group">
39
                    <input type="number" class="form-control" name="name" id="name" value="{$data.initial_balance}" placeholder="初期余额">
39
                    <input type="number" class="form-control" name="initial_balance" id="initial_balance" value="{:number_format(bcdiv($data['initial_balance'],100,2),2)}" placeholder="初期余额">
40 40
                </div>
41 41
            </div>
42 42
        </div>

+ 140 - 0
view/department/index.html

@ -0,0 +1,140 @@
1
{layout name="layout" /}
2
3
<nav class="breadcrumb">
4
    <span><a href="/">首页</a></span>
5
    <span>&gt;</span>
6
    <span><a href="/seller/index">销售员</a></span>
7
    <span>&gt;</span>
8
    <span><a href="javascript:void(0);">部门管理</a></span>
9
</nav>
10
11
<div class="content">
12
    <div class="row" style="margin: 0;">
13
        <div class="col-md-3 btn-top-box">
14
            <!-- <a href="javascript:;" class="btn btn-danger radius" onClick="del_all()">批量删除</a> -->
15
            <a href="javascript:save(0);" class="btn btn-success radius" >新增</a>
16
            <a href="/seller/index" class="btn btn-default radius" >返回</a>
17
        </div>
18
    </div>
19
    <div class="col-md-8 mt-20">
20
        <table class=" table table-hover table-bordered">
21
            <thead>
22
                <tr>
23
                    <th width="25">
24
                        <input type="checkbox" value="" name="">
25
                    </th>
26
                    <th class="text-center">id</th>
27
                    <th class="text-center">部门名称</th>
28
                    <th class="text-center">操作</th>
29
                </tr>
30
            </thead>
31
            <tbody>
32
                {foreach $list as $value}
33
                <tr>
34
                    <td>
35
                        <input type="checkbox" value="{$value.id}" name="checkbox[]">
36
                    </td>
37
                    <td class="text-center">{$value.id}</td>
38
                    <td class="text-center">{$value.name}</td>
39
                    <td class="text-center td-manager">
40
                        <a href="javascript:void(0);" onClick="save('{$value.id}')">修改</a>
41
                        <a href="javascript:void(0);" onClick="del('{$value.id}', this)" class="ml-10">删除</a>
42
                    </td>
43
                </tr>
44
                {/foreach}
45
            </tbody>
46
        </table>
47
    </div>
48
</div>
49
50
<div class="modal" tabindex="-1" role="dialog" data-backdrop="false" id="myModal" aria-labelledby="myModalLabel">
51
    <div class="modal-dialog" role="document">
52
      <div class="modal-content">
53
        <div class="modal-header">
54
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
55
          <h4 class="modal-title">销售部门</h4>
56
        </div>
57
        <div class="modal-body">
58
            <form role="form" id="form-department">
59
                <input type="hidden" name="id" id="id" value="0">
60
                <div class="row">
61
                    <div class="col-md-4">
62
                        <div class="form-group">
63
                            <label for="name">名称</label>
64
                        </div>
65
                    </div>
66
                    <div class="col-md-4">
67
                        <div class="form-group">
68
                            <input type="text" class="form-control" name="name" id="name" placeholder="部门名称">
69
                        </div>
70
                    </div>
71
                </div>
72
            </form>
73
        </div>
74
        <div class="modal-footer">
75
          <button type="button" class="btn btn-default"  onclick="closeModel()">Close</button>
76
          <button type="button" class="btn btn-success" onclick="doSave()">Save</button>
77
        </div>
78
      </div><!-- /.modal-content -->
79
    </div><!-- /.modal-dialog -->
80
  </div><!-- /.modal -->
81
82
83
84
<!--请在下方写此页面业务相关的脚本-->
85
<script type="text/javascript">
86
     function save(id) {
87
        // console.log(id);
88
        if (id) {
89
            $.get('/department/info', {
90
                'id': id,
91
            }, function(res) {
92
                if (res.code == 2) {
93
                    var data = res.data;
94
                    $("#id").val(data.id);
95
                    $("#name").val(data.name);
96
                }
97
            }, 'json');
98
        } else {
99
            $("#id").val(0);
100
            $("#name").val('');
101
        }
102
        $('#myModal').modal('show');
103
    }
104
105
    function closeModel() {
106
        $("#form-department")[0].reset();
107
        $('#myModal').modal('hide');
108
    }
109
110
    function doSave() {
111
        var data = $("#form-department").serializeArray();
112
        $.post('/department/save', data, function(res) {
113
            if (res.code == 2) {
114
                alert('保存成功');
115
                $("#form-department")[0].reset();
116
                $('#myModal').modal('hide');
117
                window.location.reload();
118
            } else {
119
                alert(res.msg);
120
            }
121
            return false;
122
        }, 'json');
123
        return false;
124
    }
125
126
    function del(id, obj) {
127
        $.post('/department/delete', {
128
            'id': id
129
        }, function (res) {
130
            if (res.code == 2) {
131
                $(obj).parents("tr").remove();
132
                alert('删除成功!');
133
            } else {
134
                alert('删除失败, 请稍后重试.');
135
                return false;
136
            }
137
        }, 'json');
138
    }
139
</script>
140
<!--请在上方写此页面业务相关的脚本-->

+ 26 - 11
view/goods/index.html

@ -3,7 +3,7 @@
3 3
<nav class="breadcrumb">
4 4
    <span><a href="/">首页</a></span>
5 5
    <span>&gt;</span>
6
    <span><a href="javascript:void(0);">产品管理</a></span>
6
    <span><a href="javascript:void(0);">产品管理</a></span>   
7 7
</nav>
8 8
9 9
<div class="content">
@ -11,8 +11,11 @@
11 11
        <div class="col-md-2 btn-top-box">
12 12
            <!-- <a href="javascript:;" class="btn btn-danger radius" onClick="del_all()">批量删除</a> -->
13 13
            <a href="/goods/save/0" class="btn btn-success radius">新增</a>
14
            {notempty name="category_name"}
15
            <a href="/goods/index" class="btn btn-default radius">返回</a>
16
            {/notempty}
14 17
        </div>
15
        <div class="col-md-6 btn-top-box">
18
        <div class="col-md-5 btn-top-box">
16 19
            <form action="/goods/index" method="get">
17 20
                <div class="col-md-4">
18 21
                    <input type="text" class="form-control" name="key" id="key" value="{$key}"
@ -28,18 +31,30 @@
28 31
                </div>
29 32
            </form>
30 33
        </div>
31
        <div class="col-md-3">
32
            <span>每页行数:</span>
33
            <select name="limit" id="limit" onchange="changLimit()">
34
                {for start="10" end="101" step="10"}
35
                <option value="{$i}" {eq name="limit" value="$i"}selected{/eq}>{$i}</option>
36
                {/for}
37
            </select>
34
        <div class="col-md-2 btn-top-box">
35
            <a href="/goods_category/index" class="btn btn-primary radius">类别管理</a>
38 36
        </div>
39 37
    </div>
40 38
    <div class="col-md-10 mt-20">
41 39
        <table class=" table table-hover table-bordered">
42 40
            <thead>
41
                <tr class="text-center bg-info">
42
                    <td class="text-left" colspan="4">
43
                        {empty name="category_name"}
44
                        全部产品: {$list->total()}
45
                        {else /}
46
                        {$category_name}: {$list->total()}
47
                        {/empty}
48
                    </td>
49
                    <td colspan="2">
50
                        <span>每页行数:</span>
51
                        <select name="limit" id="limit" onchange="changLimit()">
52
                            {for start="10" end="101" step="10"}
53
                            <option value="{$i}" {eq name="limit" value="$i"}selected{/eq}>{$i}</option>
54
                            {/for}
55
                        </select>
56
                    </td>
57
                </tr>
43 58
                <tr>
44 59
                    <th width="25">
45 60
                        <input type="checkbox" value="" name="">
@ -58,9 +73,9 @@
58 73
                        <input type="checkbox" value="{$value.id}" name="checkbox[]">
59 74
                    </td>
60 75
                    <td class="text-center">{$value.id}</td>
61
                    <td class="text-center">{$value.category_name}</td>
76
                    <td class="text-center"><a href="/goods/index/{$value['category_id']}">{$value.category_name}</a></td>
62 77
                    <td class="text-center">{$value.name}</td>
63
                    <td class="text-center">{$value.price}</td>
78
                    <td class="text-center">{:number_format(bcdiv($value['price'],100,2),2)}</td>
64 79
                    <td class="text-center td-manager">
65 80
                        <a href="/goods/save/{$value['id']}">修改</a>
66 81
                        <a href="javascript:void(0);" class="ml-10" onClick="del('{$value.id}', this)">删除</a>

+ 1 - 1
view/goods/save.html

@ -36,7 +36,7 @@
36 36
            </div>
37 37
            <div class="col-md-4">
38 38
                <div class="form-group">
39
                    <input type="number" class="form-control" name="price" id="price" value="{$data.price}" placeholder="价格">
39
                    <input type="number" class="form-control" name="price" id="price" value="{:number_format(bcdiv($data['price'],100,2),2)}" placeholder="价格">
40 40
                </div>
41 41
            </div>
42 42
            <span style='color:red;' id="error_msg"></span>

+ 139 - 0
view/goods_category/index.html

@ -0,0 +1,139 @@
1
{layout name="layout" /}
2
3
<nav class="breadcrumb">
4
    <span><a href="/">首页</a></span>
5
    <span>&gt;</span>
6
    <span><a href="/goods/index">产品管理</a></span>
7
    <span>&gt;</span>
8
    <span><a href="javascript:void(0);">产品类别管理</a></span>
9
</nav>
10
11
<div class="content">
12
    <div class="row" style="margin: 0;">
13
        <div class="col-md-3 btn-top-box">
14
            <!-- <a href="javascript:;" class="btn btn-danger radius" onClick="del_all()">批量删除</a> -->
15
            <a href="javascript:save(0);" class="btn btn-success radius" >新增</a>
16
            <a href="/goods/index" class="btn btn-default radius" >返回</a>
17
        </div>
18
    </div>
19
    <div class="col-md-8 mt-20">
20
        <table class=" table table-hover table-bordered">
21
            <thead>
22
                <tr>
23
                    <th width="25">
24
                        <input type="checkbox" value="" name="">
25
                    </th>
26
                    <th class="text-center">id</th>
27
                    <th class="text-center">类别名称</th>
28
                    <th class="text-center">操作</th>
29
                </tr>
30
            </thead>
31
            <tbody>
32
                {foreach $list as $value}
33
                <tr>
34
                    <td>
35
                        <input type="checkbox" value="{$value.id}" name="checkbox[]">
36
                    </td>
37
                    <td class="text-center">{$value.id}</td>
38
                    <td class="text-center">{$value.name}</td>
39
                    <td class="text-center td-manager">
40
                        <a href="javascript:void(0);" onClick="save('{$value.id}')">修改</a>
41
                        <a href="javascript:void(0);" onClick="del('{$value.id}', this)" class="ml-10">删除</a>
42
                    </td>
43
                </tr>
44
                {/foreach}
45
            </tbody>
46
        </table>
47
    </div>
48
</div>
49
50
<div class="modal" tabindex="-1" role="dialog" data-backdrop="false" id="myModal" aria-labelledby="myModalLabel">
51
    <div class="modal-dialog" role="document">
52
      <div class="modal-content">
53
        <div class="modal-header">
54
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
55
          <h4 class="modal-title">产品类别</h4>
56
        </div>
57
        <div class="modal-body">
58
            <form role="form" id="form-goods-category">
59
                <input type="hidden" name="id" id="id" value="0">
60
                <div class="row">
61
                    <div class="col-md-4">
62
                        <div class="form-group">
63
                            <label for="name">名称</label>
64
                        </div>
65
                    </div>
66
                    <div class="col-md-4">
67
                        <div class="form-group">
68
                            <input type="text" class="form-control" name="name" id="name" placeholder="产品类别">
69
                        </div>
70
                    </div>
71
                </div>
72
            </form>
73
        </div>
74
        <div class="modal-footer">
75
          <button type="button" class="btn btn-default"  onclick="closeModel()">Close</button>
76
          <button type="button" class="btn btn-success" onclick="doSave()">Save</button>
77
        </div>
78
      </div><!-- /.modal-content -->
79
    </div><!-- /.modal-dialog -->
80
  </div><!-- /.modal -->
81
82
83
84
<!--请在下方写此页面业务相关的脚本-->
85
<script type="text/javascript">
86
     function save(id) {
87
        if (id) {
88
            $.get('/department/info', {
89
                'id': id,
90
            }, function(res) {
91
                if (res.code == 2) {
92
                    var data = res.data;
93
                    $("#id").val(data.id);
94
                    $("#name").val(data.name);
95
                }
96
            }, 'json');
97
        } else {
98
            $("#id").val(0);
99
            $("#name").val('');
100
        }
101
        $('#myModal').modal('show');
102
    }
103
104
    function closeModel() {
105
        $("#form-goods-category")[0].reset();
106
        $('#myModal').modal('hide');
107
    }
108
109
    function doSave() {
110
        var data = $("#form-goods-category").serializeArray();
111
        $.post('/goods_category/save', data, function(res) {
112
            if (res.code == 2) {
113
                alert('保存成功');
114
                $("#form-goods-category")[0].reset();
115
                $('#myModal').modal('hide');
116
                window.location.reload();
117
            } else {
118
                alert(res.msg);
119
            }
120
            return false;
121
        }, 'json');
122
        return false;
123
    }
124
125
    function del(id, obj) {
126
        $.post('/goods_category/delete', {
127
            'id': id
128
        }, function (res) {
129
            if (res.code == 2) {
130
                $(obj).parents("tr").remove();
131
                alert('删除成功!');
132
            } else {
133
                alert('删除失败, 请稍后重试.');
134
                return false;
135
            }
136
        }, 'json');
137
    }
138
</script>
139
<!--请在上方写此页面业务相关的脚本-->

+ 0 - 1
view/layout.html

@ -32,7 +32,6 @@
32 32
    <aside class="aside">
33 33
        <div class="col-md-12 lin-height text_center"><a href="/order">销售订单</a></div>
34 34
        <div class="col-md-12 lin-height text_center"><a href="/commission">销售提成</a></div>
35
        <div class="col-md-12 lin-height text_center"><a href="/goods_category">产品类别管理</a></div>
36 35
        <div class="col-md-12 lin-height text_center"><a href="/goods">产品管理</a></div>
37 36
        <div class="col-md-12 lin-height text_center"><a href="/seller">销售员管理</a></div>
38 37
        <div class="col-md-12 lin-height text_center"><a href="/company">购货单位管理</a></div>

+ 15 - 15
view/order/lists.html

@ -5,17 +5,17 @@
5 5
    <span>&gt;</span>
6 6
    <span><a href="/order/index">销售订单</a></span>
7 7
    <span>&gt;</span>
8
    <span>{$year!=0?$year:"全部"} 年度</span>
8
    <span>{//$year!=0?$year:"全部"} 年度</span>
9 9
</nav>
10 10
11 11
<div class="content">
12 12
    <div class="row" style="margin: 10px 0;">
13 13
        <div class="col-md-2 col-xs-3 text-center">
14
            <a href="/order/save/{$year}/0" class="btn btn-success radius">新增</a>
14
            <a href="/order/save/{//$year}/0" class="btn btn-success radius">新增</a>
15 15
        </div>
16 16
        <div class="col-md-8">
17
            <form action="/order/lists/{$year}" method="get">
18
                {notempty name="year"}
17
            <form action="/order/lists/{//$year}" method="get">
18
                {//notempty name="year"}
19 19
                <label for="month" class="form-label col-md-2 text-right mt-5">
20 20
                    请选择月份 :
21 21
                </label>
@ -23,16 +23,16 @@
23 23
                    <select class="form-control input-sm" name="month" id="month">
24 24
                        {for start="0" end="13"}
25 25
                        {eq name="i" value="0"}
26
                        <option value="{$i}"{eq name="month" value="0"}selected{/eq}>全年</option>
26
                        <option value="{$i}"{//eq name="month" value="0"}selected{///eq}>全年</option>
27 27
                        {else/}
28
                        <option value="{$i}"{eq name="month" value="$i"}selected{/eq}>{$i}月</option>
28
                        <option value="{$i}"{//eq name="month" value="$i"}selected{///eq}>{$i}月</option>
29 29
                        {/eq}
30 30
                        {/for}
31 31
                    </select>
32 32
                </div>
33
                {/notempty}
33
                {///notempty}
34 34
                <div class="col-md-4">
35
                    <input type="text" class="form-control" name="key" id="key" value="{$key}"
35
                    <input type="text" class="form-control" name="key" id="key" value="{//$key}"
36 36
                        placeholder="请输入公司名称">
37 37
                </div>
38 38
                <div class="col-md-3" style="text-align:left;">
@ -40,7 +40,7 @@
40 40
                        <button type="submit" class="btn btn-success">搜索</button>
41 41
                    </div>
42 42
                    <div class="btn-group ">
43
                        <a href="/order/lists/{$year}" class="btn btn-danger ml-10">清除</a>
43
                        <a href="/order/lists/{//$year}" class="btn btn-danger ml-10">清除</a>
44 44
                    </div>
45 45
                </div>
46 46
            </form>
@ -52,13 +52,13 @@
52 52
                <tr class="text-center bg-info">
53 53
                    <td>统计</td>
54 54
                    <td colspan="11" class="text-left">
55
                        总销售金额 : ¥{$total_contract_money} | 总到款金额: ¥{$total_payment}
55
                        总销售金额 : ¥{//$total_contract_money} | 总到款金额: ¥{//$total_payment}
56 56
                    </td>
57 57
                    <td colspan="2">
58 58
                        <span>每页行数:</span>
59 59
                        <select name="limit" id="limit" onchange="changLimit()">
60 60
                            {for start="10" end="101" step="10"}
61
                            <option value="{$i}" {eq name="limit" value="$i"}selected{/eq}>{$i}</option>
61
                            <option value="{$i}" {//eq name="limit" value="$i"}selected{///eq}>{$i}</option>
62 62
                            {/for}
63 63
                        </select>
64 64
                    </td>
@ -87,18 +87,18 @@
87 87
                    <td>{$value.month}</td>
88 88
                    <td class="text-left">{$value.company_name}</td>
89 89
                    <td class="text-left"><a href="/order/item/{$value.id}">{$value.contract_no}</a></td>
90
                    <td>{$value.contract_money}</td>
90
                    <td>{//$value.contract_money}</td>
91 91
                    <td>{$value.contract_time}</td>
92 92
                    <td>{$value.fare}</td>
93 93
                    <td>{$value.agency}</td>
94 94
                    <td>{$value.seller_name}</td>
95 95
                    <td>{$value.payment}</td>
96
                    <td>{$value.contract_money-$value.payment|round=2}</td>
96
                    <td>{//$value.contract_money-$value.payment|round=2}</td>
97 97
                    <td>--</td>
98 98
                    <td>{$value.is_commission}</td>
99 99
                    <td class="td-manager">
100
                        <a href="/order/item/{$value.id}">产品明细</a>
101
                        <a href="/order/save/{$year}/{$value.id}" onclick="edit()">修改</a>
100
                        <a href="/order_item/index/{$value.id}">产品明细</a>
101
                        <a href="/order/save/{$value.id}" onclick="edit()">修改</a>
102 102
                        <a href="javascript:void(0);" onclick="del('{$value.id}', this)">删除</a>
103 103
                    </td>
104 104
                </tr>

+ 15 - 11
view/order/item.html

@ -15,11 +15,11 @@
15 15
            <a href="javascript:save(0);" class="btn btn-primary radius">新增明细</a>
16 16
        </div>
17 17
    </div>
18
    <div class="col-md-10">
18
    <div class="col-md-11">
19 19
        <table class="table table-hover table-bordered table-condensed">
20 20
            <thead>
21 21
                <tr>
22
                    <th class="bg-info" colspan="14" style="text-align: left;">
22
                    <th class="bg-info" colspan="16" style="text-align: left;">
23 23
                        购货单位: {$orderInfo.company_name} | 合同号: {$orderInfo.contract_no} | 时间: {$orderInfo.contract_time}
24 24
                    </th>
25 25
                </tr>
@ -27,15 +27,17 @@
27 27
                    <th>id</th>
28 28
                    <th>种类</th>
29 29
                    <th>产品名称</th>
30
                    <th>产品公司价</th>
30
                    <th>产品价格(公司价)</th>
31 31
                    <th>销售数量(单位KG/台)</th>
32 32
                    <th>销售价格</th>
33 33
                    <th>合同金额</th>
34
                    <th>实际发货</th>
35
                    <th>实际成交价格</th>
34
                    <th>实际发货</th>
35
                    <th>成交价格</th>
36
                    <th>成交金额</th>
36 37
                    <th>运费分摊</th>
37 38
                    <th>代理费分摊</th>
38 39
                    <th>备注</th>
40
                    <th>状态</th>
39 41
                    <th>提成类型</th>
40 42
                    <th>操作</th>
41 43
                </tr>
@ -47,15 +49,17 @@
47 49
                    <td>{$value.id}</td>
48 50
                    <td>{$value.goods_category}</td>
49 51
                    <td>{$value.goods_name}</td>
50
                    <td>{$value.goods_price}</td>
52
                    <td>{$value.goods_price|format_money}</td>
51 53
                    <td>{$value.sales_amount}</td>
52
                    <td>{$value.sales_price}</td>
53
                    <td>{$value.sales_price * $value.sales_amount|round=2}</td>
54
                    <td>{$value.sales_price|format_money}</td>
55
                    <td>{$value.sales_money|format_money}</td>
54 56
                    <td>{$value.actual_amount}</td>
55
                    <td>{$value.actual_price}</td>
56
                    <td>{$value.fare}</td>
57
                    <td>{$value.agency}</td>
57
                    <td>{$value.actual_price|format_money}</td>
58
                    <td>{$value.actual_money|format_money}</td>
59
                    <td>{$value.fare|format_money}</td>
60
                    <td>{$value.agency|format_money}</td>
58 61
                    <td>{$value.remark}</td>
62
                    <td class="td-status">{$value.status}</td>
59 63
                    <td>{$types[$value['type']]}</td>
60 64
                    <td class="td-manager">
61 65
                        <a href="javascript:void(0);" onclick="save('{$value.id}')">修改</a>

+ 8 - 4
view/seller/index.html

@ -7,10 +7,14 @@
7 7
</nav>
8 8
9 9
<div class="content">
10
    <div class="row">
10
    <div class="row" style="margin: 0;">
11 11
        <div class="col-md-3 btn-top-box">
12 12
            <!-- <a href="javascript:;" class="btn btn-danger radius" onClick="del_all()">批量删除</a> -->
13 13
            <a href="/seller/save/0" class="btn btn-success radius">新增</a>
14
            {notempty name="did"}<a href="/seller/index" class="btn btn-default radius">返回</a>{/notempty}
15
        </div>
16
        <div class="col-md-3 col-md-offset-4 btn-top-box">
17
            <a href="/department/index" class="btn btn-primary radius">部门管理</a>
14 18
        </div>
15 19
    </div>
16 20
    <div class="col-md-10 mt-20">
@ -20,7 +24,7 @@
20 24
                    <th width="25">
21 25
                        <input type="checkbox" value="" name="">
22 26
                    </th>
23
                    <th class="text-center">序 号</th>
27
                    <th class="text-center">id</th>
24 28
                    <th class="text-center">销售员</th>
25 29
                    <th class="text-center">所属部门</th>
26 30
                    <th class="text-center">操作</th>
@ -34,10 +38,10 @@
34 38
                    </td>
35 39
                    <td class="text-center">{$value.id}</td>
36 40
                    <td class="text-center">{$value.name}</td>
37
                    <td class="text-center">{$value.department_name}</td>
41
                    <td class="text-center"><a href="/seller/index/{$value.department_id}">{$value.department_name}</a></td>
38 42
                    <td class="text-center td-manager">
39 43
                        <a href="/seller/save/{$value['id']}">修改</a>
40
                        <a href="javascript:void(0);" class="ml-10" onClick="del({$value.id|intval}, this)">删除</a>
44
                        <a href="javascript:void(0);" class="ml-10" onClick="del('{$value.id}', this)">删除</a>
41 45
                    </td>
42 46
                </tr>
43 47
                {/foreach}