ModifyController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\modify\classes\ModifyClass;
  4. use bizGhs\modify\classes\ModifyItemClass;
  5. use Yii;
  6. use common\components\util;
  7. class ModifyController extends BaseController
  8. {
  9. public $guestAccess = [];
  10. public function actionList()
  11. {
  12. $where = [];
  13. $where['mainId'] = $this->mainId;
  14. $respond = ModifyClass::getModifyList($where);
  15. util::success($respond);
  16. }
  17. //添加修改记录 ssh 20240502
  18. public function actionAdd()
  19. {
  20. $post = Yii::$app->request->post();
  21. $modifyName = $post['modifyName'] ?? '';
  22. if (empty($modifyName)) {
  23. $modifyName = date("mdHIs");
  24. }
  25. $data = $post['data'] ?? '';
  26. if (!empty($data)) {
  27. $arr = json_decode($data, true);
  28. if (!empty($arr)) {
  29. $mData = [
  30. 'name' => $modifyName,
  31. 'mainId' => $this->mainId,
  32. 'inTurn' => 100,
  33. ];
  34. $info = ModifyClass::add($mData, true);
  35. $returnId = $info->id ?? 0;
  36. foreach ($arr as $it) {
  37. $name = $it['name'] ?? '';
  38. $cover = $it['cover'] ?? '';
  39. $productId = $it['id'] ?? 0;
  40. $skPrice = $it['skPrice'] ?? 0;
  41. $hjPrice = $it['skPrice'] ?? 0;
  42. $price = $it['price'] ?? 0;
  43. $currentData = [
  44. 'mId' => $returnId,
  45. 'name' => $name,
  46. 'productId' => $productId,
  47. 'skPrice' => $skPrice,
  48. 'price' => $price,
  49. 'hjPrice' => $hjPrice,
  50. 'cover' => $cover,
  51. ];
  52. ModifyItemClass::add($currentData, true);
  53. }
  54. }
  55. }
  56. util::complete();
  57. }
  58. }