|
|
|
@ -13,8 +13,13 @@ |
|
|
|
|
|
|
|
|
|
namespace app\common\repositories\user; |
|
|
|
|
|
|
|
|
|
use app\common\model\user\UserPartner; |
|
|
|
|
use app\common\repositories\BaseRepository; |
|
|
|
|
use app\common\dao\user\UserPartnerDao as dao; |
|
|
|
|
use app\common\dao\system\admin\PartnerDao; |
|
|
|
|
use FormBuilder\Factory\Elm; |
|
|
|
|
use think\facade\Db; |
|
|
|
|
use think\facade\Route; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Class UserAddressRepository |
|
|
|
@ -64,4 +69,29 @@ class UserPartnerRepository extends BaseRepository |
|
|
|
|
$list = $this->dao->getAll($uid)->order('id desc')->select(); |
|
|
|
|
return compact('list'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function changePartnerForm($uid) |
|
|
|
|
{ |
|
|
|
|
/** @var UserLabelRepository $make */ |
|
|
|
|
$list = $this->dao->getAll($uid)->column('partner_id'); |
|
|
|
|
$partnerForm = new PartnerDao(); |
|
|
|
|
$option = $partnerForm->getAll(); |
|
|
|
|
return compact('list', 'option'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function editPartner(int $uid, array $partner_id = []) |
|
|
|
|
{ |
|
|
|
|
return Db::transaction(function () use ($uid, $partner_id) { |
|
|
|
|
//先清空 |
|
|
|
|
UserPartner::getInstance()->where('uid', $uid)->delete(); |
|
|
|
|
//再插入 |
|
|
|
|
if (!empty($partner_id)) { |
|
|
|
|
$data = []; |
|
|
|
|
foreach ($partner_id as $k => $v) { |
|
|
|
|
$data[] = ['uid' => $uid, 'partner_id' => $v,'create_time' => date("Y-m-d H:i:s")]; |
|
|
|
|
} |
|
|
|
|
UserPartner::getInstance()->insertAll($data); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|