SkuPrice.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\admin\controller\shopro\goods;
  3. use app\admin\controller\shopro\Common;
  4. use think\Db;
  5. use app\admin\model\shopro\goods\SkuPrice as SkuPriceModel;
  6. class SkuPrice extends Common
  7. {
  8. protected $noNeedRight = ['index'];
  9. public function _initialize()
  10. {
  11. parent::_initialize();
  12. $this->model = new SkuPriceModel;
  13. }
  14. /**
  15. * skuPrices列表
  16. *
  17. * @return \think\Response
  18. */
  19. public function index()
  20. {
  21. $goods_id = $this->request->param('goods_id');
  22. $skuPrices = $this->model->where('goods_id', $goods_id)->select();
  23. $this->success('获取成功', null, $skuPrices);
  24. }
  25. /**
  26. * skuPrices编辑
  27. *
  28. * @param $id
  29. * @return \think\Response
  30. */
  31. public function edit($id = null)
  32. {
  33. $params = $this->request->only([
  34. 'status',
  35. ]);
  36. $id = explode(',', $id);
  37. $items = $this->model->whereIn('id', $id)->select();
  38. Db::transaction(function () use ($items, $params) {
  39. foreach ($items as $skuPrice) {
  40. $skuPrice->save($params);
  41. }
  42. });
  43. $this->success('更新成功');
  44. }
  45. }