添加:消费返利 - 结算到佣金
This commit is contained in:
parent
5f1ad1487a
commit
9fabc89f64
|
|
@ -209,6 +209,8 @@ class IncomeService
|
|||
const STORE_MANAGER = 200;// 经销商店长-店补
|
||||
const CULTURAL_SPACE_CONTRIBUTION_BONUS = 201;// 文创空间 - 贡献分享分红
|
||||
const CULTURAL_SPACE_AREA_BONUS = 202;// 文创空间 - 市场津贴
|
||||
const REBATE_MONEY = 203;// 消费返利
|
||||
|
||||
|
||||
/**
|
||||
* @param $data 会员id:member_id,分红类型:dividend_code,分红表id:dividend_table_id,金额:amount,订单号:order_sn,详情:detail
|
||||
|
|
@ -681,6 +683,7 @@ class IncomeService
|
|||
self::STORE_MANAGER => '店补',
|
||||
self::CULTURAL_SPACE_CONTRIBUTION_BONUS => '贡献分享分红',
|
||||
self::CULTURAL_SPACE_AREA_BONUS => '市场津贴',
|
||||
self::REBATE_MONEY => '消费返利'
|
||||
];
|
||||
if (empty($income_config_desc[$code])) {
|
||||
if ($func = app('ShopAsset')->getData('income')[$code]) {
|
||||
|
|
@ -883,6 +886,7 @@ class IncomeService
|
|||
self::STORE_MANAGER => 'Yunshop\TeamDividend\Common\models\StoreManagerRecordModel',
|
||||
self::CULTURAL_SPACE_CONTRIBUTION_BONUS => 'Yunshop\CulturalSpace\models\ContributionBonusLog',
|
||||
self::CULTURAL_SPACE_AREA_BONUS => 'Yunshop\CulturalSpace\models\CulturalSpaceAreaBonus',
|
||||
self::REBATE_MONEY => 'Yunshop\Rebate\models\Rebate'
|
||||
];
|
||||
if (empty($income_config_class[$code])) {
|
||||
if ($func = app('ShopAsset')->getData('income')[$code]) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class CulturalSpace extends BaseModel
|
|||
*/
|
||||
public function buyGoodsGiveContribution($uid, $orderId)
|
||||
{
|
||||
\Log::debug('文创空间 - 购买商品奖励贡献值', ['uid' => $uid, 'order_id' => $orderId]);
|
||||
// \Log::debug('文创空间 - 购买商品奖励贡献值', ['uid' => $uid, 'order_id' => $orderId]);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$set = Setting::get('plugin.cultural_space_set');
|
||||
|
|
@ -138,7 +138,7 @@ class CulturalSpace extends BaseModel
|
|||
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
\Log::debug('文创空间 - 购买商品奖励贡献值 - 错误抛出', $e->getMessage());
|
||||
// \Log::debug('文创空间 - 购买商品奖励贡献值 - 错误抛出', $e->getMessage());
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ class CulturalSpace extends BaseModel
|
|||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
\Log::debug('文创空间 - 基金池操作 - 错误:'.$e->getMessage());
|
||||
// \Log::debug('文创空间 - 基金池操作 - 错误:'.$e->getMessage());
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
namespace Yunshop\Rebate;
|
||||
|
||||
use Yunshop\Rebate\listener\OrderPaidListener;
|
||||
use Yunshop\Rebate\models\Rebate;
|
||||
|
||||
class PluginApplication extends \app\common\services\PluginApplication{
|
||||
|
||||
|
|
@ -89,6 +90,16 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
);
|
||||
}
|
||||
|
||||
public function getIncomeItems(){
|
||||
return [
|
||||
'rebate' => [
|
||||
'title' => '消费返利',
|
||||
'type' => 'rebate',
|
||||
'type_name' => '消费返利',
|
||||
'class' => 'Yunshop\Rebate\models\Rebate',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function boot(){
|
||||
$events = app('events');
|
||||
|
|
@ -98,5 +109,21 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
}
|
||||
|
||||
|
||||
public function cronConfig(){
|
||||
\Event::listen('cron.collectJobs', function () {
|
||||
// 每天5分钟 执行一次消费返利解冻判断
|
||||
\Cron::add('rebate-settlement', '*/5 * * * *', function () {
|
||||
Rebate::rebateThaw();
|
||||
return;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -9,7 +9,13 @@ use Yunshop\CollectionRoom\models\CollectionRoomModel;
|
|||
use Yunshop\Rebate\models\Rebate;
|
||||
|
||||
class IndexController extends BaseController{
|
||||
// 进入列表
|
||||
/**
|
||||
* Common: 进入列表
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/15 9:46
|
||||
* @return array|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function index(){
|
||||
//参数获取
|
||||
$pageSize = request()->input('page_size',10);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use app\common\models\Goods;
|
|||
use app\common\models\Member;
|
||||
use app\common\models\Order;
|
||||
use app\common\models\OrderGoods;
|
||||
use app\common\services\income\IncomeService;
|
||||
|
||||
class Rebate extends BaseModel{
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ class Rebate extends BaseModel{
|
|||
];
|
||||
// 判断:第一季度第一个月 并且 (不是最后一个月 或者 本季度不需要复购):立即解冻
|
||||
if($quarterIndex == 1 && $monthIndex == 1 && ($monthIndex != $endKey || (int)$quarterInfo['is_repurchase'] != 1)){
|
||||
$currentMonthData['reality_thaw_time'] = $currentExpectThawTime;
|
||||
$currentMonthData['reality_thaw_time'] = time();
|
||||
$currentMonthData['status'] = 1;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +121,10 @@ class Rebate extends BaseModel{
|
|||
}
|
||||
|
||||
// 添加数据
|
||||
if(count($insertData) > 0) self::insert($insertData);
|
||||
if(count($insertData) > 0) {
|
||||
self::insert($insertData);
|
||||
self::rebateSettlement();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -147,6 +151,58 @@ class Rebate extends BaseModel{
|
|||
->makeHidden(['order','after_sales','buttons'])
|
||||
->toArray();
|
||||
}
|
||||
/**
|
||||
* Common: 返利信息解冻
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/15 9:58
|
||||
*/
|
||||
public static function rebateThaw(){
|
||||
$time = time();
|
||||
// 预计解冻时间 低于当前时间 解冻
|
||||
self::where('expect_thaw_time','<=', $time)->update([
|
||||
'status' => 1,
|
||||
'reality_thaw_time' => $time
|
||||
]);
|
||||
// 执行 已解冻佣金结算到账
|
||||
self::rebateSettlement();
|
||||
}
|
||||
/**
|
||||
* Common: 已解冻返利 结算到佣金
|
||||
* Author: wu-hui
|
||||
* Time: 2024/03/15 9:50
|
||||
*/
|
||||
public static function rebateSettlement(){
|
||||
\Log::debug('--- 消费返利 - 结算到佣金 - 开始 ----');
|
||||
// 获取可以结算但是未结算的数据
|
||||
$list = self::select(['id','uid','money'])
|
||||
->where('status', 1)
|
||||
->get()
|
||||
->toArray();
|
||||
$incomeData = [];
|
||||
foreach($list as $item){
|
||||
$incomeData[] = [
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'member_id' => $item['uid'],
|
||||
'amount' => $item['money'],
|
||||
'detail' => '',
|
||||
'dividend_table_id' => $item['id'],
|
||||
'dividend_code' => IncomeService::REBATE_MONEY,
|
||||
'order_sn' => '',
|
||||
];
|
||||
}
|
||||
if(count($incomeData) > 0){
|
||||
// 添加结算信息
|
||||
IncomeService::insertIncome($incomeData);
|
||||
// 修改为已结算
|
||||
$ids = array_column($list,'id');
|
||||
self::whereIn('id',$ids)->update([
|
||||
'status' => 2
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -109,11 +109,11 @@
|
|||
</td>
|
||||
<td style="text-align:center;">第{{ $item['quarter'] }}季度第{{ $item['month'] }}个月</td>
|
||||
<td style="text-align:center;">
|
||||
{{--状态:0=冻结中,1=已解冻(可提现),2=已提现,3=已失效,4=已退款(失效)--}}
|
||||
{{--状态:0=冻结中,1=待结算,2=已结算,3=已失效,4=已退款(失效)--}}
|
||||
@switch($item['status'])
|
||||
@case(0)<span class="label label-default">冻结中</span>@break
|
||||
@case(1)<span class="label label-primary">待提现</span>@break
|
||||
@case(2)<span class="label label-success">已提现</span>@break
|
||||
@case(1)<span class="label label-primary">待结算</span>@break
|
||||
@case(2)<span class="label label-success">已结算</span>@break
|
||||
@case(3)<span class="label label-danger">已失效</span>@break
|
||||
@case(4)<span class="label label-danger">已退款</span>@break
|
||||
@endswitch
|
||||
|
|
|
|||
Loading…
Reference in New Issue