Merge pull request 'mkm-2' (#37) from mkm-2 into master

Reviewed-on: #37
This commit is contained in:
mkm 2023-09-08 21:32:28 +08:00
commit 5d843aaf2d
4 changed files with 40 additions and 25 deletions

View File

@ -12,17 +12,12 @@ class RemoteController extends BaseApiController
public array $notNeedLogin = ['index']; public array $notNeedLogin = ['index'];
public function shang_date_total_price($company,$isDay=1,$arr=[],$template_id=0) public function shang_date_total_price($company,$arr=[],$template_id=0)
{ {
if($isDay==1){ $start_time = date('Y-m-d');
$start_time = date('Y-m-d'); $time=strtotime($start_time)+86399;
$time=strtotime($start_time)+86399; $end_time=date('Y-m-d H:i:s',$time);
$end_time=date('Y-m-d H:i:s',$time);
}else{
$start_time = date('Y-m-d',strtotime('-1 day', time()));
$time=strtotime($start_time)+86399;
$end_time=date('Y-m-d H:i:s',$time);
}
if(isset($arr['start_time']) && $arr['end_time']){ if(isset($arr['start_time']) && $arr['end_time']){
$start_time = $arr['start_time']; $start_time = $arr['start_time'];
$end_time = $arr['end_time']; $end_time = $arr['end_time'];

View File

@ -45,7 +45,6 @@ class TaskController extends BaseApiController
$param['end_time']=date('Y-m-d H:i:s',$end); $param['end_time']=date('Y-m-d H:i:s',$end);
$where[] = ['start_time', 'between', [$time, $end]]; $where[] = ['start_time', 'between', [$time, $end]];
} }
} }
if (isset($param['status']) && $param['status'] > 0) { if (isset($param['status']) && $param['status'] > 0) {
$where[] = ['status', '=', $param['status']]; $where[] = ['status', '=', $param['status']];
@ -58,16 +57,18 @@ class TaskController extends BaseApiController
foreach ($res as $k => $item) { foreach ($res as $k => $item) {
if ($item['type'] == 33) { if ($item['type'] == 33) {
$company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足 $company = Company::where('id', $item['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade,responsible_area')->find(); // 可能要判断预存金是否满足
$find = App(RemoteController::class)->shang_date_total_price($company,1,$param,$item['template_id']); $find = App(RemoteController::class)->shang_date_total_price($company,$param,$item['template_id']);
if ($find != false) { if ($find != false) {
$transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool'); if($time<time()){
if($transaction_pool==0){ $transaction_pool=TaskTemplate::where('id',$item['template_id'])->value('transaction_pool');
$find['transaction_pool']=0; if($transaction_pool==0){
}else{ $find['transaction_pool']=0;
$find['transaction_pool']=$transaction_pool; }else{
$find['transaction_pool']=$transaction_pool;
}
$res[$k]['extend']['transaction'] = $find;
} }
$res[$k]['extend']['transaction'] = $find; // Task::where('id',$item['id'])->update(['extend'=>json_encode(['transaction'=>$find],true)]);
Task::where('id',$item['id'])->update(['extend'=>json_encode(['transaction'=>$find],true)]);
} else { } else {
$res[$k]['extend']['transaction'] = ''; $res[$k]['extend']['transaction'] = '';
} }

View File

@ -16,14 +16,16 @@ namespace app\api\lists;
use app\common\enum\user\AccountLogEnum; use app\common\enum\user\AccountLogEnum;
use app\common\model\user\UserAccountLog; use app\common\model\user\UserAccountLog;
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Sum;
use app\common\lists\ListsExtendInterface;
use app\common\lists\ListsSearchInterface;
/** /**
* 账户流水列表 * 账户流水列表
* Class AccountLogLists * Class AccountLogLists
* @package app\shopapi\lists * @package app\shopapi\lists
*/ */
class AccountLogLists extends BaseApiDataLists class AccountLogLists extends BaseApiDataLists implements ListsExtendInterface
{ {
/** /**
@ -79,16 +81,20 @@ class AccountLogLists extends BaseApiDataLists
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->select() ->select()
->toArray(); ->toArray();
foreach ($lists as &$item) { foreach ($lists as &$item) {
$item['type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']); $item['type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']);
$symbol = $item['action'] == AccountLogEnum::DEC ? '-' : '+'; $symbol = $item['action'] == AccountLogEnum::DEC ? '-' : '+';
$item['change_amount_desc'] = $symbol . $item['change_amount']; $item['change_amount_desc'] = $symbol . $item['change_amount'];
} }
return $lists; return $lists;
} }
public function extend(){
$deposit=UserAccountLog::where($this->queryWhere())->where('change_type',203)->sum('change_amount');
$user_money=UserAccountLog::where($this->queryWhere())->where('change_type',202)->sum('change_amount');
return ['deposit'=>$deposit,'user_money'=>$user_money];
}
/** /**
* @notes 获取数量 * @notes 获取数量

View File

@ -55,14 +55,20 @@ class TaskInformationJob
if($shang_date_total_price['arr']['total_price']>$shang_date_total_price['arr']['day_money']){ if($shang_date_total_price['arr']['total_price']>$shang_date_total_price['arr']['day_money']){
$day_money=bcsub($shang_date_total_price['arr']['total_price'],$shang_date_total_price['arr']['day_money'],2);//当天还剩多少 $day_money=bcsub($shang_date_total_price['arr']['total_price'],$shang_date_total_price['arr']['day_money'],2);//当天还剩多少
$shang_date_total_price['arr']['supplement']=$day_money; $shang_date_total_price['arr']['supplement']=$day_money;
$transaction_pool=bcadd($transaction_pool,$day_money,2);
}else{ }else{
$shang_date_total_price['arr']['supplement']=0; $shang_date_total_price['arr']['supplement']=0;
$shang_date_total_price['arr']['after_transaction_pool']=0; $shang_date_total_price['arr']['after_transaction_pool']=0;
$day_money=0; $day_money=0;
$transaction_pool=bcadd($transaction_pool,$shang_date_total_price['arr']['total_price'],2);
$transaction_pool=bcsub($transaction_pool,$shang_date_total_price['arr']['day_money'],2);
if($transaction_pool<0){
$transaction_pool=0;
}
} }
$shang_date_total_price['arr']['before_transaction_pool']=$day_money; $shang_date_total_price['arr']['before_transaction_pool']=$day_money;
Task::where('id', $data['task_id'])->update(['status' => 3,'extend'=>json_encode($shang_date_total_price)]); Task::where('id', $data['task_id'])->update(['status' => 3,'extend'=>json_encode($shang_date_total_price)]);
TaskTemplate::where('id',$data['template_info']['id'])->update(['transaction_pool'=>bcadd($transaction_pool,$day_money,2)]); TaskTemplate::where('id',$data['template_info']['id'])->update(['transaction_pool'=>$transaction_pool]);
$shang_date_total_price['arr']['status']=1; $shang_date_total_price['arr']['status']=1;
} }
$name = $shang_date_total_price['name']; $name = $shang_date_total_price['name'];
@ -94,7 +100,14 @@ class TaskInformationJob
$arr['company_account_type'] = 2; $arr['company_account_type'] = 2;
}else{ }else{
if($data['template_info']['day_count']<=$day){ if($data['template_info']['day_count']<=$day){
Task::where('id', $data['task_id'])->update(['create_time' => $task_35['start_time']+86400,'update_time' =>time(),'start_time'=>$task_35['start_time']+86400,'end_time'=> strtotime($task_35['end_time']) + 86400]);
try{
Task::where('id', $data['task_id'])->update(['create_time' => $task_35['start_time']+86400,'update_time' =>time(),'start_time'=>$task_35['start_time']+86400,'end_time'=>$task_35['start_time']+86400+86399]);
}catch(\Exception $e){
$start_time = strtotime(date('Y-m-d'));
Task::where('id', $data['task_id'])->update(['create_time' => $start_time+86400,'update_time' =>time(),'start_time'=>$start_time+86400,'end_time'=> $start_time + 86400+86399]);
}
return false; return false;
} }
if($data['template_info']['day_count']>$day){ if($data['template_info']['day_count']>$day){