ServiceController.php 72 KB

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