修复奖励BUG
parent
a48071aac6
commit
acb960a952
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Console\Commands\Distribution;
|
namespace App\Console\Commands\Distribution;
|
||||||
|
|
||||||
use App\Exceptions\BizException;
|
|
||||||
use App\Models\DistributionPreIncome;
|
use App\Models\DistributionPreIncome;
|
||||||
use App\Models\DistributionPreIncomeJob;
|
use App\Models\DistributionPreIncomeJob;
|
||||||
use App\Models\MerchantMessage;
|
use App\Models\MerchantMessage;
|
||||||
|
|
@ -48,13 +47,6 @@ class PreIncomeJobCommand extends Command
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
||||||
report($e);
|
report($e);
|
||||||
|
|
||||||
if ($e instanceof BizException) {
|
|
||||||
$job->update([
|
|
||||||
'status' => DistributionPreIncomeJob::STATUS_FAILED,
|
|
||||||
'failed_reason' => $e->getMessage(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送商家端预收益进帐消息
|
//发送商家端预收益进帐消息
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,11 @@ class OrderSettleCommand extends Command
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
// 只查询可结算的订单,并且没有处理中的售后单
|
// 只查询可结算的订单,并且没有处理中的售后单
|
||||||
|
// 检查订单是否有未执行的分销任务
|
||||||
Order::whereDoesntHave('afterSales', function ($query) {
|
Order::whereDoesntHave('afterSales', function ($query) {
|
||||||
return $query->processing();
|
return $query->processing();
|
||||||
|
})->whereDoesntHave('distributionPreIncomeJobs', function ($query) {
|
||||||
|
return $query->pending();
|
||||||
})->settlable()->chunkById(200, function ($orders) {
|
})->settlable()->chunkById(200, function ($orders) {
|
||||||
$orders->load(['user', 'afterSales']);
|
$orders->load(['user', 'afterSales']);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,14 @@ class Order extends Model
|
||||||
return $this->hasMany(AfterSale::class, 'order_id');
|
return $this->hasMany(AfterSale::class, 'order_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属于此订单的预收益任务
|
||||||
|
*/
|
||||||
|
public function distributionPreIncomeJobs()
|
||||||
|
{
|
||||||
|
return $this->morphMany(DistributionPreIncomeJob::class, 'jobable');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 此订单是否待付款
|
* 此订单是否待付款
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ class AfterSaleService
|
||||||
if (in_array($afterSale->type, [AfterSale::TYPE_REFUND_AND_RETURN, AfterSale::TYPE_REFUND])) {
|
if (in_array($afterSale->type, [AfterSale::TYPE_REFUND_AND_RETURN, AfterSale::TYPE_REFUND])) {
|
||||||
if ($afterSaleProduct->total_amount > 0) {
|
if ($afterSaleProduct->total_amount > 0) {
|
||||||
// 总销售值
|
// 总销售值
|
||||||
$totalSalesValue = bcmul($afterSaleProduct->sales_value, $afterSaleProduct->quantity);
|
$totalSalesValue = bcmul($afterSaleProduct->sales_value, $afterSaleProduct->quantity, 2);
|
||||||
// 售后变更金额
|
// 售后变更金额
|
||||||
$amount = $afterSale->amount;
|
$amount = $afterSale->amount;
|
||||||
|
|
||||||
|
|
@ -459,11 +459,16 @@ class AfterSaleService
|
||||||
'remarks' => $remarks,
|
'remarks' => $remarks,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (! $afterSaleProduct->isGift() && in_array($afterSale->type, [
|
// 订单未结算
|
||||||
AfterSale::TYPE_REFUND_AND_RETURN,
|
// 非赠品售后单,且售后单类型是换货、退款、退款退货
|
||||||
AfterSale::TYPE_REFUND,
|
if (! $order->is_settle
|
||||||
AfterSale::TYPE_CHANGE,
|
&& ! $afterSaleProduct->isGift()
|
||||||
])) {
|
&& in_array($afterSale->type, [
|
||||||
|
AfterSale::TYPE_REFUND_AND_RETURN,
|
||||||
|
AfterSale::TYPE_REFUND,
|
||||||
|
AfterSale::TYPE_CHANGE,
|
||||||
|
])
|
||||||
|
) {
|
||||||
DistributionPreIncomeJob::create([
|
DistributionPreIncomeJob::create([
|
||||||
'jobable_id' => $afterSale->id,
|
'jobable_id' => $afterSale->id,
|
||||||
'jobable_type' => $afterSale->getMorphClass(),
|
'jobable_type' => $afterSale->getMorphClass(),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Exceptions\BizException;
|
|
||||||
use App\Models\AfterSale;
|
use App\Models\AfterSale;
|
||||||
use App\Models\DistributionPreIncome;
|
use App\Models\DistributionPreIncome;
|
||||||
use App\Models\DistributionPreIncomeJob;
|
use App\Models\DistributionPreIncomeJob;
|
||||||
|
|
@ -37,10 +36,6 @@ class DistributionPreIncomeJobService
|
||||||
case AfterSale::class:
|
case AfterSale::class:
|
||||||
$this->runOrderAfterSaleJob($job);
|
$this->runOrderAfterSaleJob($job);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
throw new BizException('任务类型不支持');
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$job->update([
|
$job->update([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue