public function confirm() { $user = get_user() or $this->error('请先登录!', '/login'); $contract = M('loan_user_contract')->find($user['uid']); if (!$contract) { header('Location: /user/contract'); exit; } $goodsModel = new ShopGoodsModel(); $this->assign('contract', $contract); $this->assign('month_money', $goodsModel->getMonthMoney(I('money') - I('first_money'), I('month'), I('type'))); $this->display(); }
public static function getGoods($options) { $model = new ShopGoodsModel(); $model->join('__LOAN_SHOP_COLUMN__ c on c.id = g.column_id', 'left')->alias('g')->field(' g.id, title, subhead, pic, icon_id, max_month, fix_month, fee_id, price, is_promotion, promotion_price'); foreach ($options as $name => $value) { $model->{$name}($value); } $list = $model->select(); foreach ($list as &$goods) { $goods['icon'] = self::getIconUrl($goods['icon_id']); $goods['url'] = U('/' . $goods['id']); if ($goods['is_promotion']) { $goods['max_month'] = $model->getMaxMonth(0, $goods['promotion_price'], 0, $goods['max_month'], $goods['fix_month']); $goods['month_money'] = $model->getMonthMoney($goods['promotion_price'], $goods['max_month'], $goods['fee_id']); } else { $goods['max_month'] = $model->getMaxMonth(0, $goods['price'], 0, $goods['max_month'], $goods['fix_month']); $goods['month_money'] = $model->getMonthMoney($goods['price'], $goods['max_month'], $goods['fee_id']); } } return $list; }
/** * 获取指定专题分类商品 * @param $cid * @return array */ protected function get_category_goods($cid) { $model = new ShopGoodsModel(); $list = M('loan_shop_goods goods')->join('__LOAN_WEB_TOPIC_GOODS__ topic_goods on topic_goods.goods_id = goods.id')->join('__LOAN_WEB_TOPIC_CATEGORY__ category on category.id = topic_goods.topic_category_id')->where(['category.id' => $cid])->field(' goods.id, goods.title, goods.pic, goods.price, goods.is_promotion, goods.promotion_price, goods.max_month, goods.fix_month, goods.fee_id, category.name as category_name')->order('topic_goods.sort')->select(); foreach ($list as &$goods) { $goods['price_original'] = $goods['price']; if ($goods['is_promotion']) { $goods['price'] = $goods['promotion_price']; } $goods['max_month'] = $model->getMaxMonth(0, $goods['price'], 0, $goods['max_month'], $goods['fix_month']); $goods['month_money'] = $model->getMonthMoney($goods['price'], $goods['max_month'], $goods['fee_id']); } return $list; }