更新委托天数

This commit is contained in:
yaooo 2023-09-09 17:51:29 +08:00
parent 331623ebc9
commit 737d18702f

View File

@ -303,6 +303,9 @@ class Community extends BaseController
if ($merchantInfo['credit_buy'] && ($data['entrust_day'] < $merchantInfo['settle_cycle'])) {
throw new ValidateException('委托天数不能小于结算周期');
}
if (!$merchantInfo['credit_buy'] && ($data['entrust_day'] < 15 || $data['entrust_day'] > 90)) {
throw new ValidateException('委托天数区间范围[15-90]天');
}
}
$data['content'] = filter_emoji($data['content']);
@ -878,9 +881,10 @@ class Community extends BaseController
return app('json')->fail('当前商户无申请结束此委托商品权限');
}
$entrustInfo = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->find();
$limitTime = strtotime($communityInfo['entrust_start_date']) + ($entrustInfo['entrust_day'] ?? 0) * 86400;
//委托周期截止5天内可申请结束委托
$limitTime = strtotime($communityInfo['entrust_start_date']) + ($entrustInfo['entrust_day'] ?? 0) * 86400 - 5 * 86400;
if (time() < $limitTime) {
return app('json')->fail('委托时间内不能申请结束委托');
return app('json')->fail('委托周期截止5天内可申请结束委托');
}
$res = Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['entrust_finish' => 3]);
if (!$res) {
@ -909,9 +913,10 @@ class Community extends BaseController
// 同意
if ($status == 1) {
$entrustInfo = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->find();
$limitTime = strtotime($communityInfo['entrust_start_date']) + ($entrustInfo['entrust_day'] ?? 0) * 86400;
//委托周期截止5天内可申请结束委托
$limitTime = strtotime($communityInfo['entrust_start_date']) + ($entrustInfo['entrust_day'] ?? 0) * 86400 - 5 * 86400;
if (time() < $limitTime) {
return app('json')->fail('委托时间内不能结束委托');
return app('json')->fail('委托周期截止5天内可申请结束委托');
}
// 分润
$res = Db::name('community')->where('community_id', $id)->where('is_del', 0)->update(['entrust_finish' => 1]);