GoodsController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Common\GoodsService;
  5. use App\Services\Common\MemberService;
  6. /**
  7. * 商品
  8. * Class GoodsController
  9. * @package App\Http\Controllers\Api
  10. */
  11. class GoodsController extends webApp
  12. {
  13. public function index()
  14. {
  15. $params = request()->all();
  16. $pageSize = isset($params['pageSize'])? $params['pageSize'] : 18;
  17. $params['shop_id'] = $this->shopId;
  18. $params['is_trade'] = 2;
  19. $params['time'] = strtotime(date('Y-m-d'));
  20. $info = GoodsService::make()->getDataList($params, $pageSize);
  21. return message(1010, true, $info);
  22. }
  23. /**
  24. * 拆分
  25. * @return array
  26. */
  27. public function split()
  28. {
  29. $params = request()->all();
  30. $goodsId = isset($params['id'])? $params['id'] : 0;
  31. if(GoodsService::make()->split($goodsId)){
  32. return message(GoodsService::make()->getError(), true);
  33. }else{
  34. return message(GoodsService::make()->getError(), false);
  35. }
  36. }
  37. /**
  38. * 转场
  39. * @return array
  40. */
  41. public function change()
  42. {
  43. $params = request()->all();
  44. $goodsId = isset($params['id'])? $params['id'] : 0;
  45. if(GoodsService::make()->change($goodsId)){
  46. return message(GoodsService::make()->getError(), true);
  47. }else{
  48. return message(GoodsService::make()->getError(), false);
  49. }
  50. }
  51. /**
  52. * 转会员
  53. * @return array
  54. */
  55. public function switchUser()
  56. {
  57. $params = request()->all();
  58. if(GoodsService::make()->switchUser($params)){
  59. return message(GoodsService::make()->getError(), true);
  60. }else{
  61. return message(GoodsService::make()->getError(), false);
  62. }
  63. }
  64. /**
  65. * 封存
  66. * @return array
  67. */
  68. public function lock()
  69. {
  70. $params = request()->all();
  71. $goodsId = isset($params['id'])? $params['id'] : 0;
  72. if(GoodsService::make()->lock($goodsId)){
  73. return message(GoodsService::make()->getError(), true);
  74. }else{
  75. return message(GoodsService::make()->getError(), false);
  76. }
  77. }
  78. /**
  79. * 需改
  80. * @return array
  81. */
  82. public function updateData()
  83. {
  84. $params = request()->all();
  85. $goodsId = isset($params['id'])? $params['id'] : 0;
  86. if(GoodsService::make()->updateData($goodsId)){
  87. return message(GoodsService::make()->getError(), true);
  88. }else{
  89. return message(GoodsService::make()->getError(), false);
  90. }
  91. }
  92. }