更新商户交易申请判断

This commit is contained in:
yaooo 2023-09-19 10:29:15 +08:00
parent a96a958f7e
commit fa00a574e5

View File

@ -107,7 +107,10 @@ class MerchantIntention extends BaseController
}
if ($this->userInfo) $data['uid'] = $this->userInfo->uid;
$merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find();
$intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->find();
if (!empty($merInfo['business_status']) && ($merInfo['business_status']==2)) {
return app('json')->fail('商户交易申请已通过');
}
$intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->where('type', 1)->find();
if (empty($intenInfo)) {
return app('json')->fail('商户状态异常');
}
@ -133,6 +136,14 @@ class MerchantIntention extends BaseController
throw new ValidateException('商户交易申请失败,请联系平台');
}
Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]);
$intenInfoArray = $intenInfo->toArray();
$intenInfoArray['type'] = 1;
$bussIntention = Db::name('merchant_intention')->where('mer_intention_id', $intenInfo['mer_intention_id'])->where('type', 2)->find();
if ($bussIntention) {
Db::name('merchant_intention')->where('mer_intention_id', $intenInfo['mer_intention_id'])->where('type', 2)->update($intenInfoArray);
}else {
Db::name('merchant_intention')->insert($intenInfoArray);
}
return app('json')->success('申请成功');
}