store ufutx customer

This commit is contained in:
Hankin 2026-04-09 13:52:20 +08:00
parent 9630a069f2
commit f550a4a539
8 changed files with 1207 additions and 837 deletions

View File

@ -10,6 +10,8 @@ use App\Jobs\SendTemplateMsg;
use App\Jobs\SyncClientComment;
use App\Models\ConsultAccount;
use App\Models\Course\CourseVideo;
use App\Models\Dma\DmaServiceUserRole;
use App\Models\Dma\S2Customer;
use App\Models\SaasReservationConsultScheduling;
use App\Models\Server\MerchantApplyment;
use App\Models\Server\MerchantEvaluate;
@ -17,7 +19,9 @@ use App\Models\Server\SaasMemberBuyInfo;
use App\Models\Server\SaasMemberLevel;
use App\Models\Server\SaasMemberUser;
use App\Models\Server\ShopAgentOrder;
use App\Models\Wechat;
use App\Services\EvaluateService;
use App\Services\OrderService;
use App\Services\SaasVipGainService;
use App\Services\SaasVipNoticeService;
use App\Services\SaasVipSpreadEarningService;
@ -126,9 +130,11 @@ class OrderController extends Controller
} else {
throw new \Exception("订单检查失败", 1);
}
if (empty($result)) return $this->failure('订单检查失败');
if (empty($result))
return $this->failure('订单检查失败');
$result = $this->markOrder($order, $pay_order);
if (empty($result)) return $this->failure('分类回调订单失败');
if (empty($result))
return $this->failure('分类回调订单失败');
} else {
throw new \Exception("订单时间超过30天", 1);
}
@ -176,7 +182,8 @@ class OrderController extends Controller
// 给嘉宾编号
if ($order->account_id) {
$remark = $this->numMember($order);
if($remark) TouristOrder::where('trade_no', $order->trade_no)->update(['remark'=>$remark]);
if ($remark)
TouristOrder::where('trade_no', $order->trade_no)->update(['remark' => $remark]);
}
} elseif ($order->pay_type === 'alipay') {
//todo 支付宝查询订单
@ -184,9 +191,11 @@ class OrderController extends Controller
} else {
throw new \Exception("订单检查失败", 1);
}
if (empty($result)) throw new \Exception("微信端没有订单 订单未支付成功", 1);
if (empty($result))
throw new \Exception("微信端没有订单 订单未支付成功", 1);
if (empty($result)) throw new \Exception("订单回调失败 订单未支付成功", 1);
if (empty($result))
throw new \Exception("订单回调失败 订单未支付成功", 1);
} else {
throw new \Exception("订单时间超过30天", 1);
}
@ -221,7 +230,8 @@ class OrderController extends Controller
//会员订单
if ($order->type === 'rank') {
$result = $this->markRankOrder($order, $pay_order);
if (empty($result)) throw new \Exception("回调会员订单失败", 1);
if (empty($result))
throw new \Exception("回调会员订单失败", 1);
} elseif ($order->type === 'activity') {
$PayLog = new PayLog;
$PayLog->type = 'activity';
@ -230,19 +240,24 @@ class OrderController extends Controller
$PayLog->remark = '回调活动监听';
$PayLog->save();
$result = $this->markActivityOrder($order, $pay_order);
if (empty($result)) throw new \Exception("回调活动订单失败", 1);
if (empty($result))
throw new \Exception("回调活动订单失败", 1);
} elseif ($order->type === 'community') {
$result = $this->markCommunityOrder($order, $pay_order);
if (empty($result)) throw new \Exception("回调社群订单失败", 1);
if (empty($result))
throw new \Exception("回调社群订单失败", 1);
} elseif ($order->type === 'single_service') {
$result = $this->markSingleServiceOrder($order, $pay_order);
if (empty($result)) throw new \Exception("回调单身服务订单失败", 1);
if (empty($result))
throw new \Exception("回调单身服务订单失败", 1);
} elseif ($order->type === 'coin') {//福币充值订单
$result = $this->markCoinOrder($order, $pay_order);
if (empty($result)) throw new \Exception("回调福币充值订单失败,订单号:".$order->trade_no, 1);
if (empty($result))
throw new \Exception("回调福币充值订单失败,订单号:" . $order->trade_no, 1);
} elseif ($order->type === 'course') {//购买课程
$result = $this->markCourses($order, $pay_order);
if (empty($result)) throw new \Exception("回调购买课程订单失败", 1);
if (empty($result))
throw new \Exception("回调购买课程订单失败", 1);
}
\DB::beginTransaction();
PayOrder::where('trade_no', $order->trade_no)->update(['is_hooked' => 1, 'pay_status' => 'PAID']);
@ -267,15 +282,18 @@ class OrderController extends Controller
{
try {
$ratio_coin = RatioCoin::where('id', $order->type_id)->first();
if (empty($ratio_coin)) throw new \Exception("福币比例不存在", 1);
if (empty($ratio_coin))
throw new \Exception("福币比例不存在", 1);
$user = User::find($order->user_id);
if (empty($user)) throw new \Exception("订单用户不存在", 1);
if (empty($user))
throw new \Exception("订单用户不存在", 1);
\DB::beginTransaction();
//增加福币充值记录
$coin = $order->pay_type == 'ios' ? $ratio_coin->ios_coin : $ratio_coin->coin;
$result = $user->addCoinLog('RECHARGE', $order->type_id, $coin);
if (empty($result)) throw new \Exception("增加福币记录失败", 1);
if (empty($result))
throw new \Exception("增加福币记录失败", 1);
//增加福币余额
$result = $user->updateCoinInfo('add', $coin);
\DB::commit();
@ -365,10 +383,12 @@ class OrderController extends Controller
if ($result->pay_type == "partner") {
$applyment = MerchantApplyment::where('m_id', $result->merchant_id)->first();
$pay_result = \WechatService::partnerOrderPaid($trade_no, $applyment->sub_mch_id);
if (empty($pay_result) || $pay_result->trade_state != "SUCCESS") return $this->failure("支付回调失败");
if (empty($pay_result) || $pay_result->trade_state != "SUCCESS")
return $this->failure("支付回调失败");
} else {
$pay_result = \WechatService::orderPaid($trade_no);
if (empty($pay_result)) return $this->failure("支付回调失败");
if (empty($pay_result))
return $this->failure("支付回调失败");
}
$merchant = MerchantAccount::where('id', $result->merchant_id)->first();
$merchant_openid = $merchant->openid ?? '';
@ -392,8 +412,10 @@ class OrderController extends Controller
//发送通知
//判断是服务还是活动
$res = CommunityActivity::where('id', $result->type_id)->first();
if($res->class == 'one') $class = 'activity';
if($res->class == 'many') $class = 'service';
if ($res->class == 'one')
$class = 'activity';
if ($res->class == 'many')
$class = 'service';
$merchant_openid = $merchant->openid ?? '';
//多人报名增加手动签到
if ($result->linkmen && count(json_decode($result->linkmen, true)) >= 1) {
@ -412,6 +434,10 @@ class OrderController extends Controller
$channel_openid = MerchantUser::where('id', $bind_m_user_id)->value('openid');
}
}
// 友福活动将被邀请人添加到客户
$orderService = new OrderService();
$orderService->storeUftxCustomer($result);
}
if ($result->price > 0 && $result->type == 'course') {//课程回调
$PayLog->type = 'course';
@ -457,7 +483,8 @@ class OrderController extends Controller
$member_user->expire_time = $member_user_expire;
} else {
$member_user->expire_time = Carbon::now()->addYear($level->level_years)
->addMonths($level->level_month)->toDateTimeString();;
->addMonths($level->level_month)->toDateTimeString();
;
}
$member_user->save();
} else {
@ -606,7 +633,11 @@ class OrderController extends Controller
if ($result->merchant_id == 491) {
//给客服脱单姐 管理员
$openids = [
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs", "oPC_2vudkf3stdiNgjA-e2n6t9_M","oPC_2vtrwOLgWHLwVEFTFsJ7N7fw","oPC_2vt7nGwKk_OFzJL70SlVuTiU","oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs",
"oPC_2vudkf3stdiNgjA-e2n6t9_M",
"oPC_2vtrwOLgWHLwVEFTFsJ7N7fw",
"oPC_2vt7nGwKk_OFzJL70SlVuTiU",
"oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"
];
foreach ($openids as $openid) {
@ -710,6 +741,8 @@ class OrderController extends Controller
}
}
public function wechatWorkNotice($order)
{
$header = "2024开年餐宴·早鸟票\r\n";
@ -718,10 +751,10 @@ class OrderController extends Controller
$orders = TouristOrder::whereIn("pay_status", [1, 4])->where("type", $order->type)->where('type_id', $order->type_id)
->where('id', '<=', $order->id)->orderByDesc('id')->limit(3)->get();
$count = TouristOrder::whereIn("pay_status", [1, 4])->where("type", $order->type)->where('type_id', $order->type_id)->where('id', '<=', $order->id)->count();
if (empty($orders)) return ;
if (empty($orders))
return;
$index = 0;
foreach ($orders as $order)
{
foreach ($orders as $order) {
$linkmen = json_decode($order->linkmen, true);
$linkmen_num = $linkmen ? count($linkmen) : 0;
$num = $count - $index;
@ -747,7 +780,8 @@ class OrderController extends Controller
$response = \App\Utils\Http::post($url, json_encode($send_data));
}
public function getGroupParams($order,$group,$deadline,$status = 0){
public function getGroupParams($order, $group, $deadline, $status = 0)
{
$history_id = CollageGroupHistories::where('m_order_id', $order->id)->value('id');
$param['openid'] = $order->open_id;
$param['order_id'] = $order->id;
@ -766,7 +800,8 @@ class OrderController extends Controller
}
//拼团订单回调
public function groupOrder(Request $request,$trade_no){
public function groupOrder(Request $request, $trade_no)
{
if (empty($trade_no)) {
return $this->failure('没有回调订单号');
}
@ -793,10 +828,12 @@ class OrderController extends Controller
if ($result->pay_type == "partner") {
$applyment = MerchantApplyment::where('m_id', $result->merchant_id)->first();
$pay_result = \WechatService::partnerOrderPaid($trade_no, $applyment->sub_mch_id);
if (empty($pay_result) || $pay_result->trade_state != "SUCCESS") return $this->failure("支付回调失败");
if (empty($pay_result) || $pay_result->trade_state != "SUCCESS")
return $this->failure("支付回调失败");
} else {
$pay_result = \WechatService::orderPaid($trade_no);
if (empty($pay_result)) return $this->failure("支付回调失败");
if (empty($pay_result))
return $this->failure("支付回调失败");
}
$log->remark = '订单回调成功';
$log->save();
@ -873,7 +910,11 @@ class OrderController extends Controller
//给客服脱单姐
// \CommonUtilsService::sendBuySuccessNoticeToBusiness($res,'oPC_2vudkf3stdiNgjA-e2n6t9_M','merchant',$result->price,$result->mobile,$result->name);
$openids = [
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs", "oPC_2vudkf3stdiNgjA-e2n6t9_M","oPC_2vtrwOLgWHLwVEFTFsJ7N7fw","oPC_2vt7nGwKk_OFzJL70SlVuTiU","oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs",
"oPC_2vudkf3stdiNgjA-e2n6t9_M",
"oPC_2vtrwOLgWHLwVEFTFsJ7N7fw",
"oPC_2vt7nGwKk_OFzJL70SlVuTiU",
"oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"
];
foreach ($openids as $openid) {
@ -897,10 +938,12 @@ class OrderController extends Controller
if ($config->pay_type == "partner") {
$applyment = MerchantApplyment::where('m_id', $config->merchant_id)->first();
$pay_result = \WechatService::partnerOrderPaid($trade_no, $applyment->sub_mch_id);
if (empty($pay_result) || $pay_result->trade_state != "SUCCESS") return $this->failure("支付回调失败");
if (empty($pay_result) || $pay_result->trade_state != "SUCCESS")
return $this->failure("支付回调失败");
} else {
$pay_result = \WechatService::orderPaid($trade_no);
if (empty($pay_result)) return $this->failure("支付回调失败");
if (empty($pay_result))
return $this->failure("支付回调失败");
}
$scheduling = SaasReservationConsultScheduling::where('id', $result->scheduling_id)
->where('merchant_id', $result->merchant_id)
@ -978,7 +1021,8 @@ class OrderController extends Controller
$user_openid = $config->open_id;
$merchant = MerchantAccount::where('id', $result->merchant_id)->first();
$merchant_openid = $merchant->openid;
if(empty($merchant_openid)) $merchant_openid = Anchor::where('m_id',$merchant->id)->value('openid');
if (empty($merchant_openid))
$merchant_openid = Anchor::where('m_id', $merchant->id)->value('openid');
\CommonUtilsService::sendBuySuccessNoticeToUser($res, $user_openid, $way, $trade_no, $result->price);
//通知商户
@ -1072,8 +1116,12 @@ class OrderController extends Controller
$content = "有用户下单了【{$res->title}】咨询。";
$teacher = MerchantUser::where('mobile', $consult_account->mobile)->first();
if ($teacher && $teacher->openid) {
\CommonUtilsService::consultCustomNotice($teacher->openid, '', $config->name,
"{$scheduling->date} {$scheduling->date_range}", $content
\CommonUtilsService::consultCustomNotice(
$teacher->openid,
'',
$config->name,
"{$scheduling->date} {$scheduling->date_range}",
$content
);
}
//短信
@ -1348,7 +1396,8 @@ class OrderController extends Controller
{
try {
$ratio_coin = RatioCoin::find($coin_id);
if (empty($ratio_coin)) throw new \Exception("福币比例不存在", 1);
if (empty($ratio_coin))
throw new \Exception("福币比例不存在", 1);
$os = request()->header('client_os');
if ($os == 'IOS') {
$goods = '充值' . $ratio_coin->ios_coin . '个福币';
@ -1356,7 +1405,8 @@ class OrderController extends Controller
$goods = '充值' . $ratio_coin->coin . '个福币';
}
$result = $this->orderCon->makeAppOrder($request, $ratio_coin->price, $type = 'coin', $coin_id, $goods, $linkmen = [], $detail = '');
if (empty($result)) throw new \Exception("支付订单生成失败", 1);
if (empty($result))
throw new \Exception("支付订单生成失败", 1);
return $this->success('ok', $result);
} catch (\Exception $e) {
@ -1408,7 +1458,8 @@ class OrderController extends Controller
foreach ($result['receipt']['in_app'] as $v) {
$order_product_id = $this->getOrderProductId($order);
$product_id = $v['product_id'];
if ($order_product_id != $product_id) throw new \Exception("产品id不一致", 1);
if ($order_product_id != $product_id)
throw new \Exception("产品id不一致", 1);
$transaction_ids[] = $v['transaction_id'];//不管当前交易是否已经处理过,都要返回给客户端结束交易
$is_exist = \DB::table('ios_transaction_ids')->where('transaction_id', $v['transaction_id'])->first();
@ -1419,7 +1470,8 @@ class OrderController extends Controller
//否则在此处理业务逻辑
//回调订单
$result = $this->markOrder($order, $pay_order);
if (empty($result)) throw new \Exception("回调内购订单失败", 1);
if (empty($result))
throw new \Exception("回调内购订单失败", 1);
//然后记录下此transaction_id标记为已处理过
\DB::table('ios_transaction_ids')->insert([
'trade_no' => $trade_no,
@ -1522,7 +1574,8 @@ class OrderController extends Controller
}
}
$pay_result = \WechatService::orderPaid($trade_no);
if (empty($pay_result)) return $this->failure("支付回调失败");
if (empty($pay_result))
return $this->failure("支付回调失败");
$merchant = MerchantAccount::where('id', $result->merchant_id)->first();
$merchant_openid = $merchant->openid ?? '';
@ -1576,7 +1629,11 @@ class OrderController extends Controller
//给客服脱单姐
// \CommonUtilsService::sendBuySuccessNoticeToBusiness($res,'oPC_2vudkf3stdiNgjA-e2n6t9_M','merchant',$result->price,$result->mobile,$result->name);
$openids = [
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs", "oPC_2vudkf3stdiNgjA-e2n6t9_M","oPC_2vtrwOLgWHLwVEFTFsJ7N7fw","oPC_2vt7nGwKk_OFzJL70SlVuTiU","oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs",
"oPC_2vudkf3stdiNgjA-e2n6t9_M",
"oPC_2vtrwOLgWHLwVEFTFsJ7N7fw",
"oPC_2vt7nGwKk_OFzJL70SlVuTiU",
"oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"
];
foreach ($openids as $openid) {

View File

@ -40,6 +40,7 @@ use App\Models\Server\Survey;
use App\Models\UnionUser;
use App\Server\ReportFile;
use App\Services\LiveAlipayService;
use App\Services\OrderService;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
@ -2166,17 +2167,10 @@ class Controller extends BaseController
public function test(Request $request)
{
// $access_token = "";
// $app = \WechatService::officialApp()->access_token;
// $token = $app->getToken(true);
// $access_token = $token['access_token'];
// if (empty($access_token)) {
// return $this->failure("缺少access_token");
// }
// $url = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=" . $access_token;
// $result = Http::get($url);
// dd($result);
$order = TouristOrder::find($request->order_id);
$orderService = new OrderService();
$res = $orderService->storeUftxCustomer($order);
dd($res);
}
public function postIndex()

View File

@ -19,6 +19,7 @@ use App\Models\Server\WechatSubMerchant;
use App\Models\UserCoupon;
use App\Models\UserMember;
use App\Services\EvaluateService;
use App\Services\OrderService;
use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Application;
use Illuminate\Http\JsonResponse;
@ -71,8 +72,10 @@ class OrderController extends Controller
$order->address = $recive->address;
$order->title = $shop->title;
$order->icon = $shop->icon;
if ($order->banners && $order->banners != 'null') $order->banners = json_decode($shop->banners) ?? [];
if ($order->remark && $order->remark != 'null') $order->remark = json_decode($shop->remark) ?? [];
if ($order->banners && $order->banners != 'null')
$order->banners = json_decode($shop->banners) ?? [];
if ($order->remark && $order->remark != 'null')
$order->remark = json_decode($shop->remark) ?? [];
$order->describe = $shop->describe;
$order->introduction = $shop->sub_title;
$order->sku = json_decode($shop->sku, true);
@ -136,9 +139,12 @@ class OrderController extends Controller
$pic = $request->pic;
$value = Order::where('id', $id)->whereIn('pay_status', [1, 4])->first();
if ($request->comment) $value->comment = $comment;
if ($request->Praise) $value->Praise = $Praise;
if ($request->pic) $value->comment = json_encode($pic);
if ($request->comment)
$value->comment = $comment;
if ($request->Praise)
$value->Praise = $Praise;
if ($request->pic)
$value->comment = json_encode($pic);
$record = ConsultationRecords::where('trade_no', $value->trade_no)->first();
if ($record) {
@ -165,7 +171,8 @@ class OrderController extends Controller
try {
$id = $request->id;
$result = ConsultationRecords::where('id', $id)->where('pay_status', 1)->first();
if (!$result) return $this->failure('未查到该订单信息~');
if (!$result)
return $this->failure('未查到该订单信息~');
if ($request->status)
$result->status = $request->status;
if ($request->record)
@ -212,9 +219,11 @@ class OrderController extends Controller
try {
$id = $request->id;
$order = Order::where('id', $id)->whereIn('pay_status', [1, 4])->first();
if ($request->trade_no) $order = Order::where('trade_no', $request->trade_no)->whereIn('pay_status', [1, 4])
if ($request->trade_no)
$order = Order::where('trade_no', $request->trade_no)->whereIn('pay_status', [1, 4])
->first();
if (!$order) return $this->failure('未查询到该订单。');
if (!$order)
return $this->failure('未查询到该订单。');
$order->pic = json_decode($order->pic, true) ?? [];
$order->Praise = floatval($order->Praise);
$order->price = floatval($order->price);
@ -256,12 +265,16 @@ class OrderController extends Controller
$openid = 'odh7zsgI75iT8FRh0fGlSojc9PWM';
}
$type = $request->type ?? 'reward_info';
if (empty($openid)) throw new \Exception('打赏失败,未获取用户微信信息');
if (empty($openid))
throw new \Exception('打赏失败,未获取用户微信信息');
$merchant_id = $request->input('merchant_id');
if (empty($merchant_id)) throw new \Exception("打赏失败,获取到商家id");
if (empty($merchant_id))
throw new \Exception("打赏失败,获取到商家id");
$amount = $request->input('amount');
if (empty($amount)) return $this->failure("请输入打赏金额");
if (!is_numeric($amount) || (is_numeric($amount) && $amount < 0)) throw new \Exception('输入打赏金额格式错误');
if (empty($amount))
return $this->failure("请输入打赏金额");
if (!is_numeric($amount) || (is_numeric($amount) && $amount < 0))
throw new \Exception('输入打赏金额格式错误');
$trade_no = \CommonUtilsService::getTradeNO();
$order = array(
'open_id' => $openid,
@ -320,9 +333,11 @@ class OrderController extends Controller
}
$goods = '默认规格';
$result = MerchantShop::where('id', $request->id)->where('is_show', 1)->first();
if (!$result) return $this->failure('你购买的商品不存在或已下架。');
if (!$result)
return $this->failure('你购买的商品不存在或已下架。');
$sku_id = $request->sku_id;
if (!$sku_id && $result->pay_type == 'wechat') return $this->failure('规格参数不存在,请稍后再试。');
if (!$sku_id && $result->pay_type == 'wechat')
return $this->failure('规格参数不存在,请稍后再试。');
if ($sku_id) {
$skus = json_decode($result->sku, true);
$skus = array_column($skus, null, 'sku_id');
@ -333,13 +348,15 @@ class OrderController extends Controller
} else {
$price = $result->price;
$desc = $result->title;
$goods = $result->describe;;
$goods = $result->describe;
;
}
$group_id = null;
if ($buy_type && $buy_type == 'group') {
$time = date('Y-m-d H:i:s');
$group = CollageGroup::where('type', 'shop')->where('type_id', $request->id)->first();
if(!$group) return $this->failure('拼团信息不存在');
if (!$group)
return $this->failure('拼团信息不存在');
$group_sku = json_decode($group->sku, true) ?? null;
if ($group_sku && sizeof($group_sku) > 0) {
$group_skus = array_column($group_sku, null, 'sku_id');
@ -351,20 +368,24 @@ class OrderController extends Controller
$group_id = $group->id;
$history = CollageGroupHistories::where('id', $history_id)->first();
if ($history) {
if($history->deadline < $time) return $this->failure('你慢了一步,拼团已过有效期');
if($history->status == 1) return $this->failure('你慢了一步,该团已被他人完成');
if ($history->deadline < $time)
return $this->failure('你慢了一步,拼团已过有效期');
if ($history->status == 1)
return $this->failure('你慢了一步,该团已被他人完成');
$m_order_ids = CollageGroupHistories::where('group_id', $history->group_id)
->where('m_user_id', $merchant_user_id)->where('status', 0)->where('deadline', '>', $time)
->pluck('m_order_id')->toArray();
$exists = TouristOrder::whereIn('id', $m_order_ids)->whereIn('pay_status', [1, 4])->first();
if($exists) return $this->failure('该活动你有尚未完成的拼团,请耐心等待');
if ($exists)
return $this->failure('该活动你有尚未完成的拼团,请耐心等待');
$exists = CollageGroupHistories::with('tOrder')->whereHas('tOrder', function ($sql) {
$sql->whereIn('pay_status', [1, 4]);
})
->where('group_id', $group->id)->where('m_user_id', $merchant_user_id)
->where('status', 1)
->first();
if($exists) return $this->failure('你已成功拼团参与过该活动,无需重复参与');
if ($exists)
return $this->failure('你已成功拼团参与过该活动,无需重复参与');
}
}
@ -411,33 +432,60 @@ class OrderController extends Controller
$way = 'merchant';
$res = MerchantShop::where('id', $TouristOrder->type_id)->first();
//给用户
\CommonUtilsService::sendBuySuccessNoticeToUser($res, $TouristOrder->open_id, $TouristOrder->type,
$TouristOrder->trade_no, $TouristOrder->price);
\CommonUtilsService::sendBuySuccessNoticeToUser(
$res,
$TouristOrder->open_id,
$TouristOrder->type,
$TouristOrder->trade_no,
$TouristOrder->price
);
//给商户
$merchant = MerchantAccount::where('id', $TouristOrder->merchant_id)->first();
$merchant_openid = $merchant->openid ?? '';
if (!$merchant_openid) {
$merchant_openid = Anchor::where('m_id', $res->merchant_id)->value('openid');
}
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $merchant_openid, $way, $TouristOrder->price,
$TouristOrder->mobile, $TouristOrder->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$merchant_openid,
$way,
$TouristOrder->price,
$TouristOrder->mobile,
$TouristOrder->name
);
if ($TouristOrder->merchant_id == 491) {
//给客服脱单姐 管理员
$openids = [
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs", "oPC_2vudkf3stdiNgjA-e2n6t9_M","oPC_2vtrwOLgWHLwVEFTFsJ7N7fw","oPC_2vt7nGwKk_OFzJL70SlVuTiU","oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs",
"oPC_2vudkf3stdiNgjA-e2n6t9_M",
"oPC_2vtrwOLgWHLwVEFTFsJ7N7fw",
"oPC_2vt7nGwKk_OFzJL70SlVuTiU",
"oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"
];
foreach ($openids as $openid) {
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $openid,'merchant',$TouristOrder->price,
$TouristOrder->mobile, $TouristOrder->namee);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$openid,
'merchant',
$TouristOrder->price,
$TouristOrder->mobile,
$TouristOrder->namee
);
}
}
//发送推荐人
if ($TouristOrder->from_openid && $TouristOrder->from_openid != 'null') {
$way = 'recommend';
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $TouristOrder->from_openid, $way,
$TouristOrder->price, $TouristOrder->mobile, $TouristOrder->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$TouristOrder->from_openid,
$way,
$TouristOrder->price,
$TouristOrder->mobile,
$TouristOrder->name
);
}
//短信通知商家
$jump_url = env('APP_URL') . '/pu_m/#/earningsRecord?merchant_id=' . $merchant->id;
@ -459,8 +507,14 @@ class OrderController extends Controller
]);
//插入购买通知
$content = $TouristOrder->name . '购买了【' . $res->title . '】查看订单详情>>';
SaasNotice::addRecord($TouristOrder->merchant_id, $TouristOrder->account_id, 'order',
$TouristOrder->id, $content, 0);
SaasNotice::addRecord(
$TouristOrder->merchant_id,
$TouristOrder->account_id,
'order',
$TouristOrder->id,
$content,
0
);
return $this->success('ok', $TouristOrder);
}
$TouristOrder->save();
@ -546,14 +600,16 @@ class OrderController extends Controller
return $this->failure('优惠券与团购不能同时使用');
}
$result = CommunityActivity::where('id', $request->id)->first();
if (!$result) return $this->failure('你参与的活动不存在或已下架。');
if (!$result)
return $this->failure('你参与的活动不存在或已下架。');
// if (empty($result->status)) return $this->failure("该活动已下架");
//活动不能重复参与
if ($result->class == 'one' && $result->merchant_id != 44) {
$is_join = TouristOrder::where('type', 'community')->where('type_id', $request->id)
->whereIn('pay_status', [1, 4])->where('account_id', $merchant_user_id)
->first();
if($is_join) return $this->failure('已参与,请勿重复报名');
if ($is_join)
return $this->failure('已参与,请勿重复报名');
}
if ($result->class == 'one' && $result->apply_deadline) {
if ($result->apply_deadline <= $time) {
@ -563,7 +619,8 @@ class OrderController extends Controller
}
}
$sku_id = $request->sku_id;
if (!$sku_id && $result->pay_type == 'wechat') return $this->failure('规格参数不存在,请稍后再试。');
if (!$sku_id && $result->pay_type == 'wechat')
return $this->failure('规格参数不存在,请稍后再试。');
if ($user_coupon_id) {
//$result_array = $result->toArray();
$user_coupon = UserCoupon::where('id', $user_coupon_id)->where('status', 0)
@ -661,7 +718,8 @@ class OrderController extends Controller
if ($buy_type && $buy_type == 'group') {
$time = date('Y-m-d H:i:s');
$group = CollageGroup::where('type', 'community')->where('type_id', $request->id)->first();
if(!$group) return $this->failure('拼团信息不存在');
if (!$group)
return $this->failure('拼团信息不存在');
$sku = json_decode($group->sku, true) ?? null;
if (sizeof($sku) > 0) {
foreach ($sku as $key => $value) {
@ -679,20 +737,24 @@ class OrderController extends Controller
$history_id = $request->history_id;
$history = CollageGroupHistories::where('id', $history_id)->first();
if ($history) {
if($history->deadline < $time) return $this->failure('你慢了一步,拼团已过有效期');
if($history->status == 1) return $this->failure('你慢了一步,该团已被他人完成');
if ($history->deadline < $time)
return $this->failure('你慢了一步,拼团已过有效期');
if ($history->status == 1)
return $this->failure('你慢了一步,该团已被他人完成');
$m_order_ids = CollageGroupHistories::where('group_id', $history->group_id)
->where('m_user_id', $merchant_user_id)->where('status', 0)->where('deadline', '>', $time)
->pluck('m_order_id')->toArray();
$exists = TouristOrder::whereIn('id', $m_order_ids)->whereIn('pay_status', [1, 4])->first();
if($exists) return $this->failure('该活动你有尚未完成的拼团,请耐心等待');
if ($exists)
return $this->failure('该活动你有尚未完成的拼团,请耐心等待');
$exists = CollageGroupHistories::with('tOrder')->whereHas('tOrder', function ($sql) {
$sql->whereIn('pay_status', [1, 4]);
})
->where('group_id', $group->id)->where('m_user_id', $merchant_user_id)
->where('status', 1)
->first();
if($exists) return $this->failure('你已成功拼团参与过该活动,无需重复参与');
if ($exists)
return $this->failure('你已成功拼团参与过该活动,无需重复参与');
}
}
$anchor = Anchor::where('id', $result->anchor_id)->first();
@ -731,11 +793,13 @@ class OrderController extends Controller
$TouristOrder->insurance_info = json_encode($request->insurance_info);
if (is_array($request->linkmen) && count($request->linkmen)) {
$linkmen = $request->linkmen;
foreach ($linkmen as &$linkman)
{
if (!$linkman['mobile']) $linkman['mobile'] = "18888888888";
if (!$linkman['name']) $linkman['name'] = "嘉宾";
if (isset($linkman['sex']) && empty($linkman['sex'])) $linkman['sex'] = "";
foreach ($linkmen as &$linkman) {
if (!$linkman['mobile'])
$linkman['mobile'] = "18888888888";
if (!$linkman['name'])
$linkman['name'] = "嘉宾";
if (isset($linkman['sex']) && empty($linkman['sex']))
$linkman['sex'] = "";
}
$TouristOrder->linkmen = json_encode($linkmen);
} else {
@ -759,27 +823,50 @@ class OrderController extends Controller
//发送通知
//判断是服务还是活动
$res = CommunityActivity::where('id', $TouristOrder->type_id)->first();
if ($res->class == 'one') $class = 'activity';
if ($res->class == 'many') $class = 'service';
\CommonUtilsService::sendBuySuccessNoticeToUser($res, $TouristOrder->open_id, $class, $trade_no,
$TouristOrder->price);
if ($res->class == 'one')
$class = 'activity';
if ($res->class == 'many')
$class = 'service';
\CommonUtilsService::sendBuySuccessNoticeToUser(
$res,
$TouristOrder->open_id,
$class,
$trade_no,
$TouristOrder->price
);
//发送商户
$merchant_openid = $merchant->openid ?? '';
if (!$merchant_openid) {
$merchant_openid = Anchor::where('id', $res->anchor_id)->value('openid');
}
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $merchant_openid, $way, $TouristOrder->price,
$TouristOrder->mobile, $TouristOrder->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$merchant_openid,
$way,
$TouristOrder->price,
$TouristOrder->mobile,
$TouristOrder->name
);
//发送推荐人
if ($TouristOrder->from_openid && $TouristOrder->from_openid != 'null') {
$way = 'recommend';
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $TouristOrder->from_openid, $way,
$TouristOrder->price, $TouristOrder->mobile, $TouristOrder->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$TouristOrder->from_openid,
$way,
$TouristOrder->price,
$TouristOrder->mobile,
$TouristOrder->name
);
}
if ($TouristOrder->merchant_id == 491) {
//给客服脱单姐 管理员
$openids = [
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs", "oPC_2vudkf3stdiNgjA-e2n6t9_M","oPC_2vtrwOLgWHLwVEFTFsJ7N7fw","oPC_2vt7nGwKk_OFzJL70SlVuTiU","oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"oPC_2vn6Q3M5jQpw9xAS7NNCMfjs",
"oPC_2vudkf3stdiNgjA-e2n6t9_M",
"oPC_2vtrwOLgWHLwVEFTFsJ7N7fw",
"oPC_2vt7nGwKk_OFzJL70SlVuTiU",
"oPC_2vg_Eur-Wa_Vwnx9JiyRVn9Q
"
];
foreach ($openids as $openid) {
@ -810,8 +897,18 @@ class OrderController extends Controller
//添加购买通知记录
$content = $result->name . '购买了【' . $res->title . '】查看订单详情>>';
SaasNotice::addRecord($TouristOrder->merchant_id, $TouristOrder->account_id, 'order',
$TouristOrder->id, $content, 0);
SaasNotice::addRecord(
$TouristOrder->merchant_id,
$TouristOrder->account_id,
'order',
$TouristOrder->id,
$content,
0
);
// 友福活动将被邀请人添加到客户
$orderService = new OrderService();
$orderService->storeUftxCustomer($TouristOrder);
return $this->success('ok', $TouristOrder);
} else {
$TouristOrder->save();
@ -874,13 +971,15 @@ class OrderController extends Controller
$sign_buy = $request->sign_buy;
$result = CommunityActivity::where('id', $id)->where('status', 1)->first();
if (!$result) return ['code'=>1, 'msg'=>'你参与的活动不存在或已下架。'];
if (!$result)
return ['code' => 1, 'msg' => '你参与的活动不存在或已下架。'];
//活动不能重复参与
if ($result->class == 'one' && $result->merchant_id != 44) {
$is_join = TouristOrder::where('type', 'community')->where('type_id', $id)
->whereIn('pay_status', [1, 4])->where('account_id', $user_id)
->first();
if($is_join) return ['code'=>1, 'msg'=>'已参与,请勿重复报名'];
if ($is_join)
return ['code' => 1, 'msg' => '已参与,请勿重复报名'];
}
if ($result->class == 'one' && $result->apply_deadline) {
if ($result->apply_deadline <= date('Y-m-d H:i:s')) {
@ -890,7 +989,8 @@ class OrderController extends Controller
}
}
$sku_id = $request->sku_id;
if (!$sku_id && $result->pay_type == 'wechat') return ['code'=>1,'规格参数不存在,请稍后再试。'];
if (!$sku_id && $result->pay_type == 'wechat')
return ['code' => 1, '规格参数不存在,请稍后再试。'];
if ($sku_id) {
$skus = json_decode($result->sku, true);
$skus = array_column($skus, null, 'sku_id');
@ -944,27 +1044,52 @@ class OrderController extends Controller
//发送通知
//判断是服务还是活动
$res = CommunityActivity::where('id', $order->type_id)->first();
if ($res->class == 'one') $class = 'activity';
if ($res->class == 'many') $class = 'service';
\CommonUtilsService::sendBuySuccessNoticeToUser($res, $order->open_id, $class, $trade_no,
$order->price);
if ($res->class == 'one')
$class = 'activity';
if ($res->class == 'many')
$class = 'service';
\CommonUtilsService::sendBuySuccessNoticeToUser(
$res,
$order->open_id,
$class,
$trade_no,
$order->price
);
//发送商户
$merchant_openid = $merchant->openid ?? '';
if (!$merchant_openid) {
$merchant_openid = Anchor::where('id', $res->anchor_id)->value('openid');
}
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $merchant_openid, $way, $order->price,
$order->mobile, $order->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$merchant_openid,
$way,
$order->price,
$order->mobile,
$order->name
);
//发送推荐人
if ($order->from_openid && $order->from_openid != 'null') {
$way = 'recommend';
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $order->from_openid, $way,
$order->price, $order->mobile, $order->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$res,
$order->from_openid,
$way,
$order->price,
$order->mobile,
$order->name
);
}
//添加购买通知记录
$content = $result->name . '购买了【' . $res->title . '】查看订单详情>>';
SaasNotice::addRecord($order->merchant_id, $order->account_id, 'order',
$order->id, $content, 0);
SaasNotice::addRecord(
$order->merchant_id,
$order->account_id,
'order',
$order->id,
$content,
0
);
return ['code' => 0, 'data' => $order];
}
$order->save();
@ -975,7 +1100,8 @@ class OrderController extends Controller
public function payCourseOrder($request, $course_id, $user_id, $openid)
{
$course = Course::where('id', $course_id)->first();
if (empty($course)) return ['code'=>1, 'msg'=>"该课程已下线"];
if (empty($course))
return ['code' => 1, 'msg' => "该课程已下线"];
$trade_no = $this->getTradeNo();
$merchant_user = MerchantUser::where('id', $user_id)->first();
$order = new TouristOrder();
@ -1026,19 +1152,37 @@ class OrderController extends Controller
}
//发送通知
//给用户
\CommonUtilsService::sendBuySuccessNoticeToUser($course, $order->open_id, $order->type,
$trade_no, $order->price);
\CommonUtilsService::sendBuySuccessNoticeToUser(
$course,
$order->open_id,
$order->type,
$trade_no,
$order->price
);
//给商户
$merchant_openid = $course->open_id;
if (empty($merchant_id)) $merchant_openid = Anchor::where('m_id', $order->merchant_id)
if (empty($merchant_id))
$merchant_openid = Anchor::where('m_id', $order->merchant_id)
->value('openid');
\CommonUtilsService::sendBuySuccessNoticeToBusiness($course, $merchant_openid, $way,
$order->price, $order->mobile, $order->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$course,
$merchant_openid,
$way,
$order->price,
$order->mobile,
$order->name
);
//发送推荐人
if ($order->from_openid && $order->from_openid != 'null') {
$way = 'recommend';
\CommonUtilsService::sendBuySuccessNoticeToBusiness($course, $order->from_openid, $way,
$order->price, $order->mobile, $order->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$course,
$order->from_openid,
$way,
$order->price,
$order->mobile,
$order->name
);
}
//短信通知商家
$jump_url = env('APP_URL') . '/pu_m/#/earningsRecord?merchant_id=' . $order->merchant_id;
@ -1052,8 +1196,14 @@ class OrderController extends Controller
$anchor_mobile = Anchor::where('id', $request->merchant_id)->value('mobile');
$this->sentMessage($anchor_mobile, $message);
$content = $order->name . '购买了【' . $course->title . '】查看订单详情>>';
SaasNotice::addRecord($order->merchant_id, $order->account_id, 'order',
$order->id, $content, 0);
SaasNotice::addRecord(
$order->merchant_id,
$order->account_id,
'order',
$order->id,
$content,
0
);
$user_course->save();
}
$order->save();
@ -1070,36 +1220,43 @@ class OrderController extends Controller
$history_id = $request->history_id;
$buy_type = $request->buy_type ?? 'normal';//normal:单独购买 group:拼团购买
$user = MerchantUser::where('id', $user_id)->first();
if (!$user) throw new \Exception("用户信息不存在");
if (!$user)
throw new \Exception("用户信息不存在");
$config = Consultation::where('id', $consult_id)->first();
if (empty($config)) return ['code'=>1, 'msg'=>"该咨询已下线"];
if (empty($config))
return ['code' => 1, 'msg' => "该咨询已下线"];
$link_name = $request->linkmen['name'] ?? ($request->linkmen[0]['name'] ?? null);
$link_mobile = $request->linkmen['mobile'] ?? ($request->linkmen[0]['mobile'] ?? '');
$group_id = null;
if ($buy_type && $buy_type == 'group') {
$time = date('Y-m-d H:i:s');
$group = CollageGroup::where('type', 'community')->where('type_id', $request->id)->first();
if(!$group) return $this->failure('拼团信息不存在');
if (!$group)
return $this->failure('拼团信息不存在');
$price = $group->price;
$group_id = $group->id;
$history_id = $request->history_id;
if ($history_id) {
$history = CollageGroupHistories::where('id', $history_id)->first();
if ($history) {
if ($history->deadline < $time) return $this->failure('你慢了一步,拼团已过有效期');
if ($history->status == 1) return $this->failure('你慢了一步,该团已被他人完成');
if ($history->deadline < $time)
return $this->failure('你慢了一步,拼团已过有效期');
if ($history->status == 1)
return $this->failure('你慢了一步,该团已被他人完成');
$m_order_ids = CollageGroupHistories::where('group_id', $history->group_id)
->where('m_user_id', $user_id)->where('status', 0)->where('deadline', '>', $time)
->pluck('m_order_id')->toArray();
$exists = TouristOrder::whereIn('id', $m_order_ids)->whereIn('pay_status', [1, 4])->first();
if ($exists) return $this->failure('该活动你有尚未完成的拼团,请耐心等待');
if ($exists)
return $this->failure('该活动你有尚未完成的拼团,请耐心等待');
$exists = CollageGroupHistories::with('tOrder')->whereHas('tOrder', function ($sql) {
$sql->whereIn('pay_status', [1, 4]);
})
->where('group_id', $group->id)->where('m_user_id', $user_id)
->where('status', 1)
->first();
if ($exists) return $this->failure('你已成功拼团参与过该活动,无需重复参与');
if ($exists)
return $this->failure('你已成功拼团参与过该活动,无需重复参与');
}
}
}
@ -1159,7 +1316,8 @@ class OrderController extends Controller
\CommonUtilsService::sendBuySuccessNoticeToUser($res, $openid, $way, $trade_no, $consult_record->price);
$merchant = MerchantAccount::where('id', $consult_record->merchant_id)->first();
$merchant_openid = $merchant->openid;
if (empty($merchant_openid)) $merchant_openid = Anchor::where('m_id', $merchant->id)->value('openid');
if (empty($merchant_openid))
$merchant_openid = Anchor::where('m_id', $merchant->id)->value('openid');
//通知商户
\CommonUtilsService::sendBuySuccessNoticeToBusiness($res, $merchant_openid, $type, $order->price, $order->mobile, $order->name);
//发送推荐人
@ -1202,16 +1360,19 @@ class OrderController extends Controller
->first();
$test_item_id = $evaluate_id;
$merchant_id = $request->merchant_id;
if (!$merchant_id || !$test_item_id) throw new \Exception("缺少商户信息或测评信息");
if (!$merchant_id || !$test_item_id)
throw new \Exception("缺少商户信息或测评信息");
$trade_no = $this->getTradeNO();
$merchant_evaluates = MerchantEvaluate::where('merchant_id', $merchant_id)
->where('test_item_id', $test_item_id)
->first();
if (!$merchant_evaluates) return ['code'=>1, 'msg'=>"该测评已下线"];
if (!$merchant_evaluates)
return ['code' => 1, 'msg' => "该测评已下线"];
if ($merchant_evaluates->type == 1) {
//查询一点灵价格
$result = EvaluateService::testDetails($test_item_id);
if (!$result) return ['code'=>1, 'msg'=>"该测评已下线"];
if (!$result)
return ['code' => 1, 'msg' => "该测评已下线"];
} else {
$result = EvaluateDetail::where('test_item_id', $test_item_id)
->first();
@ -1248,7 +1409,8 @@ class OrderController extends Controller
if ($list->type == 1) {
//调用一点灵评测下单接口下单
$evaluate = EvaluateService::testCreate($test_item_id, $result['price'], $trade_no);
if (!$evaluate) throw new \Exception("第三方未返回数据");
if (!$evaluate)
throw new \Exception("第三方未返回数据");
}
@ -1267,9 +1429,11 @@ class OrderController extends Controller
public function payShopOrder($request, $shop_id, $user_id, $openid)
{
$shop = MerchantShop::where('id', $shop_id)->where('is_show', 1)->first();
if (!$shop) return ['code'=>1, 'msg'=>'你购买的商品不存在或已下架。'];
if (!$shop)
return ['code' => 1, 'msg' => '你购买的商品不存在或已下架。'];
$sku_id = $request->sku_id;
if (!$sku_id && $shop->pay_type == 'wechat') return $this->failure('规格参数不存在,请稍后再试。');
if (!$sku_id && $shop->pay_type == 'wechat')
return $this->failure('规格参数不存在,请稍后再试。');
if ($sku_id) {
$skus = json_decode($shop->sku, true);
$skus = array_column($skus, null, 'sku_id');
@ -1322,21 +1486,38 @@ class OrderController extends Controller
//发送通知
$way = 'merchant';
//给用户
\CommonUtilsService::sendBuySuccessNoticeToUser($shop, $order->open_id, $order->type,
$order->trade_no, $order->price);
\CommonUtilsService::sendBuySuccessNoticeToUser(
$shop,
$order->open_id,
$order->type,
$order->trade_no,
$order->price
);
//给商户
$merchant = MerchantAccount::where('id', $order->merchant_id)->first();
$merchant_openid = $merchant->openid ?? '';
if (!$merchant_openid) {
$merchant_openid = Anchor::where('m_id', $shop->merchant_id)->value('openid');
}
\CommonUtilsService::sendBuySuccessNoticeToBusiness($shop, $merchant_openid, $way, $order->price,
$order->mobile, $order->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$shop,
$merchant_openid,
$way,
$order->price,
$order->mobile,
$order->name
);
//发送推荐人
if ($order->from_openid && $order->from_openid != 'null') {
$way = 'recommend';
\CommonUtilsService::sendBuySuccessNoticeToBusiness($shop, $order->from_openid, $way,
$order->price, $order->mobile, $order->name);
\CommonUtilsService::sendBuySuccessNoticeToBusiness(
$shop,
$order->from_openid,
$way,
$order->price,
$order->mobile,
$order->name
);
}
//短信通知商家
$jump_url = env('APP_URL') . '/pu_m/#/earningsRecord?merchant_id=' . $merchant->id;
@ -1358,8 +1539,14 @@ class OrderController extends Controller
]);
//插入购买通知
$content = $order->name . '购买了【' . $shop->title . '】查看订单详情>>';
SaasNotice::addRecord($order->merchant_id, $order->account_id, 'order',
$order->id, $content, 0);
SaasNotice::addRecord(
$order->merchant_id,
$order->account_id,
'order',
$order->id,
$content,
0
);
}
$order->save();
@ -1394,7 +1581,8 @@ class OrderController extends Controller
} elseif ($type == 'shop') {
$result = $this->payShopOrder($request, $request->type_id, $user_id, $openid);
}
if($result['code'] == 1) return $this->failure($result['msg']);
if ($result['code'] == 1)
return $this->failure($result['msg']);
$order = $result['data'];
return $this->success('ok', $order);
} catch (\Exception $e) {

View File

@ -61,6 +61,7 @@ use App\Models\TouristOrder;
use App\Models\User;
use App\Models\Wechat;
use App\Services\IMService;
use App\Services\OrderService;
use App\Services\SaasVipService;
use App\Services\TestService;
use App\Utils\Http;
@ -171,8 +172,7 @@ class TestController extends Controller
}
public function test($request)
{
$time = '2023-01-01 00:00';
dd(date('Y-m-d', strtotime($time)));
}
public function merchantEarningExport(Request $request)

View File

@ -0,0 +1,11 @@
<?php
namespace App\Models\Dma;
use Illuminate\Database\Eloquent\Model;
class DmaServiceUserRole extends Model
{
protected $table = 'dma_service_user_role';
protected $connection = 'dma';
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Models\Dma;
use Illuminate\Database\Eloquent\Model;
class S2Customer extends Model
{
protected $table = 's2_customer';
protected $connection = 'dma';
public $fillable = [];
public $guarded = [];
}

View File

@ -3,6 +3,8 @@
namespace App\Services;
use App\Contracts\OrderContract;
use App\Models\Dma\DmaServiceUserRole;
use App\Models\Dma\S2Customer;
use App\Models\Order;
use App\Models\PayOrder;
use App\Models\RankHistory;
@ -19,8 +21,9 @@ use App\Models\PaasAccount;
use App\Models\Live\Asset;
use App\Http\Response\ResponseJson;
use App\Models\Live\AssetLog;
use Log;
use PhpParser\Node\Expr\Cast\Bool_;
class OrderService implements OrderContract
{
use ResponseJson;
//充值会员
@ -473,7 +476,8 @@ class OrderService implements OrderContract
// $result = \CommonUtilsService::contrastVersion($ios_version, '1.3.16');
$result = $ios_version == '1.3.17' ? true : false;
if ($result && $pay_type == 'ios' and empty($receipt)) throw new \Exception("没有支付凭证", 1);
if ($result && $pay_type == 'ios' and empty($receipt))
throw new \Exception("没有支付凭证", 1);
//生成支付订单
$pay_order = array(
'user_id' => auth()->id(),
@ -571,7 +575,8 @@ class OrderService implements OrderContract
/**订单类型转换 代码转成中文*/
public function orderTypeCodeSwitchChinese($type){
public function orderTypeCodeSwitchChinese($type)
{
if ($type === 'score') {
return '福分充值';
} else if ($type === 'rank') {
@ -606,4 +611,89 @@ class OrderService implements OrderContract
}
public function storeUftxCustomer($order): bool
{
try {
// 判断订单是否是uftx
if ($order->merchant_id != 44) {
Log::error("不是友福商户");
return false;
}
// 判断订单是否有分享人
if (!$order->from_openid) {
Log::error("没有from_openid");
return false;
}
// 判断下单人和分享人是否一致
if ($order->openid == $order->from_openid) {
Log::error("分享人和下单人一致");
return false;
}
// 查询订单用户手机号和分享人用户手机号
$wechat = Wechat::where("official_openid", $order->open_id)->first();
if (empty($wechat)) {
Log::error("没有下单人wechat");
return false;
}
$from_wechat = Wechat::where("official_openid", $order->from_openid)->first();
if (empty($from_wechat)) {
Log::error("没有分享人wechat");
return false;
}
$user = User::Where("id", $wechat->user_id)->first();
if (empty($user)) {
Log::error("没有下单人user");
return false;
}
$from_user = User::Where("id", $from_wechat->user_id)->first();
if (empty($from_user)) {
Log::error("没有分享人user");
return false;
}
$mobile = $user->mobile;
if (empty($mobile)) {
Log::error("没有下单人手机号");
return false;
}
$from_mobile = $from_user->mobile;
if (empty($from_mobile)) {
Log::error("没有分享人手机号");
return false;
}
// 判断分享人是否在友福同享有服务端账号
$serviceUser = DmaServiceUserRole::where("mobile", $from_mobile)->first();
if (empty($serviceUser)) {
Log::error("分享人不是商户端用户");
return false;
}
// 判断是否已经是客户
$customer = S2Customer::where(["user_id" => $serviceUser->user_id, "contacts_mobile" => $mobile])->first();
if ($customer) {
Log::error("已成为客户");
return false;
}
// 创建客户
S2Customer::create([
"user_id" => $serviceUser->user_id,
"customer_name" => "",
"customer_type" => 101,
"contacts_name" => $user->nickname,
"contacts_mobile" => $mobile,
"intention" => 1,
"status" => 2
]);
Log::info("创建客户成功");
return true;
} catch (\Throwable $th) {
$this->getError($th);
return false;
}
}
}

View File

@ -60,6 +60,22 @@ return [
'engine' => null,
],
'dma' => [
'driver' => 'mysql',
'host' => env('DMA_DB_HOST', '192.168.6..10'),
'port' => env('DMA_DB_PORT', '3306'),
'database' => env('DMA_DB_DATABASE', 'health'),
'username' => env('DMA_DB_USERNAME', 'root'),
'password' => env('DMA_DB_PASSWORD', 'root'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => env('DB_PREFIX', ''),
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),