Synthesis.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\ProductLists;
  5. use app\common\model\ProductOrder;
  6. use app\common\model\Synthesis as SynthesisModel;
  7. use fast\Action;
  8. use fast\Asset;
  9. use fast\Http;
  10. use think\Db;
  11. use think\Log;
  12. //合成管理
  13. class Synthesis extends Api
  14. {
  15. protected string $lan = '';
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->lan = $this->request->getLan();
  20. }
  21. public function list(SynthesisModel $synthesis)
  22. {
  23. $list = $synthesis->alias('a')
  24. ->join("product_list b", "a.product_id = b.id", "left")
  25. ->field('a.id,a.title,a.start_time,a.end_time,b.thum as img_url')
  26. ->where('a.status', $synthesis::Normal)->where('a.to_lang', $this->lan)
  27. ->order('a.weigh desc')
  28. ->paginate($this->pageSize);
  29. $this->success('', $list);
  30. }
  31. /*
  32. * 合成详情
  33. */
  34. public function detail(ProductLists $productLists, ProductOrder $productOrder)
  35. {
  36. $id = $this->request->param('id', 0, 'intval');
  37. if(empty($id)) $this->error(__("参数有误,无可用产品"));
  38. //合成详情
  39. $synthesis = SynthesisModel::get($id);
  40. if (!empty($synthesis)) {
  41. //条件一
  42. $lan = $this->request->getLan();
  43. $material_one = $productLists->getBySynthesisProduct($synthesis->material_one, $lan);
  44. $synthesis->material_one = $productOrder->getByOrderProductNum($material_one, $synthesis->material_one_num, $this->auth->id);
  45. //条件二
  46. $material_two = $productLists->getBySynthesisProduct($synthesis->material_two, $lan);
  47. $synthesis->material_two = $productOrder->getByOrderProductNum($material_two, $synthesis->material_one_num, $this->auth->id);
  48. //条件三
  49. $material_three = $productLists->getBySynthesisProduct($synthesis->material_three, $lan);
  50. $synthesis->material_three = $productOrder->getByOrderProductNum($material_three, $synthesis->material_one_num, $this->auth->id);
  51. }
  52. $this->success('', $synthesis);
  53. }
  54. }