Commit 6936fc36 by 朱继来

添加售后数量

parent 9c943632
......@@ -448,6 +448,13 @@ class ApiController extends Controller
$this->Export($OrderServiceModel->action($request));
}
// 获取售后数量
public function ApiOrderServicedNum($request)
{
$OrderServiceModel = new OrderServiceModel;
$this->Export($OrderServiceModel->getServicedNum($request));
}
// 售后单编辑
public function ApiOrderServiceEdit($request)
{
......
......@@ -171,7 +171,7 @@ class OrderServiceModel extends Model
$post['operator_id'] = $request->user->userId;
$url = Config('website.api_domain').'refund/apply';
dd(curlApi($url, $post, 'POST'));
$res = json_decode(curlApi($url, $post, 'POST'), true);
if (!$res || $res['err_code'] != 0) return [-2, '审核通过生成退款单失败,原因:'.$res['err_msg']];
......@@ -232,5 +232,31 @@ class OrderServiceModel extends Model
return [0, '成功'];
}
// 获取已售后数量
public function getServicedNum($request)
{
$order_id = $request->input('order_id', 0);
$data = $this->from('lie_order_service as s')
->leftJoin('lie_order_service_items as i', 's.id', '=', 'i.service_id')
->where('s.service_status', '>', 1)
->where('i.order_id', $order_id)
->select('goods_id', 'adjust_number')
->get()
->toArray();
if (empty($data)) return [0, '', $data];
$goods = [];
foreach ($data as $v) {
if (isset($goods[$v['goods_id']] )) {
$goods[$v['goods_id']] += $v['adjust_number'];
} else {
$goods[$v['goods_id']] = $v['adjust_number'];
}
}
return [0, '', $goods];
}
}
\ No newline at end of file
......@@ -109,6 +109,23 @@ layui.use(['form', 'table', 'laydate'], function(){
$('.bank_sub_name').val(data.bank_sub_name);
}
// 获取售后数量
var serviced_num = [];
$.ajax({
url : '/api/ApiOrderServicedNum',
type: 'post',
data: {order_id: data.order_id},
dataType: 'json',
async: false,
success: function(resp) {
if (resp.data) serviced_num = resp.data;
},
error: function(err) {
console.log(err)
}
})
var html = '';
var items = data.items;
var len = items.length;
......@@ -121,7 +138,7 @@ layui.use(['form', 'table', 'laydate'], function(){
<td class="origin-goods-number">'+ items[i].goods_number +'</td>\
<td class="fqty">'+ items[i].removal_number +'</td>\
<td class="single_pre_price">'+ items[i].single_pre_price +'</td>\
<td class="service-goods-number"></td>';
<td class="service-goods-number">'+( serviced_num[items[i].goods_id] ?? 0 )+'</td>';
if (items[i].adjust_number != 0) {
html += '<td><input type="text" class="form-control adjust_number" name="service_item['+items[i].id+'][adjust_number]" value="'+ items[i].adjust_number +'"></td>';
......
......@@ -136,8 +136,6 @@
<script>
var apply_reason = eval('('+'{!! json_encode(Config("order_service.apply_reason")) !!}'+')');
console.log(apply_reason)
console.log(apply_reason.length)
</script>
@include('common.order_service')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment