Commit 16c9be2f by 朱继来

添加已售后数量

parent c90c2d9e
......@@ -24,6 +24,8 @@ use App\Model\QueuedModel;
use App\Model\ErpPayLogModel;
use App\Model\PayExtendModel;
use App\Model\OrderPurPriceModel;
use App\Model\OrderServiceModel;
use App\Model\OrderServiceItemsModel;
use Session;
use Hprose\Http\Client;
......@@ -335,6 +337,20 @@ function getOrderPurPrice($xls_sn)
return $data;
}
// 获取已提交售后单数量
function getOrderServiceNum($order_id, $goods_id)
{
$OrderServiceModel = new OrderServiceModel;
$OrderServiceItemsModel = new OrderServiceItemsModel;
return $OrderServiceModel->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)
->where('i.goods_id', $goods_id)
->sum('i.goods_number');
}
Class OrderController extends Controller
{
......
......@@ -16,9 +16,10 @@
content: $('.order_service_info'),
btn:['确定', '取消'],
yes: function(index, layero){
var apply_reason = $('.apply_reason').val();
var remark = $('.remark').val();
var is_empty = false; // 校验申请数量、单价是否为空
var apply_reason = $('.apply_reason').val();
var remark = $('.remark').val();
var is_all_num_empty = false; // 校验全部申请数量是否为空
var is_all_price_empty = false; // 校验全部单价是否为空
if (!apply_reason) {
layer.tips('请选择申请原因', $('.apply_reason'));
......@@ -34,20 +35,19 @@
var goods_number = $(this).find('.adjust_number').val();
var goods_price = $(this).find('.adjust_price').val();
if (!goods_number) {
layer.tips('请填写申请数量', $(this).find('.adjust_number'));
is_empty = true;
return false;
}
if (!goods_price) {
layer.tips('请填写售后单价', $(this).find('.adjust_price'));
is_empty = true;
return false;
}
if (goods_number) is_all_num_empty = true;
if (goods_price) is_all_price_empty = true;
})
if (is_empty) return false;
if (!is_all_num_empty) {
layer.msg('请填写申请数量');
return false;
}
if (!is_all_price_empty) {
layer.msg('请填写售后单价');
return false;
}
var datax = $('.orderServiceForm').serialize() + '&order_id=' + order_id;
$.ajax({
......@@ -87,9 +87,11 @@
$('.orderServiceForm').find('.select-all').click(function() {
$('.order-service-table').find('tbody tr').each(function() {
var goods_number = $(this).find('.origin-goods-number').html();
var service_goods_number = $(this).find('.service-goods-number').html();
var goods_price = $(this).find('.origin-goods-price').html();
$(this).find('.adjust_number').val(goods_number);
var allow_num = (goods_number - service_goods_number) || '';
$(this).find('.adjust_number').val(allow_num);
$(this).find('.adjust_price').val(goods_price);
})
})
......@@ -108,9 +110,10 @@
var goods_price = parseFloat($(this).parents('tr').find('.origin-goods-price').html()); // 原订单单价
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 原订单数量
var origin_amount = goods_price * goods_number; // 商品可退金额
var service_goods_number = parseInt($(this).parents('tr').find('.service-goods-number').html()); // 已售后数量
var origin_amount = goods_price * (goods_number - service_goods_number); // 商品可退金额
if (val > goods_number) {
if (val > (goods_number - service_goods_number)) {
layer.msg('不能超过订单数量');
$(this).val('');
return false;
......@@ -168,7 +171,8 @@
var goods_price = parseFloat($(this).parents('tr').find('.origin-goods-price').html()); // 原订单单价
var goods_number = parseInt($(this).parents('tr').find('.origin-goods-number').html()); // 原订单数量
var origin_amount = goods_price * goods_number; // 商品可退金额
var service_goods_number = parseInt($(this).parents('tr').find('.service-goods-number').html()); // 已售后数量
var origin_amount = goods_price * (goods_number - service_goods_number); // 商品可退金额
var adjust_number = $(this).parents('tr').find('.adjust_number').val();
var adjust_amount = adjust_number * val;
......
......@@ -39,6 +39,7 @@
<th width="8%">订单数量</th>
<th width="8%">出库数量</th>
<th width="8%">原单价</th>
<th width="10%">已售后数量</th>
<th width="8%">申请数量</th>
<th width="8%">售后单价</th>
</tr>
......@@ -51,6 +52,7 @@
<?php $goods_count++; ?>
<tr>
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][rec_id]" value="{{ $v['rec_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][order_id]" value="{{ $v['order_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][goods_id]" value="{{ $v['goods_id'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][goods_name]" value="{{ $v['goods_name'] }}">
<input type="hidden" name="service_item[{{ $v['rec_id'] }}][sku_name]" value="{{ $v['sku_name'] }}">
......@@ -68,6 +70,7 @@
<td class="origin-goods-number">{{ $v['goods_number'] }}</td>
<td>{{ $v['fqty'] }}</td>
<td class="origin-goods-price">{{ $v['goods_price'] }}</td>
<td class="service-goods-number">{{ App\Http\Controllers\getOrderServiceNum($v['order_id'], $v['goods_id']) }}</td>
<td><input type="text" class="adjust_number" name="service_item[{{ $v['rec_id'] }}][adjust_number]"></td>
<td><input type="text" class="adjust_price" name="service_item[{{ $v['rec_id'] }}][adjust_price]"></td>
</tr>
......
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