lan = $this->request->getLan(); } //质押列表 public function list(ProductPledges $productPledges, PledgeLogic $pledgeLogic) { $type_id = $this->request->param('type_id', 0, 'intval'); if(empty($type_id)) $this->error(__("参数有误,无可用产品")); $list = $productPledges ->where('status', $productPledges::Normal) ->where('to_lang', $this->lan)->where('type_id', $type_id) ->field('id,title,day_num,income_reta,product_id') ->order('weigh desc') ->paginate($this->pageSize); $list = $pledgeLogic::getByProductIdList($list, $this->lan); $this->success('', $list); } /* * 质押详情 */ public function detail(ProductPledges $productPledges, ProductLists $productList) { $id = $this->request->param('id', 0, 'intval'); if(empty($id)) $this->error(__("参数有误,无可用产品")); //质押详情 $pledges = $productPledges::get($id); if (!empty($pledges)) { $pledges->product_list = $productList::getBySynthesisProduct($pledges->product_id, $this->lan); } $this->success('', $pledges); } /* * 持有商品列表 */ public function holdProductList(PledgeLogic $pledgeLogic) { $product_id = $this->request->param('product_id', 0, 'intval'); if(empty($product_id)) $this->error(__("参数有误,无可用产品")); $pledges = $pledgeLogic::getHoldProductList($this->auth->id, $product_id); $this->success('', $pledges); } /* * 质押存储 */ public function create( ProductPledges $productPledges, PledgeLogic $pledgeLogic) { $pledge_id = $this->request->post('pledge_id', 0, 'intval'); $order_no = $this->request->post('order_no/a', ''); if(empty($pledge_id) || empty($order_no)) $this->error(__("参数有误,无可用产品")); $pledge = $productPledges::get($pledge_id); if (empty($pledge)) $this->error(__("合成活动不存在")); if (empty($pledge->status) )$this->error(__("合成活动已结束")); Db::startTrans(); try { // 质抵押订单 $pledgeLogic::setPledgeOrder($pledge, $order_no, $this->auth->id); // 提交事务 Db::commit(); } catch (Exception $e) { // 回滚事务 Db::rollback(); $this->error($e->getMessage(), null, $e->getCode()); } $this->success('ok'); } /* * 我的茶矿 */ public function teamine(ProductPledges $productPledges, PledgeLogic $pledgeLogic) { Db::startTrans(); try { // 质抵押订单 $res = $pledgeLogic::getPledgeOrderList(1275); // 提交事务 Db::commit(); } catch (Exception $e) { // 回滚事务 Db::rollback(); $this->error($e->getMessage(), null, $e->getCode()); } $this->success('ok', $res); } }