alias('ig')->where(['ig.is_delete' => 0, 'ig.status' => 1, 'ig.store_id' => $store_id])->leftJoin(['g' => Goods::tableName()],'g.id=ig.goods_id');; if ($cat_id > 0) { $query->andWhere(['ig.cat_id' => $cat_id]); } $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $limit, 'page' => $page - 1]); $list = $query->select(['ig.*'])->limit($pagination->limit) ->offset($pagination->offset) ->asArray()->orderBy(['ig.sort' => SORT_ASC, 'ig.created_at' => SORT_DESC])->all(); foreach ($list as &$val) { $attr = json_decode($val['attr'], true); $count = count($attr); $str = ''; foreach ($attr as $key => &$value) { $attr_group = GoodsForm::getAttrGroupByAttId($value['attr_id']); $t = $value['attr_name']; unset($value['attr_name']); $value['attr_group_name'] = $attr_group ? $attr_group->attr_group_name : null; $value['attr_name'] = $t; $str .= $value['attr_group_name'] . ':' . $t; if ($key < $count - 1) { $str .= ','; } } $val['attr_str'] = $str; $val['cat_name'] = SaasIntegralCat::findOne($val['cat_id'])->name; $val['created_at'] = date('Y-m-d H:i:s', $val['created_at']); $val['goods'] = SaasIntegralGoods::getGoods($val['goods_id']); } $cat = []; $store_integral_cat = SaasIntegralCat::find()->where(['store_id' => $store_id, 'is_delete' => SaasIntegralCat::DELETE_STATUS_FALSE, 'is_enable' => SaasIntegralCat::IS_ENABLE_TRUE])->asArray()->all(); if ($store_integral_cat) { foreach ($store_integral_cat as $c) { $integral_cat_goods = SaasIntegralGoods::find()->where(['is_delete' => 0, 'store_id' => $store_id, 'status' => 1, 'cat_id' => $c['id']])->asArray()->all(); if (!empty($integral_cat_goods)) { $cat[] = $c; } } } return [ 'code' => 0, 'msg' => 'success', 'data' => [ 'cat' => $cat, 'row_count' => $count, 'page_count' => $pagination->pageCount, 'list' => $list, 'coupon' => [], 'integral' => get_saas_user()->integral ] ]; } /** * 商品详情 * @return array */ public function actionDetail() { $form = new IndexForm(); $form->id = get_params('id'); $form->store_id = 0; return $form->getGoodsDetail(); } /** * 积分兑换 * @return array */ public function actionPay() { $form = new IndexForm(); $form->id = post_params('id'); $form->store_id = 0; $form->user = get_saas_user(); return $form->pay(); } /** * 积分兑换 * @return array */ public function actionRecord() { return [ 'code' => 0, 'msg' => 'success', 'data' => AccountLog::find()->where(['user_id' => get_user_id(), 'type' => AccountLog::TYPE_INTEGRAL])->orderBy('created_at desc')->asArray()->all() ]; } /** * 积分兑换 * @return array */ public function actionUserRecord() { if (get_store_id() <= 0) { $store_id = [0, -1]; } else { $store_id = get_store_id(); } $saas_id = get_saas_user_id(); $query = AccountLog::find()->where(['store_id' => $store_id, 'saas_id' => $saas_id, 'type' => AccountLog::TYPE_INTEGRAL])->orderBy('created_at desc'); if (get_params('type') != 0) { $query->andWhere(['log_type' => get_params('type')])->asArray()->all(); } $list = $query->asArray()->all(); return [ 'code' => 0, 'msg' => 'success', 'data' => $list ]; } public function actionGetQrcode() { $form = new QrcodeForm(); $user_id = get_user_id(); $form->page = "user/clerk/integralList"; $form->width = 100; $form->scene = "{$user_id}"; return $form->getQrcode(); } }