Commit 16c9be2f by 朱继来

添加已售后数量

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