PrizeDelController.class.php
1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Created by IntelliJ IDEA.
* 奖品删除
* User: zhoutao
* Date: 2016-12-06
* Time: 16:48:56
*/
namespace Apicp\Controller\Mall;
use Common\Common\AttachOperation;
use Common\Service\PrizeService;
class PrizeDelController extends AbstractController
{
public function before_action($action = '')
{
// 开启自动获取
$this->autoGetData = true;
$this->field = [
'ia_id' => [
'require' => true,
'cn' => '要删除的奖品ID',
]
];
return parent::before_action($action);
}
public function Index()
{
$prizeServ = new PrizeService();
try {
$prizeServ->delete_by_conds(['ia_id' => $this->data['ia_id']]);
// 删除UC附件
$attach_serv = new AttachOperation();
$attach_serv->delete_attach(APP_DIR, 'prize', $this->data['ia_id']);
} catch (\Exception $e) {
\Think\Log::record('删除奖品,ID:(' . $this->data['ia_id'] . ')' . var_export($e, true));
// 接口返回抛错 需求如此
// 查询序号
$prizeArr = $prizeServ->list_by_conds(['ia_id' => $this->data['ia_id']]);
$sequenceList = array_column($prizeArr, 'sequence');
E(L('_ERR_BATCH_OPERATE_ERROR', ['ids' => implode(',', $sequenceList)]));
return false;
}
return true;
}
}