settter
parent
cd5ea3d614
commit
a3ddaa012a
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace app\controller\api;
|
||||
|
||||
use app\repository\DictionaryRepository;
|
||||
use think\facade\Db;
|
||||
use app\model\Area as AreaModel;
|
||||
/**
|
||||
|
@ -13,7 +14,7 @@ use app\model\Area as AreaModel;
|
|||
class Area extends Base
|
||||
{
|
||||
protected $noNeedLogin = [
|
||||
'index',
|
||||
'index',"getProvinceDictionaryCity"
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -25,4 +26,50 @@ class Area extends Base
|
|||
$filter = input("filter",false);
|
||||
return json(AreaModel::getByPCode($pcode,$filter));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取
|
||||
* */
|
||||
public function getProvinceDictionaryCity()
|
||||
{
|
||||
$province = AreaModel::getByPCode(86,true);
|
||||
$provinceCode = array_column($province->toArray(),null,"code");
|
||||
$provinceCodeArray = array_keys($provinceCode);
|
||||
|
||||
$city = AreaModel::getByPCodes($provinceCodeArray,true);
|
||||
$city = array_column($city,null,"code");
|
||||
|
||||
|
||||
$items = DictionaryRepository::getInstance()->getAllBusinessCircleList();
|
||||
$items->each(function ($item)use($city) {
|
||||
$areaText = '';
|
||||
if (!empty($item['province_text'])) {
|
||||
$areaText = $item['province_text'].'·';
|
||||
}
|
||||
if (!empty($item['city_text']) && $item['city_text'] != '市辖区') {
|
||||
$areaText .= $item['city_text'].'·';
|
||||
}
|
||||
if (!empty($item['county_text'])) {
|
||||
$areaText .= $item['county_text'];
|
||||
}
|
||||
|
||||
$item['name_text'] = $item['name'];
|
||||
if (!empty($areaText)) {
|
||||
$item['name_text'] = $item['name'] . '「'.$areaText.'」';
|
||||
}
|
||||
return $item;
|
||||
});
|
||||
foreach ($items->toArray() as $item){
|
||||
if(isset($city[$item["city"]])){
|
||||
$city[$item["city"]]["children"][]=$item;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($city as $item){
|
||||
if (isset($provinceCode[$item["pcode"]])){
|
||||
$provinceCode[$item["pcode"]]["children"][] =$item;
|
||||
}
|
||||
}
|
||||
return $this->json(0,"success",$provinceCode);
|
||||
}
|
||||
}
|
|
@ -366,6 +366,7 @@ class Business extends Base
|
|||
|
||||
$data["businessAddress"] = $list['province_text'] . $list['city_text'] . $list['county_text'] . $business['business_address'];
|
||||
$data["businessName"] = $list['business_name'];
|
||||
$data["businessSubtitle"] = $business['business_subtitle'];
|
||||
$data["count"] = $couponMain->count;
|
||||
$data["couponName"] = $couponMain->name;
|
||||
$data["deductionMoney"] = $couponMain->deduction_money;
|
||||
|
|
|
@ -776,7 +776,9 @@ class Coupon extends Base
|
|||
{
|
||||
$couponMainId = input("couponMainId/d");
|
||||
$couponMain = CouponMain::findById($couponMainId,[],function ($q){
|
||||
return $q->with("usingRule");
|
||||
return $q->with(["usingRule","business"=>function($q){
|
||||
$q->field("code,business_subtitle");
|
||||
}]);
|
||||
});
|
||||
if(empty($couponMain)){
|
||||
return $this->json(4001,"优惠券不存在");
|
||||
|
|
|
@ -310,7 +310,6 @@ class Coupon extends Base
|
|||
}
|
||||
|
||||
$business = BusinessRepository::getInstance()->getBusinessAccount($data["business_code"], true);
|
||||
|
||||
if (empty($business)) {
|
||||
return $this->json(4001, '商家不存在');
|
||||
}
|
||||
|
|
|
@ -21,8 +21,30 @@ class Area extends Base
|
|||
{
|
||||
return self::where("pcode",$PCode)->when($filter,function ($q){
|
||||
$q->where("status",self::COMMON_ON);
|
||||
})->order("id asc")->select();
|
||||
})
|
||||
->field("id,code,pcode,name,status")
|
||||
->order("id asc")->select();
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param $PCode
|
||||
* @param $filter bool 是否过滤屏蔽的地区
|
||||
* @return Area[]|array|\think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function getByPCodes($PCodes,bool $filter = false)
|
||||
{
|
||||
return self::where("pcode","in",$PCodes) ->when($filter,function ($q){
|
||||
$q->where("status",self::COMMON_ON);
|
||||
})
|
||||
->field("id,code,pcode,name,status")
|
||||
->order("id asc")
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取列表
|
||||
|
|
|
@ -157,13 +157,13 @@ class BusinessRepository extends Repository
|
|||
*/
|
||||
public function getBusinessAccount($businessCode, bool $lock = false)
|
||||
{
|
||||
$Flow = Business::with(["account"])->where("code", $businessCode)->when($lock, function ($q) {
|
||||
$business = Business::where("code", $businessCode)->when($lock, function ($q) {
|
||||
$q->lock(true);
|
||||
})->find();
|
||||
if (empty($Flow) || empty($Flow->account)) {
|
||||
if (empty($business)) {
|
||||
return null;
|
||||
}
|
||||
return $Flow;
|
||||
return $business;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue