|
|
@@ -24,6 +24,7 @@ use app\common\model\orders\RechargeOrder;
|
|
|
use app\common\model\property\PropertyActivity;
|
|
|
use app\common\model\recharge\OrderGoods;
|
|
|
use app\common\model\refund\RefundRecord;
|
|
|
+use app\common\model\service_area\ServiceArea;
|
|
|
use app\common\model\spare_part\SparePart;
|
|
|
use app\common\model\works\ServiceWork;
|
|
|
use app\common\model\works\ServiceWorkAppointmentLog;
|
|
|
@@ -43,25 +44,26 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
- * 判断是否在某服务区
|
|
|
+ * 判断是否在某服务区 返回服务区城市信息
|
|
|
* @param $params
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public static function isService($params)
|
|
|
+ public static function isService($params):array
|
|
|
{
|
|
|
// 查询服务区所有的地点
|
|
|
- $rules = MasterWorkerRule::where('scene_id',MasterWorkerRule::SCENE_SERVICE)->column('description','id');
|
|
|
- //$masters = [];
|
|
|
- foreach ($rules as $key=>$value){
|
|
|
- $rule = explode(',',$value);
|
|
|
- //$masters[] = ['id'=>$key,'lon'=>$rule[0],'lat'=>$rule[1],'radius'=>$rule[2]];
|
|
|
- $distance = round(DistributeLeafletsService::haversineDistance($params['lat'], $params['lon'], $rule[1], $rule[0]), 2);
|
|
|
- if($distance <= (float)$rule[2]){
|
|
|
- return true;
|
|
|
+ $rules = ServiceArea::column('*','id');
|
|
|
+ foreach ($rules as $value){
|
|
|
+ $distance = round(DistributeLeafletsService::haversineDistance($params['lat'], $params['lon'], $value['lat'], $value['lon']), 2);
|
|
|
+ if($distance <= (float)$value['distance']){
|
|
|
+ return [
|
|
|
+ 'province'=>$value['province'],
|
|
|
+ 'city'=>$value['city'],
|
|
|
+ 'county'=>$value['county'],
|
|
|
+ 'area_name'=>$value['area_name']
|
|
|
+ ];
|
|
|
}
|
|
|
}
|
|
|
- self::setError('已超出服务区域!');
|
|
|
- return false;
|
|
|
+ throw new Exception('已超出服务区域!');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -74,9 +76,7 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
// 订单位置是否在服务区内
|
|
|
- if(!self::isService($params)){
|
|
|
- throw new Exception('已超出服务区域!');
|
|
|
- }
|
|
|
+ $areas = self::isService($params);
|
|
|
$goods = Goods::findOrEmpty($params['goods_id']);
|
|
|
if($goods->isEmpty()){
|
|
|
throw new Exception('产品不存在!');
|
|
|
@@ -141,6 +141,11 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
'real_name' => $params['contact_people'],
|
|
|
'mobile' => $params['contact_number'],
|
|
|
'address' => $params['address'],
|
|
|
+
|
|
|
+ 'province' => $areas['province']??0,
|
|
|
+ 'city' => $areas['city']??0,
|
|
|
+ 'area_name' => $areas['area_name']??'',
|
|
|
+
|
|
|
'title' => $goods->goods_name,
|
|
|
'category_type' => $goods['category_type'],
|
|
|
'goods_category_ids' => $goods['goods_category_ids'],
|