Order.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: zilongs
  5. * Date: 20-9-30
  6. * Time: 下午10:56
  7. */
  8. namespace App\Models;
  9. class Order extends BaseModel
  10. {
  11. protected $appends = ['is_evaluate', 'consult_duration', 'callback_phone'];
  12. CONST UNKONW = 0,UNPAID = 1, NOTACCEPT = 2, ISING = 3, FINISHED = 4,CANCELED=5,ISOUT=6,ISACCEPT=7;//订单状态(1.未支付 2.进行中 3.已完成 4.已取消)
  13. public static $_order_status = [
  14. self::UNKONW=>'未知',
  15. self::UNPAID=>'未支付',
  16. self::NOTACCEPT=>'待接单',
  17. self::ISING=>'进行中',
  18. self::FINISHED=>'已完成',
  19. self::CANCELED=>'已取消',
  20. self::ISOUT=>'已超时',
  21. self::ISACCEPT=>'已预约'
  22. ];
  23. //获取订单状态
  24. public static function getStatus()
  25. {
  26. return self::$_order_status;
  27. }
  28. // 支付状态(1.待付款 2.已付款 3.退款中 4.已退款 5.待退款)
  29. public static $_order_pay_status = [
  30. 1=>'待支付',
  31. 2=>'已付款',
  32. 3=>'退款中',
  33. 4=>'已退款',
  34. 5=>'待退款',
  35. ];
  36. public static function getPayStatus()
  37. {
  38. return self::$_order_pay_status;
  39. }
  40. //产品类型(1.电话咨询 2.图文咨询 3.门诊预约 4.疫苗接种预约 5.儿保预约 6.服务包 7.充值,8 快速预约 )
  41. public static $_order_product_types = [
  42. 1=>'电话咨询',
  43. 2=>'图文咨询',
  44. 3=>'门诊预约',
  45. 4=>'疫苗接种预约',
  46. 5=>'充值',
  47. 6=>'服务包',
  48. 7=>'充值',
  49. 8=>'快速预约',
  50. ];
  51. public static function getProductType()
  52. {
  53. return self::$_order_product_types;
  54. }
  55. public function docter()
  56. {
  57. return $this->belongsTo(Docter::class);
  58. }
  59. public function calllog()
  60. {
  61. return $this->hasMany(CallLog::class);
  62. }
  63. /**
  64. * 用户医生关注表
  65. * @return
  66. * @author Liu-Yh
  67. * Create By 2020/11/18 11:06
  68. */
  69. public function userDocter(){
  70. return $this->hasOne(UserDocter::class,'user_id','user_id')->select(['id', 'remark']);
  71. }
  72. public function patients(){
  73. return $this->belongsTo(Patient::class);
  74. }
  75. public function patient(){
  76. return $this->hasOne(Patient::class,'id','patient_id');
  77. }
  78. public function orderPatient()
  79. {
  80. return $this->hasOne(OrderPatient::class);
  81. }
  82. public function orderPack()
  83. {
  84. return $this->hasOne(OrderPack::class);
  85. }
  86. public function orderNurse()
  87. {
  88. return $this->hasMany(OrderNurse::class);
  89. }
  90. public function orderVaccine()
  91. {
  92. return $this->hasOne(OrderVaccine::class);
  93. }
  94. public function orderUser()
  95. {
  96. return $this->hasOne(User::class,'id','user_id');
  97. }
  98. public function organization()
  99. {
  100. return $this->belongsTo(Organization::class);
  101. }
  102. public function user()
  103. {
  104. return $this->belongsTo(User::class);
  105. }
  106. public function evaluate()
  107. {
  108. return $this->hasOne(Evaluate::class);
  109. }
  110. //支付完成的处理方法
  111. public static function payCompletedHandle($order_id)
  112. {
  113. $order = Order::with(['organization', 'orderVaccine', 'orderNurse', 'orderPack'])->where('id', $order_id)->first()->toArray();
  114. $orderPatient = OrderPatient::where('order_id', $order_id)->first();
  115. $user = User::where('id', $order['user_id'])->first();
  116. //更新订单
  117. $order_status = 2;
  118. if (in_array($order['product_type'], [3,4,5])) {
  119. $order_status = 7;
  120. }
  121. elseif ($order['product_type'] == 6) {
  122. $order_status = 3;
  123. }
  124. elseif ($order['product_type'] == 7) {
  125. $order_status = 4;
  126. //改变用户余额
  127. User::changeBalance($order['user_id'], $order['total_amount'], 2, $order['id'], '充值');
  128. }
  129. Order::where('id', $order_id)->update([
  130. 'order_status' => $order_status,
  131. 'payment_status' => 2,
  132. 'payment_time' => time(),
  133. ]);
  134. //发送下单消息
  135. if ($order['product_type'] < 6) {
  136. $product_type_text = config('config.product_type_map')[$order['product_type']];
  137. UserMessage::saveMessage($order['user_id'], 4, $order_id, [$product_type_text]);
  138. }
  139. elseif ($order['product_type'] == 6) {
  140. $orderPack = OrderPack::select(['pack_name', 'end_time'])->where('order_id', $order_id)->first();
  141. UserMessage::saveMessage($order['user_id'], 5, $order_id, [$orderPack['pack_name'], date('Y-m-d', $orderPack['end_time'])]);
  142. //更新用户为服务包用户
  143. User::where('id', $order['user_id'])->update(['is_pack' => 1]);
  144. }
  145. elseif ($order['product_type'] == 7) {
  146. UserMessage::saveMessage($order['user_id'], 7, $order_id, [round($order['total_amount']/100, 2), round($user['balance']/100, 2)]);
  147. }
  148. //发送余额付款成功消息
  149. if ($order['payment_type'] == 2 && $order['product_type'] != 4) {
  150. UserMessage::saveMessage($order['user_id'], 8, $order_id, [round($order['payment_amount']/100, 2), round($user['balance']/100, 2)]);
  151. }
  152. //发送医生端消息
  153. if (!empty($order['docter_id'])) {
  154. DocterMessage::saveMessage($order['docter_id'], $order['user_id'], 1, $order_id, [$order['order_sn']]);
  155. }
  156. //如果是服务包支付的,就扣服务包的次数
  157. if ($order['payment_type'] == 3) {
  158. OrderPack::deductPackData($order['pay_order_pack_id'], $order['product_type']);
  159. }
  160. //如果是门诊预约,预约时间段的订单数要加1
  161. if ($order['product_type'] == 3) {
  162. $schedule_date = date('Y-m-d', $orderPatient['appoint_start_time']);
  163. SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('schedule_type', 1)->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
  164. }
  165. //如果是儿保和疫苗预约,预约时间段的订单数要加1
  166. if (in_array($order['product_type'], [4,5])) {
  167. $schedule_date = date('Y-m-d', $orderPatient['appoint_start_time']);
  168. $schedule_type = $order['product_type'] == 4 ? 2 : 3;
  169. SchedulePeriod::where('organization_id', $order['organization_id'])->where('schedule_type', $schedule_type)->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
  170. }
  171. //如果是疫苗就减少疫苗库存
  172. if ($order['product_type'] == 4) {
  173. $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
  174. Vaccine::where('id', $orderVaccine['vaccine_id'])->decrement('stock');
  175. }
  176. //给用户发送微信消息
  177. $docter = Docter::where('id', $order['docter_id'])->first();
  178. if ($order['product_type'] == 1) {
  179. $official_arr = [$user['openid'], $docter['name'], date('Y-m-d H:i:s'), round($order['payment_amount']/100, 2)];
  180. $product_type_text = config('config.product_type_map')[$order['product_type']];
  181. $subscribe_arr = [$user['openid'], $product_type_text, $user['nickname'], date('Y-m-d H:i:s'), $product_type_text, round($order['payment_amount']/100, 2)];
  182. send_wechat_message(1, $official_arr, $subscribe_arr);
  183. }
  184. elseif ($order['product_type'] == 2) {
  185. $official_arr = [$user['openid'], $docter['name'], $orderPatient['name'], $orderPatient['symptoms'], date('Y-m-d H:i:s'), round($order['payment_amount']/100, 2)];
  186. $product_type_text = config('config.product_type_map')[$order['product_type']];
  187. $subscribe_arr = [$user['openid'], $product_type_text, $user['nickname'], date('Y-m-d H:i:s'), $product_type_text, round($order['payment_amount']/100, 2)];
  188. send_wechat_message(2, $official_arr, $subscribe_arr);
  189. }
  190. elseif ($order['product_type'] == 3) {
  191. $keyword2 = date('Y-m-d H:i', $orderPatient['appoint_start_time']).' - '.date('H:i', $orderPatient['appoint_end_time']);
  192. $official_arr = [$user['openid'], $docter['name'], $keyword2, $orderPatient['name'], $orderPatient['phone'], $order['organization']['name'], $order['organization']['address']];
  193. $subscribe_arr = [$user['openid'], $orderPatient['name'], $order['organization']['name'], $docter['name'], $keyword2];
  194. send_wechat_message(3, $official_arr, $subscribe_arr);
  195. }
  196. elseif ($order['product_type'] == 4) {
  197. $keyword2 = date('Y-m-d H:i', $orderPatient['appoint_start_time']).' - '.date('H:i', $orderPatient['appoint_end_time']);
  198. $official_arr = [$user['openid'], $order['organization']['name'], $order['order_vaccine']['vaccine_name'], $keyword2, $orderPatient['name'], $orderPatient['phone'], $order['organization']['name'], $order['organization']['address']];
  199. $subscribe_arr = [$user['openid'], $orderPatient['name'], $order['order_vaccine']['vaccine_name'], $order['organization']['name'], $keyword2];
  200. send_wechat_message(4, $official_arr, $subscribe_arr);
  201. }
  202. elseif ($order['product_type'] == 5) {
  203. $keyword2 = date('Y-m-d H:i', $orderPatient['appoint_start_time']).' - '.date('H:i', $orderPatient['appoint_end_time']);
  204. $official_arr = [$user['openid'], $order['organization']['name'], $order['order_nurse'][0]['nurse_name'], $keyword2, $orderPatient['name'], $orderPatient['phone'], $order['organization']['name'], $order['organization']['address']];
  205. $subscribe_arr = [$user['openid'], $orderPatient['name'], $order['order_nurse'][0]['nurse_name'], $order['organization']['name'], $keyword2];
  206. send_wechat_message(5, $official_arr, $subscribe_arr);
  207. }
  208. elseif ($order['product_type'] == 6) {
  209. $official_arr = [$user['openid'], $order['order_pack']['pack_name'], date('Y-m-d H:i:s', $order['order_pack']['start_time']), date('Y-m-d H:i:s', $order['order_pack']['end_time'])];
  210. $service_time = date('Y/m/d', $order['order_pack']['start_time']). ' - '. date('Y/m/d', $order['order_pack']['end_time']);
  211. $subscribe_arr = [$user['openid'], $order['order_pack']['pack_name'], $service_time, $user['nickname']];
  212. send_wechat_message(6, $official_arr, $subscribe_arr);
  213. }
  214. //给医生发送消息
  215. if (in_array($order['product_type'], [1,2])) {
  216. $docter_openid = Docter::where('id', $order['docter_id'])->value('openid');
  217. $official_arr = [$docter_openid, $order['order_sn'], config('config.product_type_map')[$order['product_type']], $orderPatient['name'], $orderPatient['phone']];
  218. send_wechat_message_to_docter(10, $official_arr);
  219. }
  220. elseif ($order['product_type'] == 3) {
  221. $docter_openid = Docter::where('id', $order['docter_id'])->value('openid');
  222. $keyword4 = date('Y-m-d H:i', $orderPatient['appoint_start_time']).' - '.date('H:i', $orderPatient['appoint_end_time']);
  223. $official_arr = [$docter_openid, $orderPatient['name'], $orderPatient['phone'], $keyword4, $order['organization']['name'], $docter['name']];
  224. send_wechat_message_to_docter(11, $official_arr);
  225. }
  226. return true;
  227. }
  228. public function suggest()
  229. {
  230. return $this->hasOne(Suggest::class)->select(['id', 'order_id']);
  231. }
  232. public function getIsEvaluateAttribute()
  233. {
  234. $is_evaluate = 0;
  235. $user = User::getUserByToken(false);
  236. if (!empty($user)) {
  237. if (Evaluate::where('order_id', $this->id)->where('user_id', $user['id'])->exists()) {
  238. $is_evaluate = 1;
  239. }
  240. }
  241. return $is_evaluate;
  242. }
  243. //取消订单,建议是在事务里面去调用
  244. public static function orderCancel($order_id, $order_notes = '')
  245. {
  246. $order = Order::with(['orderPatient'])->where('id', $order_id)->first()->toArray();
  247. //判断预约时间是否还剩1小时内
  248. $can_refund = true;
  249. if (in_array($order['product_type'], [3,4,5])) {
  250. $order_notes = '用户取消预约';
  251. if ($order['order_patient']['appoint_start_time'] - 3600 < time()) {
  252. $order_notes = '用户超时取消';
  253. $can_refund = false;
  254. }
  255. }
  256. //改变订单状态
  257. $updateOrder = ['order_status' => 5, 'order_notes' => $order_notes];
  258. if ($order['payment_status'] > 1) {
  259. //判断是余额支付还是服务包支付
  260. if ($order['payment_type'] == 3) {
  261. //退服务包的次数
  262. $map = [1 => 'phone_minutes', 2 => 'chat_num', 3 => 'appoint_num', 4 => 'vaccine_limit_amount', 5 => 'nurses_limit_amount'];
  263. OrderPack::where('id', $order['pay_order_pack_id'])->increment($map[$order['product_type']]);
  264. $updateOrder['cancel_time'] = time();
  265. $updateOrder['payment_status'] = 4;
  266. if ($order['product_type'] == 3 && !$can_refund) {
  267. $updateOrder['payment_status'] = 2;
  268. }
  269. }
  270. else {
  271. //退钱到余额
  272. if (!empty($order['payment_amount']) && $can_refund && $order['product_type'] != 5) {
  273. User::changeBalance($order['user_id'], $order['payment_amount'], 4, $order['id'], '取消订单退款');
  274. }
  275. $updateOrder['cancel_time'] = time();
  276. if ($can_refund) {
  277. $updateOrder['payment_status'] = 4;
  278. }
  279. if ($order['product_type'] == 5) {
  280. $updateOrder['payment_status'] = 5;
  281. }
  282. if ($order['product_type'] == 3 && !$can_refund) {
  283. $updateOrder['payment_status'] = 2;
  284. }
  285. }
  286. }
  287. Order::where('id', $order_id)->update($updateOrder);
  288. //如果是门诊预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
  289. if ($order['product_type'] == 3 && $can_refund) {
  290. $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
  291. SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('order_num', '>', 0)->decrement('order_num');
  292. }
  293. //如果是疫苗儿保预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
  294. if (in_array($order['product_type'], [4,5]) && $can_refund) {
  295. $schedule_type_map = [4 => 2, 5 => 3];
  296. $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
  297. SchedulePeriod::where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('schedule_type', $schedule_type_map[$order['product_type']])->where('order_num', '>', 0)->decrement('order_num');
  298. }
  299. //如果是疫苗预约那么取消订单就增加疫苗库存
  300. if ($order['product_type'] == 4) {
  301. $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
  302. Vaccine::where('id', $orderVaccine['vaccine_id'])->increment('stock');
  303. }
  304. //如果买的时候使用了优惠券,取消订单,要把优惠券返回回去
  305. $userCoupon = UserCoupon::where('user_id', $order['user_id'])->where('order_id', $order['id'])->where('status', 2)->first();
  306. if (!empty($userCoupon)) {
  307. $new_status = 1;
  308. if ($userCoupon['expire_time'] <= time()) {
  309. $new_status = 3;
  310. }
  311. UserCoupon::where('id', $userCoupon['id'])->update(['status' => $new_status, 'order_id' => 0, 'use_time' => 0]);
  312. }
  313. return true;
  314. }
  315. public function getConsultDurationAttribute()
  316. {
  317. $duration = 0;
  318. if ($this->product_type == 1) {
  319. $duration = CallLog::where('order_id', $this->id)->where('talk_time', '<>', null)->sum('talk_time');
  320. $duration = !empty($duration) ? $duration : 0;
  321. }
  322. elseif ($this->product_type == 2) {
  323. $duration = $this->end_time - $this->receiving_time;
  324. }
  325. return $duration > 0 ? $duration : 0;
  326. }
  327. public function getCallbackPhoneAttribute()
  328. {
  329. $secret_no = '';
  330. if ($this->product_type == 1) {
  331. $secret_no = CallLog::where('order_id', $this->id)->orderBy('id', 'desc')->value('secret_no');
  332. }
  333. return !empty($secret_no) ? $secret_no : '';
  334. }
  335. public static function checkOrder($order_id)
  336. {
  337. $order = Order::with(['orderPatient', 'orderVaccine'])->where('id', $order_id)->first()->toArray();
  338. $product_type = $order['product_type'];
  339. if (in_array($product_type, [1,2])) {
  340. //判断是否在服务时间内
  341. $now_line = (int)date('Hi');
  342. if (!DocterServiceTime::where('docter_id', $order['docter_id'])->where('type', $product_type)->where('start_time_line', '<=', $now_line)->where('end_time_line', '>', $now_line)->exists()) {
  343. exit_out(null, 10011, '当前不在医生服务时间内,不能下单');
  344. }
  345. //图文咨询订单未结束时不能针对同一医生再次下图文订单
  346. if ($product_type == 2 && Order::where('docter_id', $order['docter_id'])->where('product_type', 2)->where('user_id', $order['user_id'])->whereIn('order_status', [2,3])->exists()) {
  347. exit_out(null, 10012, '您已经下过该医生的图文订单了,并且订单还未完成');
  348. }
  349. }
  350. //检查号源
  351. elseif ($product_type == 3) {
  352. $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
  353. $schedulePeriod = SchedulePeriod::where('docter_id', $order['docter_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('schedule_type', 1)->first();
  354. if (empty($schedulePeriod)) {
  355. exit_out(null, 10012, '医生无该时间段的排班');
  356. }
  357. $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $order['docter_id'])->where('type', 1)->first();
  358. if ($docterSettings['service_num'] <= $schedulePeriod['order_num']) {
  359. exit_out(null, 10014, '医生该时间段已经预约满了');
  360. }
  361. }
  362. elseif (in_array($product_type, [4,5])) {
  363. if (Order::whereIn('product_type', [4,5])->where('user_id', $order['user_id'])->whereIn('order_status', [2,3])->exists()) {
  364. exit_out(null, 10012, '您已经下过'.config('config.product_type_map')[$product_type].'订单,并且订单还未完成');
  365. }
  366. $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
  367. $schedule_type_map = [4 => 2, 5 => 3];
  368. $schedulePeriod = SchedulePeriod::where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('organization_id', $order['organization_id'])->where('schedule_type', $schedule_type_map[$product_type])->first();
  369. if (empty($schedulePeriod)) {
  370. exit_out(null, 10013, '机构无该时间段的排班');
  371. }
  372. $docterSettings = DocterSetting::select(['service_num'])->where('org_id', $order['organization_id'])->where('type', $schedule_type_map[$product_type])->first();
  373. if ($docterSettings['service_num'] <= $schedulePeriod['order_num']) {
  374. exit_out(null, 10015, '机构该时间段已经预约满了');
  375. }
  376. }
  377. //疫苗预约检查库存是否足够
  378. if ($product_type == 4) {
  379. $stock = Vaccine::where('id', $order['order_vaccine']['vaccine_id'])->value('stock');
  380. if ($stock <= 0) {
  381. exit_out(null, 10009, '该疫苗库存不足');
  382. }
  383. }
  384. if ($order['payment_type'] == 3) {
  385. OrderPack::checkUserServicePack($order['pay_order_pack_id'], $order['user_id'], $product_type);
  386. }
  387. return true;
  388. }
  389. //后台预约订单取消
  390. public static function appiontOrderCancel($order_id, $order_notes = '')
  391. {
  392. $order = Order::with(['orderPatient'])->where('id', $order_id)->first()->toArray();
  393. //改变订单状态
  394. $updateOrder = ['order_status' => 5, 'order_notes' => $order_notes,'cancel_time'=>time()];
  395. if ($order['payment_status'] > 1) {
  396. //判断是余额支付还是服务包支付
  397. if ($order['payment_type'] == 3) {
  398. //退服务包的次数
  399. $map = [1 => 'phone_minutes', 2 => 'chat_num', 3 => 'appoint_num', 4 => 'vaccine_limit_amount', 5 => 'nurses_limit_amount'];
  400. OrderPack::where('id', $order['pay_order_pack_id'])->increment($map[$order['product_type']]);
  401. $updateOrder['payment_status'] = 4;
  402. }
  403. else {
  404. //申请退款
  405. $updateOrder['payment_status'] = 5;
  406. }
  407. }
  408. Order::where('id', $order_id)->update($updateOrder);
  409. //如果是门诊预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
  410. if ($order['product_type'] == 3) {
  411. $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
  412. SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('order_num', '>', 0)->decrement('order_num');
  413. }
  414. //如果是疫苗儿保预约且距离预约时间还有1个小时以上,那么预约时间段的订单数减1
  415. if (in_array($order['product_type'], [4,5])) {
  416. $schedule_type_map = [4 => 2, 5 => 3];
  417. $schedule_date = date('Y-m-d', $order['order_patient']['appoint_start_time']);
  418. SchedulePeriod::where('organization_id', $order['organization_id'])->where('time_period_id', $order['order_patient']['time_period_id'])->where('schedule_date', $schedule_date)->where('schedule_type', $schedule_type_map[$order['product_type']])->where('order_num', '>', 0)->decrement('order_num');
  419. }
  420. //如果是疫苗预约那么取消订单就增加疫苗库存
  421. if ($order['product_type'] == 4) {
  422. $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
  423. Vaccine::where('id', $orderVaccine['vaccine_id'])->increment('stock');
  424. }
  425. return true;
  426. }
  427. }