diff --git a/app/controller/manager/Business.php b/app/controller/manager/Business.php index d7f2d66..d7f3bd0 100644 --- a/app/controller/manager/Business.php +++ b/app/controller/manager/Business.php @@ -12,6 +12,7 @@ use app\model\Member; use app\model\BusinessCircle as BusinessCircleModel ; use app\repository\AccountRepository; use app\repository\BusinessRepository; +use app\repository\CouponRepository; use app\repository\RechargeRepository; use app\service\wx\WechatPay; use Endroid\QrCode\Builder\Builder; @@ -228,7 +229,7 @@ class Business extends Base 'type|分类' => 'require|number', //'characteristic|特色' => 'max:100', // 'intro|介绍' => 'require', -// 'business_circle_id|商圈' => 'require', + 'business_circle_id|商圈' => 'require', 'background|背景图' => 'require', 'model|商家模式' => 'require', //'score|评分' => 'require|in:1,2,3,4,5', @@ -246,6 +247,11 @@ class Business extends Base Db::startTrans(); try { $business->save($item); + //修改所属的签到券 + CouponRepository::getInstance()->updateCouponMainByBusinessCode($business["code"],[ + "business_circle_id"=>$item["business_circle_id"], + "business_type"=>$item["type"], + ]); Db::commit(); return $this->json(); } catch (ValidateException $e) { diff --git a/app/repository/CouponRepository.php b/app/repository/CouponRepository.php index 0497927..96964e5 100644 --- a/app/repository/CouponRepository.php +++ b/app/repository/CouponRepository.php @@ -110,4 +110,15 @@ class CouponRepository extends Repository { return Coupon::create($data); } + /** + * 根据商家id修改优惠券 + * @param array $data + * @return Coupon|Model + */ + public function updateCouponMainByBusinessCode(int $businessCode,array $data) + { + return CouponMain::where("business_code",$businessCode)->update($data); + } + + } \ No newline at end of file