订单商品增加销量新增订单支付规则

This commit is contained in:
Devil 2021-07-08 23:06:07 +08:00
parent f0ebb397ab
commit 51d13a206e
5 changed files with 72 additions and 17 deletions

View File

@ -180,6 +180,9 @@ class Site extends Common
// 扣除库存规则
$this->assign('common_deduction_inventory_rules_list', lang('common_deduction_inventory_rules_list'));
// 增加销量规则
$this->assign('common_sales_count_inc_rules_list', lang('common_sales_count_inc_rules_list'));
// 首页商品排序规则
$this->assign('goods_order_by_type_list', lang('goods_order_by_type_list'));
$this->assign('goods_order_by_rule_list', lang('goods_order_by_rule_list'));

View File

@ -41,6 +41,16 @@
</select>
</div>
<!-- 订单商品销量 -->
<div class="am-form-group">
<label>{{$data.common_goods_sales_count_inc_rules.name}}<span class="am-form-group-label-tips">{{$data.common_goods_sales_count_inc_rules.describe}}</span></label>
<select name="{{$data.common_goods_sales_count_inc_rules.only_tag}}" class="am-radius chosen-select" data-validation-message="{{$data.common_goods_sales_count_inc_rules.error_tips}}" required>
{{foreach $common_sales_count_inc_rules_list as $v}}
<option value="{{$v.id}}" {{if isset($data['common_goods_sales_count_inc_rules']['value']) and $data['common_goods_sales_count_inc_rules']['value'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</div>
<!-- 订单批量支付 -->
<div class="am-form-group">
<label>{{$data.home_is_enable_order_bulk_pay.name}}<span class="am-form-group-label-tips">{{$data.home_is_enable_order_bulk_pay.describe}}</span></label>

View File

@ -173,11 +173,17 @@ return [
// 扣除库存规则
'common_deduction_inventory_rules_list' => [
0 => ['id' => 0, 'name' => '订单确认成功', 'checked' => true],
0 => ['id' => 0, 'name' => '订单确认成功'],
1 => ['id' => 1, 'name' => '订单支付成功'],
2 => ['id' => 2, 'name' => '订单发货'],
],
// 商品增加销量规则
'common_sales_count_inc_rules_list' => [
0 => ['id' => 0, 'name' => '订单支付'],
1 => ['id' => 1, 'name' => '订单收货'],
],
// 是否已读
'common_is_read_list' => [
0 => ['id' => 0, 'name' => '未读', 'checked' => true],

View File

@ -988,7 +988,9 @@ class OrderAftersaleService
}
// 已完成订单、商品销量释放
if($order['data']['status'] == 4 && $aftersale['number'] > 0)
// 规则 订单支付、订单收货(默认)
$order_status = (MyC('common_goods_sales_count_inc_rules', 1) == 1) ? 4 : 2;
if($order['data']['status'] == $order_status && $aftersale['number'] > 0)
{
if(!Db::name('Goods')->where(['id'=>intval($aftersale['goods_id'])])->setDec('sales_count', $aftersale['number']))
{

View File

@ -807,7 +807,16 @@ class OrderService
{
// 事务回滚
Db::rollback();
return DataReturn($ret['msg'], -10);
return $ret;
}
// 订单商品销量增加
$ret = self::GoodsSalesCountInc(['order_id'=>$order['id'], 'order_status'=>2]);
if($ret['code'] != 0)
{
// 事务回滚
Db::rollback();
return $ret;
}
// 订单支付成功处理完毕钩子
@ -1789,16 +1798,16 @@ class OrderService
{
// 事务回滚
Db::rollback();
return DataReturn($ret['msg'], -10);
return $ret;
}
// 订单商品销量增加
$ret = self::GoodsSalesCountInc(['order_id'=>$order['id']]);
$ret = self::GoodsSalesCountInc(['order_id'=>$order['id'], 'order_status'=>4]);
if($ret['code'] != 0)
{
// 事务回滚
Db::rollback();
return DataReturn($ret['msg'], -10);
return $ret;
}
// 用户消息
@ -2106,6 +2115,11 @@ class OrderService
'checked_type' => 'empty',
'key_name' => 'order_id',
'error_msg' => '订单id有误',
],
[
'checked_type' => 'isset',
'key_name' => 'order_status',
'error_msg' => '订单状态有误',
]
];
$ret = ParamsChecked($params, $p);
@ -2114,6 +2128,24 @@ class OrderService
return DataReturn($ret, -1);
}
// 增加销量规则、默认订单收货
$status = false;
if(MyC('common_goods_sales_count_inc_rules', 1) == 1)
{
// 订单收货责确认订单状态是收货状态
if($params['order_status'] == 4)
{
$status = true;
}
} else {
// 订单支付状态
if($params['order_status'] == 2)
{
$status = true;
}
}
if($status)
{
// 获取订单商品
$order_detail = Db::name('OrderDetail')->field('id,goods_id,title,buy_number')->where(['order_id'=>$params['order_id']])->select();
if(!empty($order_detail))
@ -2130,6 +2162,8 @@ class OrderService
return DataReturn('订单有误,没有找到相关商品', -100);
}
}
return DataReturn('无需处理', 0);
}
/**
* 支付状态校验