|
|
@@ -13,7 +13,8 @@ use app\common\{enum\GoodsEnum,
|
|
|
model\third\ThirdGoods,
|
|
|
model\third\ThirdOrders,
|
|
|
model\user\User,
|
|
|
- model\works\ServiceWork};
|
|
|
+ model\works\ServiceWork,
|
|
|
+ model\works\ServiceWorkLog};
|
|
|
use think\facade\Db;
|
|
|
use app\common\model\service_area\ServiceArea;
|
|
|
|
|
|
@@ -92,7 +93,8 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'productId'=>$message['productId'],
|
|
|
'productName'=>$message['productName'],
|
|
|
'request_msg'=>json_encode($order,JSON_UNESCAPED_UNICODE),
|
|
|
- 'bookStatus'=>1
|
|
|
+ 'bookStatus'=>1,
|
|
|
+ 'third_type'=>1,//美团
|
|
|
];
|
|
|
|
|
|
//判断美团的预约订单是否生成
|
|
|
@@ -114,7 +116,7 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
if(!$thirdOrders->isEmpty()){
|
|
|
$orderData['work_id'] = $thirdOrders->work_id;
|
|
|
}
|
|
|
- if(empty($orderData['work_id']) and !$product->isEmpty()){
|
|
|
+ if(empty($orderData['work_id']) and !$product->isEmpty() and !empty($product['goods_id'])){
|
|
|
$goods = Goods::findOrEmpty($product['goods_id']);
|
|
|
$pattern = '/(?:省|市)([\w\s]+市)/u';
|
|
|
Db::startTrans();
|
|
|
@@ -138,7 +140,7 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'goods_category_ids' => $goods['goods_category_ids'],
|
|
|
'goods_category_id' => $goods['goods_category_id'],
|
|
|
'base_service_fee' => $goods['base_service_fee'],
|
|
|
- 'service_fee' => $message['amount'],
|
|
|
+ 'service_fee' => $product['product_price'],
|
|
|
'work_pay_status'=>WorkEnum::IS_PAY_STATUS,
|
|
|
'appointment_time' => strtotime($message['begintime']),
|
|
|
'user_id'=>$user['id'],
|
|
|
@@ -147,10 +149,10 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'property_activity_id'=>0,
|
|
|
'user_equity_id'=>0,
|
|
|
'third_type'=>1,
|
|
|
- 'work_total'=>$goods['base_service_fee'],
|
|
|
- 'work_amount'=>$goods['base_service_fee']
|
|
|
+ 'work_total'=>$product['product_price'],
|
|
|
+ 'work_amount'=>$product['product_price']
|
|
|
];
|
|
|
- $service_area_id = ServiceArea::getAreaId(['lon' => $work_data['lon'], 'lat' => $work_data['lat']]);
|
|
|
+ $service_area_id = ServiceArea::serviceAreaId(['lon' => $work_data['lon'], 'lat' => $work_data['lat']]);
|
|
|
$work_data['service_area_id'] = $service_area_id;
|
|
|
$service_work = ServiceWork::create($work_data);
|
|
|
|
|
|
@@ -166,8 +168,8 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'coupon_id'=>0,
|
|
|
'coupon_price'=>0,
|
|
|
'pay_way' => 4,
|
|
|
- 'order_total' => $message['amount'],
|
|
|
- 'order_amount' => $message['amount'],
|
|
|
+ 'order_total' => $product['product_price'],
|
|
|
+ 'order_amount' => $product['product_price'],
|
|
|
];
|
|
|
$order = RechargeOrder::create($data);
|
|
|
//生成订单服务详情
|
|
|
@@ -189,7 +191,7 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'goods_payment_type'=>$goods['goods_payment_type'],
|
|
|
'base_service_fee' => $goods['base_service_fee'],
|
|
|
'service_total' => $goods['service_total'],
|
|
|
- 'service_fee' => $message['amount'],
|
|
|
+ 'service_fee' => $product['product_price'],
|
|
|
'service_image' => $goods['service_image'],
|
|
|
'warranty_period'=>$goods['warranty_period'],
|
|
|
'fee_schedule' => $goods['fee_schedule'],
|
|
|
@@ -197,7 +199,6 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
]);
|
|
|
|
|
|
//判断是否是一口价预支付订单,支付成功后生成尾款订单
|
|
|
- $order_goods = OrderGoods::where('sn',$order->sn)->findOrEmpty();
|
|
|
if(!$goods->isEmpty() and $goods->goods_payment_type == 3 and bcsub($goods->base_service_fee,$goods->service_fee,2)>=0){
|
|
|
//新增待支付尾款
|
|
|
$order_weikuan_data = [
|
|
|
@@ -206,8 +207,8 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'work_id'=>$order['work_id'],
|
|
|
'user_id'=>$order['user_id'],
|
|
|
'payment_type'=>2,
|
|
|
- 'order_total'=>bcsub($goods->base_service_fee,$message['amount'],2),
|
|
|
- 'order_amount'=>bcsub($goods->base_service_fee,$message['amount'],2),
|
|
|
+ 'order_total'=>bcsub($goods->base_service_fee,$product['product_price'],2),
|
|
|
+ 'order_amount'=>bcsub($goods->base_service_fee,$product['product_price'],2),
|
|
|
'order_terminal'=>$order['order_terminal']
|
|
|
];
|
|
|
\app\common\model\recharge\RechargeOrder::create($order_weikuan_data);
|
|
|
@@ -215,6 +216,8 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
|
|
|
$thirdOrders->work_id = $service_work->id;
|
|
|
$thirdOrders->save();
|
|
|
+
|
|
|
+ self::bookresultcallback($order['opBizCode'],$message['orderId'],2);
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
@@ -277,7 +280,7 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
'work_total'=>$goods['base_service_fee'],
|
|
|
'work_amount'=>$goods['base_service_fee']
|
|
|
];
|
|
|
- $service_area_id = ServiceArea::getAreaId(['lon' => $work_data['lon'], 'lat' => $work_data['lat']]);
|
|
|
+ $service_area_id = ServiceArea::serviceAreaId(['lon' => $work_data['lon'], 'lat' => $work_data['lat']]);
|
|
|
$work_data['service_area_id'] = $service_area_id;
|
|
|
$service_work = ServiceWork::create($work_data);
|
|
|
|
|
|
@@ -374,13 +377,14 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
* @param $bookStatus
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function bookresultcallback($orderId,$bookStatus=2)
|
|
|
+ public static function bookresultcallback($opBizCode,$orderId,$bookStatus=2)
|
|
|
{
|
|
|
//预订结果,2-预订成功,3-预订失败
|
|
|
$url = 'https://api-open-cater.meituan.com/ddzh/yuding/bookresultcallback';
|
|
|
+ $accessToken = $opBizCode == 'AE7MKOJAV67338LIC3UD0K5TGIO' ? self::shop_token2['accessToken'] : self::shop_token1['accessToken'];
|
|
|
$data = [
|
|
|
'timestamp'=>time(),
|
|
|
- 'appAuthToken'=>self::shop_token2['accessToken'],
|
|
|
+ 'appAuthToken'=>$accessToken,
|
|
|
'charset'=>'utf-8',
|
|
|
'version'=>'2',
|
|
|
'developerId'=>self::developerId,
|
|
|
@@ -397,4 +401,97 @@ class ThirdOrderLogic extends BaseLogic
|
|
|
return http_request($url,http_build_query($data));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 取消预订
|
|
|
+ * @param array
|
|
|
+ * $order
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public static function cancelOrderHandle(array $order)
|
|
|
+ {
|
|
|
+ $message = json_decode($order['message'], true);
|
|
|
+ $thirdOrders = ThirdOrders::where('orderId',$message['orderId'])->findOrEmpty();
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ // 04-11-12 不做任何限制强制取消,已支付的费用给工程师余额
|
|
|
+ $serviceWorkInfo = ServiceWork::find($thirdOrders->work_id);
|
|
|
+
|
|
|
+ ServiceWork::where('id', $thirdOrders->work_id)->update([
|
|
|
+ //'work_status' => 9,
|
|
|
+ 'service_status' => 4,
|
|
|
+ 'remark' => '美团取消预约订单'
|
|
|
+ ]);
|
|
|
+
|
|
|
+ ServiceWorkLog::create([
|
|
|
+ 'work_id' => $thirdOrders->work_id,
|
|
|
+ 'master_worker_id' => $serviceWorkInfo['master_worker_id'],
|
|
|
+ 'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消"
|
|
|
+ ]);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ self::setError($e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取美团商品信息
|
|
|
+ * @param $offset
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public static function queryshopdeal($offset=1)
|
|
|
+ {
|
|
|
+ $url = 'https://api-open-cater.meituan.com/ddzh/tuangou/deal/queryshopdeal';
|
|
|
+ $data = [
|
|
|
+ 'timestamp'=>time(),
|
|
|
+ 'appAuthToken'=>self::shop_token2['accessToken'],
|
|
|
+ 'charset'=>'utf-8',
|
|
|
+ 'version'=>'2',
|
|
|
+ 'developerId'=>self::developerId,
|
|
|
+ 'businessId'=>58,
|
|
|
+ 'biz'=>json_encode([
|
|
|
+ 'offset'=>$offset,
|
|
|
+ 'limit'=>100,
|
|
|
+ "source"=>2,
|
|
|
+ ],JSON_UNESCAPED_UNICODE)
|
|
|
+ ];
|
|
|
+ $sign_data = self::get_sign(self::assessKey, $data);
|
|
|
+ $data['sign'] = $sign_data;
|
|
|
+ return http_request($url,http_build_query($data));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商家改约
|
|
|
+ * @param $offset
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public static function merchantmodify($data)
|
|
|
+ {
|
|
|
+ $url = 'https://api-open-cater.meituan.com/ddzh/yuding/lifereserve/merchantmodify';
|
|
|
+ $opBizCode = !empty($data['request_msg'])?json_decode($data['request_msg'],true)['opBizCode']:'';
|
|
|
+ $accessToken = $opBizCode == 'AE7MKOJAV67338LIC3UD0K5TGIO' ? self::shop_token2['accessToken'] : self::shop_token1['accessToken'];
|
|
|
+ $data = [
|
|
|
+ 'timestamp'=>time(),
|
|
|
+ 'appAuthToken'=>$accessToken,
|
|
|
+ 'charset'=>'utf-8',
|
|
|
+ 'version'=>'2',
|
|
|
+ 'developerId'=>self::developerId,
|
|
|
+ 'businessId'=>58,
|
|
|
+ 'biz'=>json_encode([
|
|
|
+ 'reserveOrderId'=>$data['reserveOrderId'],
|
|
|
+ 'reserveUserName'=>$data['reserveUserName'],
|
|
|
+ "reservePhone"=>$data['reservePhone'],
|
|
|
+ "reserveAddress"=>$data['reserveAddress'],
|
|
|
+ "bookStartTime"=>$data['bookStartTime'],
|
|
|
+ "bookEndTime"=>$data['bookEndTime'],
|
|
|
+ ],JSON_UNESCAPED_UNICODE)
|
|
|
+ ];
|
|
|
+ $sign_data = self::get_sign(self::assessKey, $data);
|
|
|
+ $data['sign'] = $sign_data;
|
|
|
+ return http_request($url,http_build_query($data));
|
|
|
+ }
|
|
|
+
|
|
|
}
|