Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0d9ade8b
authored
Aug 09, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整线上下单
parent
552d3453
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
19 deletions
app/Http/Controllers/AddOrderController.php
app/Http/routes.php
config/website.php
public/js/add_order.js
public/js/goods.js
resources/views/detail/addGoods.blade.php
app/Http/Controllers/AddOrderController.php
View file @
0d9ade8b
...
...
@@ -10,6 +10,8 @@ use Cookie;
use
App\Http\Page
;
use
App\Http\Controllers\PermController
;
use
App\Http\Error
;
use
App\Model\UserMainModel
;
use
App\Model\OrderModel
;
use
Excel
;
Class
AddOrderController
extends
Controller
...
...
@@ -87,22 +89,32 @@ Class AddOrderController extends Controller
public
function
getUserInfo
(
Request
$request
)
{
if
(
$request
->
isMethod
(
'post'
))
{
$mobile
=
$request
->
input
(
'mobile'
);
$mobile
=
$request
->
input
(
'mobile'
);
$goods_type
=
$request
->
input
(
'goods_type'
);
// 类型,1-联营,2-自营
$operator_id
=
$request
->
user
->
userId
;
$UserMainModel
=
new
UserMainModel
;
if
(
preg_match
(
'/@/'
,
$mobile
))
{
$user
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_main'
)
->
where
(
'email'
,
$mobile
)
->
select
(
'user_id'
,
'email'
,
'is_test'
)
->
first
();
$user
=
$UserMainModel
->
where
(
'email'
,
$mobile
)
->
select
(
'user_id'
,
'email'
,
'is_test'
)
->
first
();
}
else
{
$user
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_main'
)
->
where
(
'mobile'
,
$mobile
)
->
select
(
'user_id'
,
'mobile'
,
'is_test'
)
->
first
();
}
$user
=
$UserMainModel
->
where
(
'mobile'
,
$mobile
)
->
select
(
'user_id'
,
'mobile'
,
'is_test'
)
->
first
();
}
if
(
!
empty
(
$user
))
{
$perm
=
new
PermController
;
$role
=
$perm
->
getUserRole
(
$request
);
// 用户角色
if
(
!
empty
(
$user
))
{
// 收货地址
$address
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_address'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
if
(
$goods_type
==
1
||
(
$goods_type
==
2
&&
!
in_array
(
$role
,
[
1
,
10
,
11
])))
{
// 自营管理员、主管、主管助理可以帮客服下单
$last_sale_id
=
$this
->
findLastSaleId
(
$user
->
user_id
);
// 发票信息
$invoice
=
DB
::
connection
(
'order'
)
->
table
(
'lie_taxinfo'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
if
(
$last_sale_id
&&
$operator_id
!=
$last_sale_id
)
return
[
'errcode'
=>
-
1
,
'errmsg'
=>
'暂不能跟进该客户,请联系主管重新指派'
];
}
$address
=
DB
::
connection
(
'order'
)
->
table
(
'lie_user_address'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 收货地址
$invoice
=
DB
::
connection
(
'order'
)
->
table
(
'lie_taxinfo'
)
->
where
(
'user_id'
,
$user
->
user_id
)
->
get
();
// 发票信息
$info
[
'user'
]
=
$user
;
$info
[
'user'
]
=
$user
;
$info
[
'address'
]
=
$address
;
$info
[
'invoice'
]
=
$invoice
;
}
...
...
@@ -115,6 +127,20 @@ Class AddOrderController extends Controller
}
}
// 获取用户最近的订单跟进业务员
public
function
findLastSaleId
(
$user_id
)
{
$OrderModel
=
new
OrderModel
;
$map
[
'user_id'
]
=
$user_id
;
$map
[
'is_type'
]
=
0
;
// 过滤尽调数据
$map
[]
=
[
'sale_id'
,
'>'
,
0
];
$order
=
$OrderModel
->
where
(
$map
)
->
select
(
'sale_id'
)
->
first
();
return
$order
?
$order
[
'sale_id'
]
:
0
;
}
// 选择收货地址
public
function
selectAddr
(
Request
$request
)
{
...
...
@@ -743,4 +769,22 @@ Class AddOrderController extends Controller
return
$goods_info
;
}
// 添加商品到订单
public
function
addGoods
(
Request
$request
)
{
if
(
$request
->
isMethod
(
'post'
))
{
$data
[
'order_id'
]
=
$request
->
input
(
'order_id'
);
$data
[
'goods_id'
]
=
$request
->
input
(
'goods_id'
);
$data
[
'goods_num'
]
=
$request
->
input
(
'goods_num'
);
$data
[
'operator_id'
]
=
$request
->
user
->
userId
;
$url
=
Config
(
'website.order_api_domain'
)
.
'/order/addgoods'
;
$response
=
json_decode
(
curlApi
(
$url
,
$data
,
'post'
),
true
);
return
[
'errcode'
=>
$response
[
'errcode'
],
'errmsg'
=>
$response
[
'errmsg'
]];
}
}
}
\ No newline at end of file
app/Http/routes.php
View file @
0d9ade8b
...
...
@@ -132,6 +132,8 @@ Route::group(['middleware' => 'web'], function () {
Route
::
get
(
'/self_return_export'
,
'ReturnController@selfReturnExport'
);
Route
::
match
([
'get'
,
'post'
],
'/return_edit/{id}'
,
'OrderController@orderReturnEdit'
);
Route
::
post
(
'/ajax/addGoods'
,
'AddOrderController@addGoods'
);
});
// 不需要登陆态
...
...
config/website.php
View file @
0d9ade8b
...
...
@@ -76,4 +76,7 @@ return [
// 支付地址
'pay_url'
=>
'https://www.liexin.com/v3/pay/online?id='
,
// 订单微服务
'order_api_domain'
=>
'http://orderapi.liexin.com'
,
];
public/js/add_order.js
View file @
0d9ade8b
...
...
@@ -46,7 +46,7 @@
$
.
ajax
({
url
:
'/ajax/getUserInfo'
,
type
:
'post'
,
data
:
{
mobile
:
mobile
.
trim
()},
data
:
{
mobile
:
mobile
.
trim
()
,
goods_type
:
goods_type
},
dataType
:
'json'
,
success
:
function
(
resp
)
{
if
(
resp
.
errcode
==
0
)
{
...
...
public/js/goods.js
View file @
0d9ade8b
...
...
@@ -12,6 +12,66 @@
content
:
$
(
'#addGoods'
),
btn
:
[
'新增'
,
'取消'
],
btn1
:
function
()
{
var
goods_min_num
=
$
(
'.sku-info'
).
find
(
'.moq'
).
text
();
// 最小起订量
var
goods_id
=
$
(
'.sku-info'
).
find
(
'.goods_id'
).
val
();
var
type
=
$
(
'.sku-info'
).
find
(
'.goods_type'
).
val
();
// 商品类型
var
order_id
=
$
(
'#order_id'
).
val
();
var
delivery_place
=
1
// 1.大陆,2.香港 自营默认是大陆
var
goods_min_price
=
$
(
'.sku-info'
).
find
(
'.goods-min-price'
).
text
();
// 人民币单价
var
goods_min_price_us
=
$
(
'.sku-info'
).
find
(
'.goods-min-price-us'
).
text
();
// 美元单价
if
(
goods_type
==
1
)
{
// 联营需要选择交货地
if
(
type
==
3
||
type
==
4
)
{
layer
.
msg
(
'自营商品不能添加到联营订单'
);
return
false
;
}
if
(
delivery_place
==
1
)
{
if
(
!
goods_min_price
)
{
layer
.
msg
(
'缺少RMB价格,商品添加失败'
);
return
false
;
}
}
else
if
(
delivery_place
==
2
)
{
if
(
!
goods_min_price_us
)
{
layer
.
msg
(
'缺少美金价格,商品添加失败'
);
return
false
;
}
}
}
else
{
if
(
type
==
1
||
type
==
2
)
{
// 1.联营 2.专卖
layer
.
msg
(
'联营商品不能添加到自营订单'
);
return
false
;
}
if
(
!
goods_min_price
)
{
layer
.
msg
(
'缺少RMB价格,商品添加失败'
);
return
false
;
}
}
var
datax
=
{
order_id
:
order_id
,
goods_id
:
goods_id
,
goods_num
:
goods_min_num
,
};
$
.
ajax
({
type
:
"POST"
,
url
:
'/ajax/addGoods'
,
data
:
datax
,
dataType
:
"json"
,
success
:
function
(
resp
){
if
(
resp
.
errcode
==
0
){
layer
.
msg
(
resp
.
errmsg
||
'操作成功'
);
setTimeout
(
function
(){
location
.
reload
();
},
1000
);
return
false
;
}
else
{
layer
.
alert
(
resp
.
errmsg
||
'网络异常'
);
}
},
})
},
btn2
:
function
(
index
)
{
...
...
@@ -102,15 +162,27 @@
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
html
+=
'<tr>'
;
if
(
data
.
ac_type
)
{
html
+=
'<td><span>'
+
data
.
tiered
[
i
][
'purchases'
]
+
'</span></td><td>¥<span class="price-line">'
+
data
.
tiered
[
i
][
'price_cn'
]
+
'</span></td><td>¥<span>'
+
data
.
tiered
[
i
][
'price_ac'
]
+
'</span></td>'
;
if
(
i
==
0
)
{
if
(
data
.
ac_type
)
{
html
+=
'<td><span class="goods-min-num">'
+
data
.
tiered
[
i
][
'purchases'
]
+
'</span></td><td>¥<span class="goods-min-price price-line">'
+
data
.
tiered
[
i
][
'price_cn'
]
+
'</span><td>¥<span>'
+
data
.
tiered
[
i
][
'price_ac'
]
+
'</span></td>'
;
}
else
{
html
+=
'<td><span class="goods-min-num">'
+
data
.
tiered
[
i
][
'purchases'
]
+
'</span></td><td>¥<span class="goods-min-price">'
+
data
.
tiered
[
i
][
'price_cn'
]
+
'</span></td>'
;
}
if
(
goods_type
==
1
&&
data
.
tiered
[
0
][
'price_us'
])
{
html
+=
'<td>$<span class="goods-min-price-us">'
+
data
.
tiered
[
i
][
'price_us'
]
+
'</span></td>'
;
}
}
else
{
html
+=
'<td><span>'
+
data
.
tiered
[
i
][
'purchases'
]
+
'</span></td><td>¥<span>'
+
data
.
tiered
[
i
][
'price_cn'
]
+
'</span></td>'
;
}
if
(
goods_type
==
1
)
{
html
+=
'<td>$<span>'
+
data
.
tiered
[
i
][
'price_us'
]
+
'</span></td>'
;
}
if
(
data
.
ac_type
)
{
html
+=
'<td><span>'
+
data
.
tiered
[
i
][
'purchases'
]
+
'</span></td><td>¥<span class="price-line">'
+
data
.
tiered
[
i
][
'price_cn'
]
+
'</span></td><td>¥<span>'
+
data
.
tiered
[
i
][
'price_ac'
]
+
'</span></td>'
;
}
else
{
html
+=
'<td><span>'
+
data
.
tiered
[
i
][
'purchases'
]
+
'</span></td><td>¥<span>'
+
data
.
tiered
[
i
][
'price_cn'
]
+
'</span></td>'
;
}
if
(
goods_type
==
1
&&
data
.
tiered
[
0
][
'price_us'
])
{
html
+=
'<td>$<span>'
+
data
.
tiered
[
i
][
'price_us'
]
+
'</span></td>'
;
}
}
html
+=
'</tr>'
;
}
...
...
resources/views/detail/addGoods.blade.php
View file @
0d9ade8b
...
...
@@ -87,10 +87,12 @@
</div>
<input
type=
"hidden"
name=
"goods_id"
class=
"goods_id"
value=
""
>
<input
type=
"hidden"
name=
"goods_type"
class=
"goods_type"
value=
""
>
</div>
</div>
</div>
<script>
var
goods_type
=
"{{ $order_info['order_goods_type'] }}"
;
var
delivery_place
=
"{{ $order_info['delivery_place'] }}"
;
</script>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment