|
|
@@ -74,22 +74,21 @@ class Pledge extends Api
|
|
|
/*
|
|
|
* 质押存储
|
|
|
*/
|
|
|
- public function create( ProductPledges $productPledges, PledgeLogic $pledgeLogic)
|
|
|
+ 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(__("合成活动已结束"));
|
|
|
+ if(count(explode(',', $pledge->product_id)) || count($order_no)) $this->error(__("参数有误,无可用产品"));
|
|
|
|
|
|
+ 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) {
|
|
|
@@ -99,23 +98,33 @@ class Pledge extends Api
|
|
|
}
|
|
|
$this->success('ok');
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
/*
|
|
|
* 我的茶矿
|
|
|
*/
|
|
|
- public function teamine(ProductPledges $productPledges, PledgeLogic $pledgeLogic)
|
|
|
+ public function teamine(PledgeLogic $pledgeLogic)
|
|
|
{
|
|
|
-
|
|
|
- Db::startTrans();
|
|
|
try {
|
|
|
-
|
|
|
// 质抵押订单
|
|
|
- $res = $pledgeLogic::getPledgeOrderList(1275);
|
|
|
+ $res = $pledgeLogic::getPledgeOrderList($this->auth->id);
|
|
|
+
|
|
|
+ } catch (Exception $e) {
|
|
|
+
|
|
|
+ $this->error($e->getMessage(), null, $e->getCode());
|
|
|
+ }
|
|
|
+ $this->success('ok', $res);
|
|
|
+ }
|
|
|
|
|
|
+ /*
|
|
|
+ * 收取茶矿
|
|
|
+ */
|
|
|
+ public function collect(PledgeLogic $pledgeLogic)
|
|
|
+ {
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ // 质抵押订单
|
|
|
+ $res = $pledgeLogic::getPledgeOrderList($this->auth->id);
|
|
|
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
@@ -127,7 +136,27 @@ class Pledge extends Api
|
|
|
$this->success('ok', $res);
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * 解除质押
|
|
|
+ */
|
|
|
+ public function remove(PledgeLogic $pledgeLogic)
|
|
|
+ {
|
|
|
+ $pledge_id = $this->request->post('pledge_id', 0, 'intval');
|
|
|
+ if(empty($pledge_id)) $this->error(__("参数有误,无可用产品"));
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ // 质抵押订单
|
|
|
+ $res = $pledgeLogic::setPledgeRemove($pledge_id, $this->auth->id);
|
|
|
|
|
|
+ // 提交事务
|
|
|
+ Db::commit();
|
|
|
+ } catch (Exception $e) {
|
|
|
+ // 回滚事务
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage(), null, $e->getCode());
|
|
|
+ }
|
|
|
+ $this->success('ok', $res);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|