ServiceController.php 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2018/11/16
  6. * Time: 11:17
  7. */
  8. namespace App\Http\Controllers\Jkq\Company;
  9. use Aix\Pay\Data\PayOrder;
  10. use App\Exceptions\ResponseException;
  11. use App\Http\Controllers\Jkq\JkqBaseController;
  12. use App\Models\Jobs;
  13. use App\Models\Promotion;
  14. use App\Repositories\JobsRepository;
  15. use App\Repositories\MemberHandselRepository;
  16. use App\Repositories\MemberLogRepository;
  17. use App\Repositories\MembersChargeLogRepository;
  18. use App\Repositories\PromotionRepository;
  19. use App\Repositories\QueueAutoRefreshRepository;
  20. use App\Services\Common\MembersSetmealService;
  21. use App\Services\Common\OrderService;
  22. use App\Services\Common\PaymentService;
  23. use App\Services\Common\PayService;
  24. use App\Services\Common\SetmealIncrementsService;
  25. use App\Services\Common\SetmealService;
  26. use App\Services\Company\CompanyService;
  27. use App\Services\Company\CompanyTplService;
  28. use App\Services\Company\ComplaintConsultantService;
  29. use App\Services\Company\ServiceService;
  30. use App\Services\Person\MemberPointService;
  31. use Illuminate\Http\Request;
  32. use Illuminate\Support\Facades\DB;
  33. class ServiceController extends JkqBaseController
  34. {
  35. protected $serviceService;
  36. protected $membersSetmealService;
  37. protected $payService;
  38. protected $setmealService;
  39. protected $memberPointService;
  40. protected $orderService;
  41. protected $memberLogRepository;
  42. protected $memberHandselRepository;
  43. protected $membersChargeLogRepository;
  44. protected $paymentService;
  45. protected $setmealIncrementsService;
  46. protected $companyService;
  47. protected $queueAutoRefreshRepository;
  48. protected $jobsRepository;
  49. protected $promotionRepository;
  50. protected $companyTplService;
  51. protected $complaintConsultantService;
  52. /**
  53. * ServiceController constructor.
  54. * @param $serviceService
  55. * @param $membersSetmealService
  56. * @param $payService
  57. * @param $setmealService
  58. * @param $memberPointService
  59. * @param $orderService
  60. * @param $memberLogRepository
  61. * @param $memberHandselRepository
  62. * @param $membersChargeLogRepository
  63. * @param $paymentService
  64. * @param $setmealIncrementsService
  65. * @param $companyService
  66. * @param $queueAutoRefreshRepository
  67. * @param $jobsRepository
  68. * @param $promotionRepository
  69. */
  70. public function __construct(ServiceService $serviceService, PromotionRepository $promotionRepository, JobsRepository $jobsRepository, QueueAutoRefreshRepository $queueAutoRefreshRepository, CompanyService $companyService, SetmealIncrementsService $setmealIncrementsService, PaymentService $paymentService, MembersChargeLogRepository $membersChargeLogRepository, MemberHandselRepository $memberHandselRepository, MemberLogRepository $memberLogRepository, OrderService $orderService, MemberPointService $memberPointService, MembersSetmealService $membersSetmealService, PayService $payService, SetmealService $setmealService, CompanyTplService $companyTplService, ComplaintConsultantService $complaintConsultantService)
  71. {
  72. $this->serviceService = $serviceService;
  73. $this->membersSetmealService = $membersSetmealService;
  74. $this->payService = $payService;
  75. $this->setmealService = $setmealService;
  76. $this->memberPointService = $memberPointService;
  77. $this->orderService = $orderService;
  78. $this->memberLogRepository = $memberLogRepository;
  79. $this->memberHandselRepository = $memberHandselRepository;
  80. $this->membersChargeLogRepository = $membersChargeLogRepository;
  81. $this->paymentService = $paymentService;
  82. $this->setmealIncrementsService = $setmealIncrementsService;
  83. $this->companyService = $companyService;
  84. $this->queueAutoRefreshRepository = $queueAutoRefreshRepository;
  85. $this->jobsRepository = $jobsRepository;
  86. $this->promotionRepository = $promotionRepository;
  87. $this->companyTplService = $companyTplService;
  88. $this->complaintConsultantService = $complaintConsultantService;
  89. }
  90. /**我的套餐
  91. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  92. */
  93. public function index()
  94. {
  95. $user = auth('web-company')->user();//企业信息
  96. $res = $this->serviceService->index($user);
  97. return view('jkq.company.service.index', $res);
  98. }
  99. public function setmealDetail(Request $request)
  100. {
  101. $user = auth('web-company')->user();//企业信息
  102. $res = $this->serviceService->setmealDetail($request->all(), $user);
  103. return view('jkq.company.service.setmeal_detail', $res);
  104. }
  105. /**积分任务
  106. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  107. */
  108. public function points()
  109. {
  110. $user = auth('web-company')->user();
  111. $res = $this->serviceService->points($user);
  112. return view('jkq.company.service.points', $res);
  113. }
  114. /**积分明细
  115. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  116. */
  117. public function pointsDetail(Request $request)
  118. {
  119. $user = auth('web-company')->user();
  120. $type = $request->type?$request->type:1;
  121. $res = $this->serviceService->pointsDetail(3, $user);
  122. return view('jkq.company.service.points_detail', $res);
  123. }
  124. /**套餐升级
  125. * @param $id
  126. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  127. * @throws \App\Exceptions\ResponseException
  128. */
  129. public function setmealAdd($id)
  130. {
  131. $user = auth('web-company')->user();
  132. if (!$id) {
  133. throw new ResponseException('请选择正确的套餐!', '', 404);
  134. }
  135. $setmeal = $this->serviceService->setmealAdd($id, $user);
  136. return view('jkq.company.service.setmeal_add', $setmeal);
  137. }
  138. /**套餐弹窗
  139. * @return \Illuminate\Http\JsonResponse
  140. * @throws \Throwable
  141. */
  142. public function paySetmeal()
  143. {
  144. $user = auth('web-company')->user();
  145. $mysetmeal = $this->membersSetmealService->getSetmealByUid($user->id, $user->utype);
  146. if (config('aix.companyset.setmeal_com.setmeal_com_set.is_superposition') == 0 && config('aix.companyset.setmeal_com.setmeal_com_set.is_superposition_time') == 0) { //项目和时间都不叠加
  147. $tip = '您当前是【' . $mysetmeal->setmeal_name . '】重新开通套餐<br /><span class="font_yellow">1. 原有套餐资源以新开套餐资源为准;</span><br /><span class="font_yellow">2. 原有会员服务时长以新开套餐时长为准;</span><br />确定要重新开通套餐吗?';
  148. } elseif (config('aix.companyset.setmeal_com.setmeal_com_set.is_superposition') == 0 && config('aix.companyset.setmeal_com.setmeal_com_set.is_superposition_time') == 1) { //项目不叠加时间叠加
  149. $tip = '您当前是【' . $mysetmeal->setmeal_name . '】重新开通套餐<br /><span class="font_yellow">您的原套餐资源会被新开通的套餐资源覆盖</span><br />确定要重新开通套餐吗?';
  150. } elseif (config('aix.companyset.setmeal_com.setmeal_com_set.is_superposition') == 1 && config('aix.companyset.setmeal_com.setmeal_com_set.is_superposition_time') == 0) { //项目叠加时间不叠加
  151. $tip = '您当前是【' . $mysetmeal->setmeal_name . '】重新开通套餐<br /><span class="font_yellow">您的会员服务时长将以新开套餐服务时长为准</span><br />确定要重新开通套餐吗?';
  152. } else {
  153. $tip = '您当前是【' . $mysetmeal->setmeal_name . '】重新开通套餐<br /><span class="font_yellow">您的套餐资源和会员时长将叠加</span><br />确定要重新开通套餐吗?';
  154. }
  155. return response()->json(['status' => 1, 'data' => ['html' => view('jkq.company.ajax.ajax_warning', ['tip' => $tip])->render()]]);
  156. }
  157. /**会员套餐
  158. * @param Request $request
  159. * @return \Illuminate\Http\JsonResponse
  160. * @throws ResponseException
  161. * @throws \Prettus\Validator\Exceptions\ValidatorException
  162. */
  163. public function setmealAddSave(Request $request)
  164. {
  165. $user = auth('web-company')->user();
  166. //检查未处理订单数
  167. $order_pay_type = 1;
  168. $payment_name = $request->input('payment_name', '');
  169. $pay_type = $request->input('points', '');
  170. $setmeal_id = $request->input('project_id', 0);
  171. $is_deductible = $request->input('is_deductible', 0);
  172. if ($payment_name == 'wechat') {
  173. $type = 'scan';
  174. } elseif ($payment_name == 'alipay') {
  175. $type = 'web';
  176. } elseif ($payment_name == 'offline') {
  177. $is_deductible=0;
  178. $type = 'pay';
  179. }
  180. if ($is_deductible == 0) {
  181. $deductible = 0;
  182. } else {
  183. $deductible = $request->input('deductible', '');
  184. }
  185. $amount = $request->input('amount', '');//应当付款价格
  186. if ($amount == 0) {
  187. $pay_type = 'points';
  188. }
  189. if ($deductible>0) {
  190. $m_amount = floatval($deductible/config('aix.companyset.points.points_set.payment_rate')); //积分充值比例
  191. } else {
  192. $m_amount =0;//应该减去的钱
  193. }
  194. if ($setmeal_id == 0 || $setmeal_id==1) {
  195. throw new ResponseException(AjaxError("请选择套餐",0));
  196. }
  197. $setmealInfo = $this->setmealService->getSetmealOne($setmeal_id);//套餐详情
  198. if ($setmealInfo->apply==0){
  199. throw new ResponseException(AjaxError("改套餐不可购买",0));
  200. }
  201. $mypoints = $this->memberPointService->getPoints($user->id, $user->utype);
  202. $amount = $setmealInfo->expense;//套餐的价格
  203. $price=$amount-$m_amount; //套餐-积分兑换的钱
  204. $price=round($price, 2); //去小数点
  205. $service_need_points = round($amount * config('aix.companyset.points.points_set.payment_rate'));
  206. if (!config('aix.companyset.setmeal_com.setmeal_com_set.setmeal_by_points')) {
  207. $is_deductible = 0;
  208. $deductible = 0;
  209. $pay_type = 'cash';
  210. }
  211. if ($pay_type == 'points') {
  212. DB::beginTransaction();
  213. try {
  214. if ($mypoints->points < $service_need_points) {
  215. throw new \Exception('积分不足,请使用其他方式支付!');
  216. }
  217. $set_setmeal = $this->serviceService->setMembersSetmeal($user, $setmeal_id);
  218. if (!$set_setmeal['status']) {
  219. throw new \Exception($set_setmeal['msg']);
  220. }
  221. $description = '购买服务:' . $setmealInfo->setmeal_name . ';积分支付:' . $service_need_points . "积分";
  222. $order = $this->orderService->addOrder($user, 1, $setmealInfo->expense, 0, $service_need_points, $setmealInfo->setmeal_name, 'points', '积分支付', $description, 2, 0, $setmeal_id, time(), '');
  223. if (!$order) {
  224. throw new \Exception('生成订单失败!');
  225. }
  226. $oid = $this->payService->getTradeNo($order->id);//订单号
  227. if (!$this->serviceService->updateOid($order->id, $oid)) {
  228. throw new \Exception('生成订单号失败!');
  229. }
  230. //生成会员日志
  231. $this->memberLogRepository->createLog($user, 9001, [$oid, '积分支付','']);
  232. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  233. throw new \Exception('修改会员积分失败!');
  234. } else {
  235. $handsel['uid'] = $user->id;
  236. $handsel['utype'] = $user->utype;
  237. $handsel['htype'] = 'points_buy_setmeal';
  238. $handsel['htype_cn'] = '购买增值包:' . $setmealInfo->setmeal_name;
  239. $handsel['operate'] = 2;
  240. $handsel['points'] = $service_need_points;
  241. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  242. throw new \Exception('添加积分操作记录失败!');
  243. }
  244. $notes = date('Y-m-d H:i:s', time()) . "通过积分兑换成功开通{ $setmealInfo->setmeal_name}";
  245. }
  246. DB::commit();
  247. } catch (\Exception $e) {
  248. DB::rollback();
  249. return response()->json(['status' => 0, 'msg' => $e->getMessage()]);
  250. }
  251. return response()->json(['status' => 1, 'data' => $oid]);
  252. } else {
  253. if ($is_deductible == 1 && $mypoints->points < $deductible) {
  254. throw new ResponseException('积分不足,请使用其他方式支付!');
  255. }
  256. if ($is_deductible == 1 && $deductible > 0) {
  257. $description = $setmealInfo->setmeal_name . ';积分抵扣:' . $deductible . '积分';
  258. }
  259. if ($deductible > 0 && $is_deductible) {
  260. $amount = $amount - floatval($deductible / config('aix.companyset.points.points_set.payment_rate'));
  261. }
  262. $paysetarr['ordtotal_fee'] = $price;
  263. $payment = $this->paymentService->returnPayment($payment_name);
  264. $description = '购买服务:' . $setmealInfo->setmeal_name . ';' . $payment->name . $paysetarr['ordtotal_fee'];
  265. if ($deductible > 0 && $is_deductible == 1) {
  266. $description .= ';积分支付:' . $deductible . '积分';
  267. }
  268. $params = [
  269. 'setmeal_id'=>$setmealInfo->id,
  270. 'setmeal_name'=>$setmealInfo->setmeal_name,
  271. 'company_id'=>$user->id,
  272. 'utype'=>$user->utype,
  273. 'companyname'=>$user->companyname,
  274. 'amount'=>$paysetarr['ordtotal_fee'],
  275. 'points'=>$deductible,
  276. 'payment'=>$payment_name,
  277. 'username'=>$user->username,
  278. 'subsite_id'=>$user->subsite_id,
  279. ];
  280. $insert_id = $this->orderService->addOrder($user, 1, $price, $paysetarr['ordtotal_fee'], $deductible, $setmealInfo->setmeal_name, $payment_name, $payment->name, $description, 1, $deductible, $setmeal_id, 0, serialize($params));
  281. $tradeNo = $this->payService->getTradeNo($insert_id->id);
  282. if (!$this->serviceService->updateOid($insert_id->id, $tradeNo)) {
  283. throw new ResponseException('生成订单号失败');
  284. }
  285. $payOrder = new PayOrder();
  286. $payOrder->trade_no = $tradeNo;
  287. $payOrder->subject = '购买' . $setmealInfo->setmeal_name;
  288. $payOrder->detail = $description;
  289. $payOrder->price = $price;
  290. $payOrder->callback = "App\Services\Common\OrderService.updateCompany";
  291. $payOrder->return_url = route('jkq.service.order.index');
  292. $result = $this->payService->pay($payment_name, $type, $payOrder);
  293. if ($payment_name == 'wechat') {
  294. return response()->json([
  295. 'status' => 1,
  296. 'tradeCode' => get_qrcode_html($result->code_url),
  297. 'tradeNo' => $tradeNo,
  298. ]);
  299. } elseif ($payment_name =='alipay') {
  300. return $result;
  301. } else {
  302. return response()->json([
  303. 'status'=>1,
  304. 'tradeNo'=>$tradeNo,
  305. 'url'=>route("jkq.service.order.detail",['id'=>$insert_id->id]),
  306. ]);
  307. }
  308. }
  309. }
  310. /**订单状态
  311. * @param Request $request
  312. * @return \Illuminate\Http\JsonResponse
  313. */
  314. public function checkOrderStatus(Request $request)
  315. {
  316. $tradeNo = $request->tradeNo;
  317. if (!$tradeNo) {
  318. return response()->json(['status' => 0, 'msg' => "订单号错误!"]);
  319. }
  320. return $this->orderService->getOrderbyTradeNo($tradeNo);
  321. }
  322. /**
  323. * @return \Illuminate\Http\JsonResponse
  324. * @throws \Throwable
  325. */
  326. public function paySetmealStatus()
  327. {
  328. $tip = '请在新打开的支付页面完成付款';
  329. $description = '付款完成前请不要关闭此窗口,付款后请根据您的情况点击下面的按钮,如果在支付中遇到问题请到<a target="_blank" href="">帮助中心</a>。';
  330. return response()->json(['status' => 1, 'html' => view('jkq.company.ajax.ajax_warning', ['tip' => $tip, 'description' => $description])->render()]);
  331. }
  332. /**增值服务
  333. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  334. */
  335. public function increment()
  336. {
  337. $res = $this->serviceService->increment(auth('web-company')->user());
  338. return view('jkq.company.increment.index', $res);
  339. }
  340. /**各增值包
  341. * @param Request $request
  342. * @param $cat
  343. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  344. * @throws ResponseException
  345. */
  346. public function incrementAdd(Request $request, $cat)
  347. {
  348. switch ($cat) {
  349. case 'download_resume':
  350. case 'sms':
  351. case 'jobs':
  352. case 'jobfair_num':
  353. $display_tpl = "resume_sms";
  354. break;
  355. case 'stick':
  356. case 'emergency':
  357. $display_tpl = 'stick_emergency';
  358. break;
  359. case 'tpl':
  360. $display_tpl = 'tpl';
  361. break;
  362. case 'auto_refresh_jobs':
  363. $display_tpl = 'auto_refresh_jobs';
  364. break;
  365. default:
  366. throw new ResponseException('参数错误');
  367. break;
  368. }
  369. $res = $this->serviceService->incrementAdd($cat, $request->all());
  370. return view("jkq.company.increment.increment_add_{$display_tpl}", $res);
  371. }
  372. /**增值服务 === 提示框内容
  373. * @return \Illuminate\Http\JsonResponse
  374. * @throws \Throwable
  375. */
  376. public function confirmPayIncrement()
  377. {
  378. $user = auth('web-company')->user();
  379. $res = $this->serviceService->confirmPayIncrement($user);
  380. return response()->json(['status'=>1, 'msg'=>'success','data'=>['html'=>view('jkq.company.ajax.ajax_warning', $res)->render()]]);
  381. }
  382. /**增值服务保存
  383. * @param Request $request
  384. * @return \Illuminate\Http\JsonResponse
  385. */
  386. public function incrementPaySave(Request $request)
  387. {
  388. $service_type = $request->input('service_type', '');
  389. if (!$service_type) {
  390. return response()->json(['status'=>0,'msg'=>"参数错误"]);
  391. }
  392. switch ($service_type) {
  393. case 'download_resume':
  394. $fun = 'DownloadResume';
  395. break;
  396. case 'sms':
  397. $fun = 'Sms';
  398. break;
  399. case 'jobs':
  400. $fun = 'Jobs';
  401. break;
  402. case 'jobfair_num':
  403. $fun = 'JobfairNum';
  404. break;
  405. case 'stick':
  406. $fun = 'Stick';
  407. break;
  408. case 'emergency':
  409. $fun = 'Emergency';
  410. break;
  411. case 'tpl':
  412. $fun = 'Tpl';
  413. break;
  414. case 'auto_refresh_jobs':
  415. $fun = 'AutoRefreshJobs';
  416. break;
  417. }
  418. $func_name = "increment".$fun;
  419. $incrment_arr = ['download_resume','jobs','jobfair_num','sms','stick','emergency','tpl','auto_refresh_jobs'];
  420. if (!in_array($service_type, $incrment_arr)) {
  421. return response()->json(['status'=>0,'msg'=>"参数错误"]);
  422. } else {
  423. return $this->$func_name($request);
  424. }
  425. }
  426. /**简历包
  427. * @param $request
  428. * @return array|\Illuminate\Http\JsonResponse
  429. * @throws ResponseException
  430. * @throws \Prettus\Validator\Exceptions\ValidatorException
  431. */
  432. protected function incrementDownloadResume($request)
  433. {
  434. $cat = $request->input('service_type', 'download_resume');
  435. $order_pay_type = 6;
  436. $payment_name = $request->input('payment_name', '');
  437. $pay_type = $request->input('pay_type', 'points');
  438. $project_id = $request->input('project_id', 0);
  439. $is_deductible = $request->input('is_deductible', 0);
  440. if ($is_deductible==0) {
  441. $deductible = 0;
  442. } else {
  443. $deductible = $request->input('deductible', 0);
  444. }
  445. $amount = floatval($request->input('amount', 0));
  446. if ($amount==0) {
  447. $pay_type = 'points';
  448. }
  449. if ($project_id==0) {
  450. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  451. }
  452. $user = auth('web-company')->user();
  453. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  454. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  455. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  456. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  457. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //增值包套餐金额
  458. if ($pay_type=='points') { //积分支付
  459. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //增值包套餐所需积分
  460. if ($my_point->points < $service_need_points) {
  461. return response()->json(['status'=>0, 'msg' =>'积分不足,请使用其他方式支付!']);
  462. }
  463. //操作事务开始
  464. DB::beginTransaction();
  465. try {
  466. //会员套餐添加增值包数量
  467. $setmeal_rst = $this->membersSetmealService->actionUserSetmeal(array('uid'=>$user->id, 'utype'=>1), $cat, 1, $increment_info->value);
  468. if (!$setmeal_rst) {
  469. throw new \Exception('修改会员套餐失败!');
  470. }
  471. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  472. $stime = time();
  473. //添加订单信息
  474. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, '', '专享'.$my_discount.'折优惠');
  475. if (!$order) {
  476. throw new \Exception('生成订单失败!');
  477. }
  478. $oid = $this->payService->getTradeNo($order->id);//订单号
  479. if (!$this->serviceService->updateOid($order->id, $oid)) {
  480. throw new \Exception('生成订单号失败!');
  481. }
  482. //会员日志:添加创建增值服务订单日志
  483. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  484. //修改会员积分
  485. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  486. throw new \Exception('修改会员积分失败!');
  487. } else {
  488. $handsel['uid'] = $user->id;
  489. $handsel['utype'] = $user->utype;
  490. $handsel['htype'] = 'increment_download_resume';
  491. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  492. $handsel['operate'] = 2;
  493. $handsel['points'] = $service_need_points;
  494. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  495. throw new \Exception('添加积分操作记录失败!');
  496. }
  497. $notes = date('Y-m-d H:i:s', time()) . "通过积分兑换成功开通{ $increment_info->name}";
  498. }
  499. DB::commit();
  500. } catch (\Exception $e) {
  501. DB::rollback();
  502. return response()->json(['status'=>0, 'msg' => $e->getMessage()]);
  503. }
  504. return response()->json(['status'=>1, 'msg' => '积分兑换成功!','data'=>$oid]);
  505. } else {
  506. if ($is_deductible==1 && $my_point->points<$deductible) {
  507. return response()->json(['status'=>1, 'msg' => '积分不足,请使用其他方式支付!']);
  508. }
  509. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', '', 0, $project_id, '专享'.$my_discount.'折优惠');
  510. }
  511. }
  512. /**短信包
  513. * @param $request
  514. * @return array|\Illuminate\Http\JsonResponse
  515. * @throws ResponseException
  516. * @throws \Prettus\Validator\Exceptions\ValidatorException
  517. */
  518. protected function incrementSms($request)
  519. {
  520. $cat = $request->input('service_type', 'sms');
  521. $order_pay_type = 7;
  522. $payment_name = $request->input('payment_name', '');
  523. $pay_type = $request->input('pay_type', 'points');
  524. $project_id = $request->input('project_id', 0);
  525. $is_deductible = $request->input('is_deductible', 0);
  526. // dd($request);
  527. if ($is_deductible==0) {
  528. $deductible = 0;
  529. } else {
  530. $deductible = $request->input('deductible', '');
  531. }
  532. $amount = floatval($request->input('amount', ''));
  533. if ($amount==0) {
  534. $pay_type = 'points';
  535. }
  536. if ($project_id==0) {
  537. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  538. }
  539. $user = auth('web-company')->user();
  540. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  541. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  542. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  543. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  544. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //增值包套餐金额
  545. if ($pay_type=='points') { //积分支付
  546. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //增值包套餐所需积分
  547. if ($my_point->points < $service_need_points) {
  548. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!']);
  549. }
  550. //操作事务开始
  551. DB::beginTransaction();
  552. try {
  553. $companySms = $this->companyService->incSms($user->id, 1, $increment_info->value);
  554. if (!$companySms) {
  555. throw new \Exception('会员短信数量增加失败!');
  556. }
  557. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  558. $stime = time();
  559. //添加订单信息
  560. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, '', '专享'.$my_discount.'折优惠');
  561. if (!$order) {
  562. throw new \Exception('生成订单失败!');
  563. }
  564. $oid = $this->payService->getTradeNo($order->id);//订单号
  565. if (!$this->serviceService->updateOid($order->id, $oid)) {
  566. throw new \Exception('生成订单号失败!');
  567. }
  568. //会员日志:添加创建增值服务订单日志
  569. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  570. //修改会员积分
  571. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  572. throw new \Exception('修改会员积分失败!');
  573. } else {
  574. $handsel['uid'] = $user->id;
  575. $handsel['utype'] = $user->utype;
  576. $handsel['htype'] = 'increment_download_resume';
  577. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  578. $handsel['operate'] = 2;
  579. $handsel['points'] = $service_need_points;
  580. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  581. throw new \Exception('添加积分操作记录失败!');
  582. }
  583. }
  584. DB::commit();
  585. } catch (\Exception $e) {
  586. DB::rollback();
  587. return array( 'status'=>0, 'msg' => $e->getMessage());
  588. }
  589. return array( 'status'=>1, 'msg' => '积分兑换成功!','data'=>$oid);
  590. } else {
  591. if ($is_deductible==1 && $my_point->points<$deductible) {
  592. return array( 'status'=>0, 'msg' => '积分不足,请使用其他方式支付!');
  593. }
  594. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', '', 0, $project_id, '专享'.$my_discount.'折优惠');
  595. }
  596. }
  597. protected function incrementJobfairNum($request)
  598. {
  599. $cat = $request->input('service_type', 'jobfair_num');
  600. $order_pay_type = 15;
  601. $payment_name = $request->input('payment_name', '');
  602. $pay_type = $request->input('pay_type', 'points');
  603. $project_id = $request->input('project_id', 0);
  604. $is_deductible = $request->input('is_deductible', 0);
  605. if ($is_deductible==0) {
  606. $deductible = 0;
  607. } else {
  608. $deductible = $request->input('deductible', '');
  609. }
  610. $amount = floatval($request->input('amount', ''));
  611. if ($amount==0) {
  612. $pay_type = 'points';
  613. }
  614. if ($project_id==0) {
  615. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  616. }
  617. $user = auth('web-company')->user();
  618. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  619. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  620. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  621. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  622. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //增值包套餐金额
  623. if ($pay_type=='points') { //积分支付
  624. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //增值包套餐所需积分
  625. if ($my_point->points < $service_need_points) {
  626. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!']);
  627. }
  628. //操作事务开始
  629. DB::beginTransaction();
  630. try {
  631. $companySms = $this->membersSetmealService->actionUserSetmeal($user->id, 'jobfair_num', 1, $increment_info->value);
  632. if (!$companySms) {
  633. throw new \Exception('会员招聘会场次数量增加失败!');
  634. }
  635. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  636. $stime = time();
  637. //添加订单信息
  638. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, '', '专享'.$my_discount.'折优惠');
  639. if (!$order) {
  640. throw new \Exception('生成订单失败!');
  641. }
  642. $oid = $this->payService->getTradeNo($order->id);//订单号
  643. if (!$this->serviceService->updateOid($order->id, $oid)) {
  644. throw new \Exception('生成订单号失败!');
  645. }
  646. //会员日志:添加创建增值服务订单日志
  647. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  648. //修改会员积分
  649. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  650. throw new \Exception('修改会员积分失败!');
  651. } else {
  652. $handsel['uid'] = $user->id;
  653. $handsel['utype'] = $user->utype;
  654. $handsel['htype'] = 'increment_jobfair_num';
  655. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  656. $handsel['operate'] = 2;
  657. $handsel['points'] = $service_need_points;
  658. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  659. throw new \Exception('添加积分操作记录失败!');
  660. }
  661. }
  662. DB::commit();
  663. } catch (\Exception $e) {
  664. DB::rollback();
  665. return array( 'status'=>0, 'msg' => $e->getMessage());
  666. }
  667. return array( 'status'=>1, 'msg' => '积分兑换成功!','data'=>$oid);
  668. } else {
  669. if ($is_deductible==1 && $my_point->points<$deductible) {
  670. return array( 'status'=>0, 'msg' => '积分不足,请使用其他方式支付!');
  671. }
  672. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', '', 0, $project_id, '专享'.$my_discount.'折优惠');
  673. }
  674. }
  675. /**购买职位增值包
  676. * @param $request
  677. * @return array|\Illuminate\Http\JsonResponse
  678. * @throws ResponseException
  679. * @throws \Prettus\Validator\Exceptions\ValidatorException
  680. */
  681. protected function incrementJobs($request)
  682. {
  683. $cat = $request->input('service_type', 'jobs');
  684. $order_pay_type = 15;
  685. $payment_name = $request->input('payment_name', '');
  686. $pay_type = $request->input('pay_type', 'points');
  687. $project_id = $request->input('project_id', 0);
  688. $is_deductible = $request->input('is_deductible', 0);
  689. if ($is_deductible==0) {
  690. $deductible = 0;
  691. } else {
  692. $deductible = $request->input('deductible', '');
  693. }
  694. $amount = floatval($request->input('amount', ''));
  695. if ($amount==0) {
  696. $pay_type = 'points';
  697. }
  698. if ($project_id==0) {
  699. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  700. }
  701. $user = auth('web-company')->user();
  702. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  703. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  704. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  705. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  706. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //增值包套餐金额
  707. if ($pay_type=='points') { //积分支付
  708. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //增值包套餐所需积分
  709. if ($my_point->points < $service_need_points) {
  710. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!']);
  711. }
  712. //操作事务开始
  713. DB::beginTransaction();
  714. try {
  715. $companySms = $this->membersSetmealService->actionUserSetmeal($user->id, 'jobs_meanwhile', 1, $increment_info->value);
  716. if (!$companySms) {
  717. throw new \Exception('会员可发布职位数量增加失败!');
  718. }
  719. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  720. $stime = time();
  721. //添加订单信息
  722. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, '', '专享'.$my_discount.'折优惠');
  723. if (!$order) {
  724. throw new \Exception('生成订单失败!');
  725. }
  726. $oid = $this->payService->getTradeNo($order->id);//订单号
  727. if (!$this->serviceService->updateOid($order->id, $oid)) {
  728. throw new \Exception('生成订单号失败!');
  729. }
  730. //会员日志:添加创建增值服务订单日志
  731. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  732. //修改会员积分
  733. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  734. throw new \Exception('修改会员积分失败!');
  735. } else {
  736. $handsel['uid'] = $user->id;
  737. $handsel['utype'] = $user->utype;
  738. $handsel['htype'] = 'increment_jobs';
  739. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  740. $handsel['operate'] = 2;
  741. $handsel['points'] = $service_need_points;
  742. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  743. throw new \Exception('添加积分操作记录失败!');
  744. }
  745. }
  746. DB::commit();
  747. } catch (\Exception $e) {
  748. DB::rollback();
  749. return array( 'status'=>0, 'msg' => $e->getMessage());
  750. }
  751. return array( 'status'=>1, 'msg' => '积分兑换成功!','data'=>$oid);
  752. } else {
  753. if ($is_deductible==1 && $my_point->points<$deductible) {
  754. return array( 'status'=>0, 'msg' => '积分不足,请使用其他方式支付!');
  755. }
  756. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', '', 0, $project_id, '专享'.$my_discount.'折优惠');
  757. }
  758. }
  759. /**职位置顶
  760. * @param $request
  761. * @return \Illuminate\Http\JsonResponse
  762. * @throws ResponseException
  763. * @throws \Prettus\Validator\Exceptions\ValidatorException
  764. */
  765. protected function incrementStick($request)
  766. {
  767. $user = auth('web-company')->user();
  768. $cat = $request->input('service_type', 'stick');
  769. $order_pay_type = 8;
  770. $payment_name = $request->input('payment_name', '');
  771. $pay_type = $request->input('pay_type', 'points');
  772. $project_id = $request->input('project_id', 0);
  773. $is_deductible = $request->input('is_deductible', 0);
  774. $jobs_id = $request->input('jobs_id', 0);
  775. $form_validate = $request->input('form_validate', false); //支付宝支付是Form 表单提交的,错误信息返回json,不是form的就不进行callback
  776. if ($is_deductible==0) {
  777. $deductible = 0;
  778. } else {
  779. $deductible = $request->input('deductible', '');
  780. }
  781. $amount = floatval($request->input('amount', ''));
  782. if ($amount==0) {
  783. $pay_type = 'points';
  784. }
  785. if ($project_id==0) {
  786. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  787. }
  788. if (!$jobs_id) {
  789. return response()->json(['status'=>0, 'msg'=>"请选择职位!"]);
  790. }
  791. if (!$jobsRes = $this->jobsRepository->findWhere(['id'=>$jobs_id,'company_id'=>$user->id])->first()) {
  792. return response()->json(['status'=>0,'msg'=>'该职位不存在!']);
  793. }
  794. if ($this->jobsRepository->getInfo(['stick'=>1,'id'=>$jobs_id,])) {
  795. return response()->json(['status'=>0,'msg'=>'该职位已置顶!']);
  796. }
  797. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  798. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  799. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  800. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  801. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //智能刷新所需积分
  802. if ($pay_type=='points') { //积分支付
  803. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //智能刷新所需积分
  804. if ($my_point->points < $service_need_points) {
  805. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!']);
  806. }
  807. //操作事务开始
  808. DB::beginTransaction();
  809. try {
  810. $promotionsqlarr['companyid']=$user->id;
  811. $promotionsqlarr['jobid']=$jobs_id;
  812. $promotionsqlarr['ptype'] = 1;
  813. $promotionsqlarr['days']=$increment_info->value;
  814. $promotionsqlarr['starttime']=time();
  815. $promotionsqlarr['endtime']=strtotime("{$increment_info->value} day");
  816. $promotion_insert_id = Promotion::create($promotionsqlarr);
  817. if (!$promotion_insert_id) {
  818. throw new \Exception('职位置顶添加失败!');
  819. }
  820. // $refresh_time = $this->jobsRepository->getFires($jobs_id);
  821. $stick_time = time();
  822. $this->jobsRepository->update(['stime'=>$stick_time, 'stick'=>1], $jobs_id);
  823. $params_array = array('days'=>$increment_info['value']);
  824. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  825. $stime = time();
  826. $params_array['jobs_id'] = $jobs_id;
  827. //添加订单信息
  828. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, serialize($params_array), '专享'.$my_discount.'折优惠');
  829. if (!$order) {
  830. throw new \Exception('生成订单失败!');
  831. }
  832. $oid = $this->payService->getTradeNo($order->id);//订单号
  833. if (!$this->serviceService->updateOid($order->id, $oid)) {
  834. throw new \Exception('生成订单号失败!');
  835. }
  836. //会员日志:添加创建增值服务订单日志
  837. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  838. //修改会员积分
  839. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  840. throw new \Exception('修改会员积分失败!');
  841. } else {
  842. $handsel['uid'] = $user->id;
  843. $handsel['utype'] = $user->utype;
  844. $handsel['htype'] = 'increment_download_resume';
  845. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  846. $handsel['operate'] = 2;
  847. $handsel['points'] = $service_need_points;
  848. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  849. throw new \Exception('添加积分操作记录失败!');
  850. }
  851. }
  852. DB::commit();
  853. } catch (\Exception $e) {
  854. DB::rollback();
  855. return response()->json(['status'=>0, 'msg' => $e->getMessage()]);
  856. }
  857. event_search_update(Jobs::class, (string)$jobs_id, 'update');
  858. return response()->json(['status'=>1, 'msg' => '积分兑换成功!','data'=>$oid]);
  859. } else {
  860. if ($is_deductible==1 && $my_point->points<$deductible) {
  861. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!!']);
  862. }
  863. if ($form_validate){//是否是表单验证的
  864. //返回之后支付宝再用form 表单再请求一遍
  865. return response()->json(['status'=>1, 'msg' => '验证成功!']);
  866. }
  867. $params['jobs_id'] = $jobs_id;
  868. $params['days'] = $increment_info['value'];
  869. $nowtime = time();
  870. $params['starttime'] = $nowtime;
  871. for ($i=0; $i < $params['days']*4; $i++) {
  872. $timespace = 3600*6*$i;
  873. if ($i+1==$params['days']*4) {
  874. $params['endtime'] = $nowtime+$timespace;
  875. }
  876. }
  877. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', $params, 0, $project_id, '专享'.$my_discount.'折优惠');
  878. }
  879. }
  880. /**职位紧急
  881. * @param $request
  882. * @return \Illuminate\Http\JsonResponse
  883. * @throws ResponseException
  884. * @throws \Prettus\Validator\Exceptions\ValidatorException
  885. */
  886. protected function incrementEmergency($request)
  887. {
  888. $user = auth('web-company')->user();
  889. $cat = $request->input('service_type', 'emergency');
  890. $order_pay_type = 9;
  891. $payment_name = $request->input('payment_name', '');
  892. $pay_type = $request->input('pay_type', 'points');
  893. $project_id = $request->input('project_id', 0);
  894. $is_deductible = $request->input('is_deductible', 0);
  895. $jobs_id = $request->input('jobs_id', 0);
  896. $form_validate = $request->input('form_validate', false); //支付宝支付是Form 表单提交的,错误信息返回json,不是form的就不进行callback
  897. if ($is_deductible==0) {
  898. $deductible = 0;
  899. } else {
  900. $deductible = $request->input('deductible', '');
  901. }
  902. $amount = floatval($request->input('amount', ''));
  903. if ($amount==0) {
  904. $pay_type = 'points';
  905. }
  906. if ($project_id==0) {
  907. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  908. }
  909. if (!$jobs_id) {
  910. return response()->json(['status'=>0, 'msg'=>"请选择职位!"]);
  911. }
  912. if (!$jobsRes = $this->jobsRepository->findWhere(['id'=>$jobs_id,'company_id'=>$user->id])->first()) {
  913. return response()->json(['status'=>0,'msg'=>'该职位不存在!']);
  914. }
  915. if ($this->jobsRepository->getInfo(['emergency'=>1,'id'=>$jobs_id,])) {
  916. return response()->json(['status'=>0,'msg'=>'该职位已紧急!']);
  917. }
  918. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  919. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  920. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  921. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  922. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //智能刷新所需积分
  923. if ($pay_type=='points') { //积分支付
  924. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //智能刷新所需积分
  925. if ($my_point->points < $service_need_points) {
  926. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!']);
  927. }
  928. //操作事务开始
  929. DB::beginTransaction();
  930. try {
  931. $promotionsqlarr['companyid']=$user->id;
  932. $promotionsqlarr['jobid']=$jobs_id;
  933. $promotionsqlarr['ptype'] = 2;
  934. $promotionsqlarr['days']=$increment_info->value;
  935. $promotionsqlarr['starttime']=time();
  936. $promotionsqlarr['endtime']=strtotime("{$increment_info->value} day");
  937. $promotion_insert_id = $this->promotionRepository->create($promotionsqlarr);
  938. if (!$promotion_insert_id) {
  939. throw new \Exception('职位紧急添加失败!');
  940. }
  941. $this->jobsRepository->update(['emergency'=>1], $jobs_id);
  942. $params_array = array('days'=>$increment_info['value']);
  943. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  944. $stime = time();
  945. $params_array['jobs_id'] = $jobs_id;
  946. //添加订单信息
  947. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, serialize($params_array), '专享'.$my_discount.'折优惠');
  948. if (!$order) {
  949. throw new \Exception('生成订单失败!');
  950. }
  951. $oid = $this->payService->getTradeNo($order->id);//订单号
  952. if (!$this->serviceService->updateOid($order->id, $oid)) {
  953. throw new \Exception('生成订单号失败!');
  954. }
  955. //会员日志:添加创建增值服务订单日志
  956. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  957. //修改会员积分
  958. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  959. throw new \Exception('修改会员积分失败!');
  960. } else {
  961. $handsel['uid'] = $user->id;
  962. $handsel['utype'] = $user->utype;
  963. $handsel['htype'] = 'increment_download_resume';
  964. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  965. $handsel['operate'] = 2;
  966. $handsel['points'] = $service_need_points;
  967. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  968. throw new \Exception('添加积分操作记录失败!');
  969. }
  970. }
  971. DB::commit();
  972. } catch (\Exception $e) {
  973. DB::rollback();
  974. return response()->json(['status'=>0, 'msg' => $e->getMessage()]);
  975. }
  976. event_search_update(Jobs::class, (string)$jobs_id, 'update');
  977. return response()->json(['status'=>1, 'msg' => '积分兑换成功!','data'=>$oid]);
  978. } else {
  979. if ($is_deductible==1 && $my_point->points<$deductible) {
  980. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!!']);
  981. }
  982. if ($form_validate){//是否是表单验证的
  983. //返回之后支付宝再用form 表单再请求一遍
  984. return response()->json(['status'=>1, 'msg' => '验证成功!']);
  985. }
  986. $params['jobs_id'] = $jobs_id;
  987. $params['days'] = $increment_info['value'];
  988. $nowtime = time();
  989. $params['starttime'] = $nowtime;
  990. for ($i=0; $i < $params['days']*4; $i++) {
  991. $timespace = 3600*6*$i;
  992. if ($i+1==$params['days']*4) {
  993. $params['endtime'] = $nowtime+$timespace;
  994. }
  995. }
  996. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', $params, 0, $project_id, '专享'.$my_discount.'折优惠');
  997. }
  998. }
  999. /**企业模版
  1000. * @param $request
  1001. * @return ServiceController
  1002. */
  1003. protected function incrementTpl(Request $request)
  1004. {
  1005. $result = $this->companyTplService->incrementTpl(auth('web-company')->user(), $request->all(), $request->route());
  1006. if ($result['code']=='wechat') {
  1007. if ($result['type']=='wap') {
  1008. return $result['tradeCode'];
  1009. } else {
  1010. return json_encode(['tradeCode'=>$result['tradeCode'],'tradeNo'=>$result['tradeNo']]);
  1011. }
  1012. } elseif ($result['code']=='alipay') {
  1013. return $result['tradeCode'];
  1014. } elseif ($result['code']=='offline') {
  1015. return json_encode(['tradeNo'=>$result['tradeNo']]);
  1016. } else {
  1017. if ($result['status']==1) {
  1018. return $this->sendSuccessResponse($result['info']);
  1019. } else {
  1020. return $this->sendErrorResponse($result['info'], '', 400);
  1021. }
  1022. }
  1023. }
  1024. /**智能刷新
  1025. * @param $request
  1026. * @return \Illuminate\Http\JsonResponse
  1027. * @throws ResponseException
  1028. * @throws \Prettus\Validator\Exceptions\ValidatorException
  1029. */
  1030. protected function incrementAutoRefreshJobs($request)
  1031. {
  1032. $cat = $request->input('service_type', 'auto_refresh_jobs');
  1033. $order_pay_type = 12;
  1034. $payment_name = $request->input('payment_name', '');
  1035. $pay_type = $request->input('pay_type', 'points');
  1036. $project_id = $request->input('project_id', 0);
  1037. $is_deductible = $request->input('is_deductible', 0);
  1038. $jobs_id = $request->input('id', 0);
  1039. $form_validate = $request->input('form_validate', false); //支付宝支付是Form 表单提交的,错误信息返回json,不是form的就不进行callback
  1040. if ($is_deductible==0) {
  1041. $deductible = 0;
  1042. } else {
  1043. $deductible = $request->input('deductible', '');
  1044. }
  1045. $amount = floatval($request->input('amount', ''));
  1046. if ($amount==0) {
  1047. $pay_type = 'points';
  1048. }
  1049. if ($project_id==0) {
  1050. return response()->json(['status'=>0, 'msg' => '请选择增值包套餐!']);
  1051. }
  1052. if (!$jobs_id) {
  1053. return response()->json(['status'=>0, 'msg'=>"请选择职位!"]);
  1054. }
  1055. if ($this->queueAutoRefreshRepository->findData(['type'=>1, 'pid'=>$jobs_id])) {
  1056. return response()->json(['status'=>0,'msg'=>'该职位已预约刷新!']);
  1057. }
  1058. $user = auth('web-company')->user();
  1059. $my_setmeal = $this->membersSetmealService->getUserSetmeal($user, '1'); //会员套餐信息
  1060. if (isExpire($my_setmeal)){
  1061. return response()->json( ['status' => 0, 'msg' => "提醒:您的套餐已到期,请及时到我的套餐处升级套餐!"]);
  1062. }
  1063. $my_point = $this->memberPointService->getPoints($user->id, 1); //获取会员积分信息
  1064. $increment_info = $this->setmealIncrementsService->getIncrement($project_id); //获取所选简历增值包信息
  1065. $my_discount = $this->setmealIncrementsService->getIncrementDiscountByArray($cat, $my_setmeal); //套餐折扣
  1066. $service_need_cash = $my_discount > 0 ?round($increment_info->price*$my_discount/10, 2):$increment_info->price; //智能刷新所需积分
  1067. if ($pay_type=='points') { //积分支付
  1068. $service_need_points = round($service_need_cash*config('aix.companyset.points.points_set.payment_rate')); //智能刷新所需积分
  1069. if ($my_point->points < $service_need_points) {
  1070. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!']);
  1071. }
  1072. //操作事务开始
  1073. DB::beginTransaction();
  1074. try {
  1075. //添加自动刷新记录
  1076. $days = $increment_info->value;
  1077. $params_array['days'] = $days;
  1078. $nowtime = time();
  1079. $params_array['days'] = $nowtime;
  1080. $params_array['starttime'] = $nowtime;
  1081. for ($i=0; $i < $days*4; $i++) {
  1082. $timespace = 3600*6*$i;
  1083. $this->queueAutoRefreshRepository->create(['uid'=>$user->id,'pid'=>$jobs_id,'type'=>1,'refreshtime'=>$nowtime+$timespace]);
  1084. if ($i+1==$days*4) {
  1085. $params_array['endtime'] = $nowtime+$timespace;
  1086. }
  1087. }
  1088. $params_array['jobs_id'] = $jobs_id;
  1089. $description1 = '购买服务:'.$increment_info->name.';积分支付:'.$service_need_points.'积分';
  1090. $stime = time();
  1091. //添加订单信息
  1092. $order = $this->orderService->addOrder($user, $order_pay_type, $service_need_cash, 0, $service_need_points, $increment_info->name, $payment_name, '积分支付', $description1, 2, 0, $project_id, $stime, serialize($params_array), '专享'.$my_discount.'折优惠');
  1093. if (!$order) {
  1094. throw new \Exception('生成订单失败!');
  1095. }
  1096. $oid = $this->payService->getTradeNo($order->id);//订单号
  1097. if (!$this->serviceService->updateOid($order->id, $oid)) {
  1098. throw new \Exception('生成订单号失败!');
  1099. }
  1100. //会员日志:添加创建增值服务订单日志
  1101. $log_rst1 = $this->serviceService->writeMembersLog($user, '9001', [$oid,'积分兑换','']);
  1102. //修改会员积分
  1103. if (false === $p_rst = $this->memberPointService->reportDeal($user->id, $user->utype, 2, $service_need_points)) {
  1104. throw new \Exception('修改会员积分失败!');
  1105. } else {
  1106. $handsel['uid'] = $user->id;
  1107. $handsel['utype'] = $user->utype;
  1108. $handsel['htype'] = 'increment_download_resume';
  1109. $handsel['htype_cn'] = '购买增值包:' . $increment_info->name;
  1110. $handsel['operate'] = 2;
  1111. $handsel['points'] = $service_need_points;
  1112. if (!$this->memberHandselRepository->addNew($handsel)) { //添加积分操作记录
  1113. throw new \Exception('添加积分操作记录失败!');
  1114. }
  1115. }
  1116. DB::commit();
  1117. } catch (\Exception $e) {
  1118. DB::rollback();
  1119. return response()->json(['status'=>0, 'msg' => $e->getMessage()]);
  1120. }
  1121. return response()->json(['status'=>1, 'msg' => '积分兑换成功!','data'=>$oid]);
  1122. } else {
  1123. if ($is_deductible==1 && $my_point->points<$deductible) {
  1124. return response()->json(['status'=>0, 'msg' => '积分不足,请使用其他方式支付!!']);
  1125. }
  1126. if ($form_validate){//是否是表单验证的
  1127. //返回之后支付宝再用form 表单再请求一遍
  1128. return response()->json(['status'=>1, 'msg' => '验证成功!']);
  1129. }
  1130. $params['jobs_id'] = $jobs_id;
  1131. $params['days'] = $increment_info['value'];
  1132. $nowtime = time();
  1133. $params['starttime'] = $nowtime;
  1134. for ($i=0; $i < $params['days']*4; $i++) {
  1135. $timespace = 3600*6*$i;
  1136. if ($i+1==$params['days']*4) {
  1137. $params['endtime'] = $nowtime+$timespace;
  1138. }
  1139. }
  1140. return $this->callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name, $service_need_cash, $is_deductible, $deductible, '', $params, 0, $project_id, '专享'.$my_discount.'折优惠');
  1141. }
  1142. }
  1143. /**购买积分
  1144. * @return ServiceController|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1145. */
  1146. public function pointsAdd()
  1147. {
  1148. if (!config('aix.companyset.points.points_set.enable_com_buy_points')) {
  1149. return $this->sendErrorResponse('参数错误!', 404);
  1150. }
  1151. $res = $this->serviceService->pointsAdd();
  1152. return view('jkq.company.increment.points_add', $res);
  1153. }
  1154. public function pointsSave(Request $request)
  1155. {
  1156. if (!config('aix.companyset.points.points_set.enable_com_buy_points')) {
  1157. return $this->sendErrorResponse('企业充值未开启,请联系网站管理员!', 404);
  1158. }
  1159. $payment_name = $request->input('payment_name', '');
  1160. $points = $request->input('points', 0);
  1161. if (!$points) {
  1162. return response()->json(['status'=>0, 'msg'=>"请输入要购买的积分数量!"]);
  1163. } elseif ($points < config('aix.companyset.points.points_set.com_buy_points_min')) {
  1164. $points = config('aix.companyset.points.points_set.com_buy_points_min');
  1165. }
  1166. $service_need_cash = round($points/config('aix.companyset.points.points_set.payment_rate'), 2);
  1167. $paymenttpye = $this->paymentService->returnPayment($payment_name);
  1168. if (!$paymenttpye) {
  1169. return array( 'status'=>0, 'msg' => '支付方式错误!');
  1170. }
  1171. $user = auth('web-company')->user();
  1172. $description = '购买积分';
  1173. $params['points'] = $points;
  1174. $params['cash'] = $service_need_cash;
  1175. $params['rate'] = config('aix.companyset.points.points_set.payment_rate');
  1176. $order = $this->orderService->addOrder($user, 2, $service_need_cash, $service_need_cash, 0, '购买积分', $payment_name, $paymenttpye->name, $description, 1, 0, 0, 0, serialize($params));
  1177. $tradeNo = $this->payService->getTradeNo($order->id);
  1178. if (!$this->serviceService->updateOid($order->id, $tradeNo)) {
  1179. throw new ResponseException('生成订单号失败!');
  1180. }
  1181. if ($payment_name == 'wechat') {
  1182. $type = 'scan';
  1183. } elseif ($payment_name == 'offline') {
  1184. $type = 'pay';
  1185. } else {
  1186. $type = 'web';
  1187. }
  1188. $payOrder = new PayOrder();
  1189. $payOrder->trade_no = $tradeNo;
  1190. $payOrder->subject = '购买积分';
  1191. $payOrder->detail = $description;
  1192. $payOrder->price = $service_need_cash;
  1193. $payOrder->callback = "App\Services\Common\OrderService.pointsSave";
  1194. $result = $this->payService->pay($payment_name, $type, $payOrder);
  1195. if ($payment_name == 'wechat') {
  1196. return response()->json([
  1197. 'status' => 1,
  1198. 'tradeCode' => get_qrcode_html($result->code_url),
  1199. 'tradeNo' => $tradeNo,
  1200. ]);
  1201. } elseif ($payment_name == 'offline') {
  1202. return response()->json([
  1203. 'status'=>1,
  1204. 'tradeNo'=>$tradeNo,
  1205. 'url'=>route("service.order.detail",['id'=>$order->id]),
  1206. ]);
  1207. } else {
  1208. return $result;
  1209. }
  1210. }
  1211. /**现金支付
  1212. * @param $resume_id
  1213. * @param $my_setmeal
  1214. * @param $my_point
  1215. * @param $increment_info
  1216. * @param $order_pay_type
  1217. * @param string $payment_name
  1218. * @param string $amount
  1219. * @param $is_deductible
  1220. * @param int $deductible
  1221. * @param string $description
  1222. * @param string $params
  1223. * @param int $points
  1224. * @param int $stemeal
  1225. * @param string $discount
  1226. * @return \Illuminate\Http\JsonResponse
  1227. * @throws ResponseException
  1228. * @throws \Prettus\Validator\Exceptions\ValidatorException
  1229. */
  1230. protected function callCashPay($my_setmeal, $my_point, $increment_info, $order_pay_type, $payment_name = '', $amount = '0.0', $is_deductible, $deductible = 0, $description = '', $params = '', $points = 0, $stemeal = 0, $discount = '')
  1231. {
  1232. //获取支付方式
  1233. $paymenttpye = $this->paymentService->returnPayment($payment_name);
  1234. if (!$paymenttpye) {
  1235. return array( 'status'=>0, 'msg' => '支付方式错误!');
  1236. }
  1237. if (!config("aix.system.pay.{$payment_name}.is_on")) {
  1238. if ($payment_name == 'alipay') {
  1239. return "支付方式未开启!请联系客服电话:【".config('aix.system.pay.offline.service_tel')."】";
  1240. } else {
  1241. return array( 'status'=>0, 'msg' => "支付方式未开启!请联系客服电话:【".config('aix.system.pay.offline.service_tel')."】");
  1242. }
  1243. }
  1244. if ($payment_name == 'wechat') {
  1245. $type = 'scan';
  1246. } elseif ($payment_name == 'alipay') {
  1247. $type = 'web';
  1248. } elseif ($payment_name == 'offline') { //如果是线下转账
  1249. /**
  1250. * 把积分设为0,产生原因:线下线上用的同一个请求参数,
  1251. * 切换时候没有擦除,会带上积分
  1252. * bug-#1255
  1253. */
  1254. $is_deductible=0;
  1255. $type='pay';
  1256. }
  1257. if ($my_point->points < $deductible) {
  1258. return array( 'status'=>0, 'msg' => '积分不足,请使用其他方式支付!');
  1259. }
  1260. if ($is_deductible==0) {
  1261. $deductible = 0;
  1262. }
  1263. if ($deductible>0) {
  1264. $m_amount = round($amount- floatval($deductible/config('aix.companyset.points.points_set.payment_rate')),2);
  1265. } else {
  1266. $m_amount = $amount;
  1267. }
  1268. $paysetarr['ordtotal_fee']=$m_amount;
  1269. if ($description=='') {
  1270. $description = '购买服务:'.$increment_info->name;
  1271. }
  1272. $description .= ';'.$paymenttpye->name.$paysetarr['ordtotal_fee'].'元';
  1273. if ($deductible>0) {
  1274. $description .= ';积分支付:'.$deductible.'积分';
  1275. }
  1276. $stime = time();
  1277. $user = auth('web-company')->user();
  1278. //生成订单
  1279. $order = $this->orderService->addOrder($user, $order_pay_type, $amount, $paysetarr['ordtotal_fee'], $deductible, $increment_info->name, $payment_name, $paymenttpye->name, $description, 1, $deductible, $stemeal, 0, serialize($params), $discount);
  1280. $tradeNo = $this->payService->getTradeNo($order->id);
  1281. if (!$this->serviceService->updateOid($order->id, $tradeNo)) {
  1282. throw new ResponseException('生成订单号失败!');
  1283. }
  1284. $payOrder = new PayOrder();
  1285. $payOrder->trade_no = $tradeNo;
  1286. $payOrder->subject = '购买' . $increment_info->name;
  1287. $payOrder->detail = $description;
  1288. $payOrder->price = round($m_amount, 2);
  1289. $payOrder->callback = "App\Services\Common\OrderService.incrementSave";
  1290. $payOrder->return_url = route('jkq.service.order.index');
  1291. $result = $this->payService->pay($payment_name, $type, $payOrder);
  1292. if ($payment_name == 'wechat') {
  1293. return response()->json([
  1294. 'status' => 1,
  1295. 'tradeCode' => get_qrcode_html($result->code_url),
  1296. 'tradeNo' => $tradeNo,
  1297. ]);
  1298. } elseif ($payment_name =='alipay') {
  1299. return $result;
  1300. } else {
  1301. return response()->json([
  1302. 'status'=>1,
  1303. 'tradeNo'=>$tradeNo,
  1304. 'url'=>route("jkq.service.order.detail",['id'=>$order->id]),
  1305. ]);
  1306. }
  1307. }
  1308. /**订单列表
  1309. * @param Request $request
  1310. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1311. */
  1312. public function orderList(Request $request)
  1313. {
  1314. $user = auth('web-company')->user();
  1315. $res = $this->orderService->orderList($request->all(), $user);
  1316. return view('jkq.company.order.index', $res);
  1317. }
  1318. public function templateList()
  1319. {
  1320. $res = $this->companyTplService->templateList(auth('web-company')->user());
  1321. return view('jkq.company.increment.template', $res);
  1322. }
  1323. public function companyUpdate(Request $request)
  1324. {
  1325. $result = $this->companyTplService->companyUpdate(auth('web-company')->user(), $request->tpl);
  1326. if ($result) {
  1327. return $this->sendSuccessResponse('更新成功!');
  1328. } else {
  1329. return $this->sendErrorResponse('更新失败!');
  1330. }
  1331. }
  1332. public function complaintConsultant(Request $request)
  1333. {
  1334. if($request->method()=='POST'){
  1335. $result = $this->complaintConsultantService->getCompanyConsultant(auth('web-company')->user(), $request->all());
  1336. if ($result) {
  1337. return $this->sendSuccessResponse('投诉成功!');
  1338. } else {
  1339. return $this->sendErrorResponse('投诉失败!');
  1340. }
  1341. }else{
  1342. $arr['name'] = $request->name;
  1343. $arr['id'] = $request->id;
  1344. $html = view('jkq.company.ajax.complaint_consultant', $arr)->render();
  1345. return response()->json(['html'=>$html]);
  1346. }
  1347. }
  1348. /**删除订单
  1349. * @param Request $request
  1350. * @return \Illuminate\Http\JsonResponse
  1351. * @throws \Throwable
  1352. */
  1353. public function orderDel(Request $request)
  1354. {
  1355. $id = $request->id?$request->id:0;
  1356. if (!$id) {
  1357. return response()->json(['status'=>0,'msg'=>'参数错误']);
  1358. }
  1359. if ($request->method()=='POST') {
  1360. $user = auth('web-company')->user();
  1361. return $this->orderService->orderDel($id,$user);
  1362. }
  1363. $tip='订单被删除后无法恢复,您确定要删除该订单吗?';
  1364. return response()->json(['status'=>1, 'msg'=>'', 'data'=>['html'=>view('jkq.company.ajax.ajax_warning', ['tip'=>$tip])->render()]]);
  1365. }
  1366. /**订单取消
  1367. * @param Request $request
  1368. * @return \Illuminate\Http\JsonResponse
  1369. * @throws \Throwable
  1370. */
  1371. public function orderCancel(Request $request)
  1372. {
  1373. $user = auth('web-company')->user();
  1374. $id = $request->id?$request->id:0;
  1375. if (!$id) {
  1376. return response()->json(['status'=>0,'msg'=>'参数错误']);
  1377. }
  1378. if ($request->method() == 'POST') {
  1379. return $this->orderService->orderCancel($id, $user);
  1380. }
  1381. $tip='您确定要取消该订单吗?';
  1382. $description='如果您在支付过程中遇到问题,可以联系网站客服,联系电话:'.config('aix.system.site.site.bootom_tel').'。';
  1383. return response()->json(['status'=>1, 'msg'=>'', 'data'=>['html'=>view('jkq.company.ajax.ajax_warning', ['tip'=>$tip, 'description'=>$description])->render()]]);
  1384. }
  1385. /**订单详情
  1386. * @param $id
  1387. * @return ServiceController|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1388. * @throws ResponseException
  1389. */
  1390. public function orderDetail($id)
  1391. {
  1392. if (!$id) {
  1393. return $this->sendErrorResponse('参数错误!', 404);
  1394. }
  1395. $user = auth('web-company')->user();
  1396. $res = $this->orderService->orderDetail($id, $user);
  1397. if ($res['order']->is_pay==2 || $res['order']->is_pay==3) {
  1398. $tpl = 'order_detail';
  1399. } else {
  1400. $tpl = 'order_detail_nopay';
  1401. }
  1402. return view("jkq.company.order.{$tpl}", $res);
  1403. }
  1404. /**索要发票
  1405. * @param Request $request
  1406. * @return array|\Illuminate\Http\JsonResponse
  1407. */
  1408. public function invoiceSave(Request $request)
  1409. {
  1410. $data = $request->except('_token');
  1411. $user = auth('web-company')->user();
  1412. return $this->orderService->invoiceSave($data, $user);
  1413. }
  1414. /**重新支付
  1415. * @param int $id
  1416. * @return ServiceController|\Illuminate\Http\JsonResponse
  1417. * @throws ResponseException
  1418. */
  1419. public function orderPayRepeat($id = 0)
  1420. {
  1421. if (!$id) {
  1422. return $this->sendErrorResponse('参数错误!', 404);
  1423. }
  1424. return $this->orderService->orderPayRepeat($id);
  1425. }
  1426. /**
  1427. * 电子票据
  1428. */
  1429. // public function enote($id = 0)
  1430. // {
  1431. // if (!$id) {
  1432. // return response()->json(['status'=>0, 'msg'=>"参数错误!"]);
  1433. // }
  1434. // $res = $this->orderService->enote($id);
  1435. // return response()->json(['status'=>1,'msg'=>'获取数据成功!','data'=>['html'=>view('app.company.ajax.ajax_enote', $res)->render()]]);
  1436. // }
  1437. /**订单支付成功
  1438. * @param $oid
  1439. * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  1440. * @throws ResponseException
  1441. */
  1442. public function setmealFinish($oid)
  1443. {
  1444. $res = $this->serviceService->setmealFinish($oid);
  1445. return view('jkq.company.service.order_finish', $res);
  1446. }
  1447. }