ItemController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * User: admin
  4. * Date Time: 2021/3/2 14:33
  5. */
  6. namespace hd\controllers;
  7. use biz\item\classes\PtItemClass;
  8. use bizGhs\item\classes\ItemClass;
  9. use bizGhs\item\services\ItemService;
  10. use common\components\util;
  11. use common\services\xhItemService;
  12. use Yii;
  13. class ItemController extends BaseController
  14. {
  15. public function actionList()
  16. {
  17. }
  18. public function actionAdd()
  19. {
  20. $post = Yii::$app->request->post();
  21. $post['adminId'] = $this->adminId;
  22. // $post['shopId'] = $this->shopId;
  23. $post['sjId'] = $this->sjId;
  24. ItemService::addGhsItem($post);
  25. util::complete('添加成功');
  26. }
  27. public function actionBatchAdd()
  28. {
  29. $post = Yii::$app->request->post();
  30. $data = $post['data']; //[{itemId:1000,classId:2,cost:1,addPrice:1,stockWarning:1}]
  31. if(empty($data)){
  32. util::fail("参数错误");
  33. }
  34. $data = json_decode($data,true);
  35. if(!is_array($data) || empty($data)){
  36. util::fail("参数格式错误");
  37. }
  38. foreach ($data as $v){
  39. $v['adminId'] = $this->adminId;
  40. $v['sjId'] = $this->sjId;
  41. ItemService::addGhsItem($v);
  42. }
  43. util::complete('添加成功');
  44. }
  45. public function actionDelete()
  46. {
  47. util::fail('不能删除哦!');
  48. }
  49. //获取平台里的花材信息
  50. public function actionPlatformItem()
  51. {
  52. $py = Yii::$app->request->get('py', '');
  53. $where = [];
  54. if ($py) {
  55. $where = ['py' => $py];
  56. }
  57. $list = PtItemClass::getItemList($where);
  58. util::success($list);
  59. }
  60. }