123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/4/6
- * Time: 下午1:42
- */
- require_once (BASE_ROOT_PATH . '/helper/fcode/mfcode.php');
- require_once (BASE_ROOT_PATH . '/helper/fcode/operator.php');
- require_once (BASE_ROOT_PATH . '/helper/goods_helper.php');
- class member_fcodeControl extends mbMemberControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function listOp()
- {
- $mod_fcode = Model('goods_fcode');
- $items = $mod_fcode->getFcodeList(array('mobile' => session_helper::cur_mobile()),'*','fc_state asc,fc_id asc',$this->page_size());
- $page_count = $mod_fcode->gettotalpage();
- $fcodes = [];
- $gids = [];
- foreach ($items as $item) {
- $fcoder = new fcode\mfcode($item);
- $fcode = $fcoder->format();
- $gids[] = intval($fcode['goods_id']);
- $fcodes[] = $fcode;
- }
- if(empty($fcodes))
- {
- return self::outsuccess(array('special_list' => null,
- 'fcodes' => null,
- 'summary' => null,
- 'groupbuy' => null,
- 'limitime' => null,
- 'bundling' => null,
- 'mobile_page' => mobile_page($page_count)));
- }
- else
- {
- $blocks = $this->format($fcodes);
- $helper = new goods_helper();
- $ret = $helper->cart_summary($gids,$related_goods);
- return self::outsuccess(array('special_list' => $blocks,
- 'fcodes' => $fcodes,
- 'summary' => $ret['summary'],
- 'groupbuy' => $ret['groupbuy'],
- 'limitime' => $ret['limitime'],
- 'bundling' => $ret['bundling'],
- 'mobile_page' => mobile_page($page_count)));
- }
- }
- private function format($fcodes)
- {
- $blocks = [];
- foreach ($fcodes as $fcode)
- {
- $block = [];
- $block['item_title'] = '';
- $block['item_type'] = 'home1';
- $item['image'] = '';
- $item['show_type'] = "fcode";
- $item['show_data'] = strval($fcode['fcode_id']);
- $item['type'] = "goods";
- $item['data'] = strval($fcode['goods_id']);;
- $item['title'] = '';
- $block['items'][] = $item;
- $blocks[] = $block;
- $blocks[] = special_formater::def_divider();
- }
- return $blocks;
- }
- public function addOp()
- {
- $fc_code = $_GET['fcode'];
- $user_key = $_GET['key'];
- if(empty($fc_code) || empty($user_key)) {
- return self::outerr(errcode::ErrParamter,"参数错误,请输入正确的参数");
- }
- try
- {
- $fcode = new fcode\mfcode($fc_code);
- if($fcode->used()) {
- return self::outerr(errcode::ErrParamter,"该F码已经使用过了,不能添加.");
- }
- if($fcode->expired()) {
- return self::outerr(errcode::ErrParamter,"该F码已经过期,不能添加.");
- }
- if($fcode->user_key() != $user_key) {
- return self::outerr(errcode::ErrParamter,"密钥不正确,可能输入错误或者已经被其他人占用.");
- }
- $oper = new fcode\operator($fcode->commonid(),$fcode->batch_code());
- $oper->change($fcode->params(),session_helper::cur_mobile());
- return self::outsuccess(null);
- }
- catch (Exception $ex) {
- return self::outerr(errcode::ErrParamter,"参数错误,没有此F码.");
- }
- }
- }
|