| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\models\cashier;
- use app\constants\OptionSetting;
- use app\models\Address;
- use app\models\Coupon;
- use app\models\DeliveryRules;
- use app\models\GoodsBook;
- use app\models\GoodsCat;
- use app\models\GoodsFullMinus;
- use app\models\MchGoodsCat;
- use app\models\MdGoods;
- use app\models\Option;
- use app\models\OrderDetail;
- use app\models\SeckillActivity;
- use app\models\SeckillActivityGoods;
- use app\models\VerifyCard;
- use app\models\Favorite;
- use app\models\Goods;
- use app\models\GoodsPic;
- use app\models\Order;
- use app\models\PostageRules;
- use app\models\Shop;
- use app\models\TerritorialLimitation;
- use app\modules\client\models\v1\common\CommonGoods;
- use app\modules\client\models\v1\diy\GetInfo;
- use app\modules\client\models\v1\mch\ShopDataForm;
- use app\plugins\product_traceability\models\ProductBatch;
- use app\utils\Tools;
- use yii\base\Model;
- use yii\helpers\Json;
- class GoodsForm extends Model
- {
- public $id;
- public $user_id;
- public $store_id;
- public $mch_id;
- public $shop_id;
- public $address_id;
- public $verify_card_id;
- public function rules()
- {
- return [
- [['id'], 'required'],
- [['mch_id', 'shop_id', 'address_id'], 'integer'],
- [['user_id'], 'safe'],
- ];
- }
- /**
- * 排序类型$sort 1--综合排序 2--销量排序
- */
- public function search()
- {
- if (!$this->validate()) {
- return $this->getErrorSummary(false)[0];
- }
- $where = [
- 'id' => $this->id,
- 'is_delete' => 0,
- 'status' => 1,
- 'store_id' => $this->store_id
- ];
- if (\Yii::$app->prod_is_dandianpu()) {
- unset($where['store_id']);
- }
- $goods = Goods::findOne($where);
- \app\modules\admin\models\erp\InventoryForm::erp2Goods($this->store_id, $goods);
- \app\modules\admin\models\jushuitan\JuShuiTanForm::syncStoreJstGoodsQty($this->store_id, $goods);
- if (!empty($goods->verify_card_id)) {
- $ids = explode(',', $goods->verify_card_id);
- $verify_card = Tools::getVerifyList($ids);
- } else {
- $verify_card = [];
- }
- if (get_md_id()) {
- $md_goods = MdGoods::findOne(['md_id' => get_md_id(), 'goods_id' => $this->id]);
- if ($md_goods) {
- if ($md_goods->status == 0) {
- return [
- 'code' => 1,
- 'msg' => '商品已下架'
- ];
- }
- } else {
- if (!$goods) {
- return [
- 'code' => 1,
- 'msg' => '商品已下架'
- ];
- }
- }
- } else {
- if (!$goods) {
- return [
- 'code' => 1,
- 'msg' => '商品已下架'
- ];
- }
- }
- $mch = null;
- if ($goods->mch_id) {
- $mch = $this->getMch($goods);
- if (!$mch) {
- return [
- 'code' => 1,
- 'msg' => '店铺已经打烊了哦~'
- ];
- }
- }
- $pic_list = GoodsPic::find()->select('pic_url')->where(['goods_id' => $goods->id, 'is_delete' => 0])->asArray()->all();
- $is_favorite = 0;
- if ($this->user_id) {
- $exist_favorite = Favorite::find()->where(['user_id' => $this->user_id, 'goods_id' => $goods->id, 'is_delete' => 0])->exists();
- if ($exist_favorite) {
- $is_favorite = 1;
- }
- }
- $service_list = explode(',', $goods->service);
- // 默认商品服务
- if (!$goods->service) {
- $option = Option::get('good_services', $this->store_id, 'admin', []);
- foreach ($option as $item) {
- if (!empty($item['is_default'])) {
- $service_list = explode(',', $item['service']);
- break;
- }
- }
- }
- $new_service_list = [];
- if (is_array($service_list)) {
- foreach ($service_list as $item) {
- $item = trim($item);
- if ($item) {
- $new_service_list[] = $item;
- }
- }
- }
- // 门店逻辑
- $is_md = false;
- if (get_md_id()) {
- $md_goods = MdGoods::findOne(['goods_id' => $goods->id, 'md_id' => get_md_id()]);
- if ($md_goods) {
- $is_md = true;
- }
- }
- $new_price = $is_md ? $md_goods->price : $goods->price;
- $price_attr = $is_md ? Json::decode($md_goods->attr) : Json::decode($goods->attr);
- $price = [];
- if (is_array($price_attr)) {
- foreach ($price_attr as $v) {
- if (is_object($v) && $v->price > 0) {
- $price[] = $v->price;
- } else {
- $price[] = floatval($new_price);
- }
- }
- } else {
- $price = [$goods->price];
- }
-
- $res_url = GetInfo::getVideoInfo($goods->video_url);
- $goods->video_url = $res_url['url'];
- if ($goods->is_negotiable) {
- $min_price = Goods::GOODS_NEGOTIABLE;
- } else {
- $min_price = sprintf('%.2f', min($price));
- }
- $res = CommonGoods::getMMPrice([
- 'attr' => $is_md ? $md_goods->attr : $goods->attr,
- 'attr_setting_type' => $goods->attr_setting_type,
- 'share_type' => $goods->share_type,
- 'share_commission_first' => $goods->share_commission_first,
- 'price' => $new_price,
- 'individual_share' => $goods->individual_share,
- 'mch_id' => $goods->mch_id,
- 'is_level' => $goods->is_level,
- 'use_attr' => $goods->use_attr,
- ]);
- $attr = $price_attr;
- $goodsPrice = $new_price;
- $isMemberPrice = false;
- if ($res['user_is_member'] === true && count($attr) === 1 && $attr[0]['attr_list'][0]['attr_name'] == '默认') {
- $goodsPrice = $res['min_member_price'] ? $res['min_member_price'] : $new_price;
- $isMemberPrice = true;
- }
- $GoodsFullMinus = GoodsFullMinus::find()
- ->select('*')
- ->where(['store_id' => $this->store_id, 'goods_id' => $goods->id])
- ->orderBy('full_minus_num ASC')->asArray()->all();
- //秒杀活动
- $seckill_activity_goods = SeckillActivityGoods::find()->alias('sag')->where(['sag.goods_id' => $goods->id])
- ->leftJoin(['sa' => SeckillActivity::tableName()], 'sag.activity_id = sa.id')
- ->andWhere(['AND', ['sa.is_delete' => 0], ['>', 'sa.end_time', time()], ['sag.is_delete' => 0]])
- ->select('sa.id, sa.self_limit_num, sa.order_limit_num, sa.start_time, sa.end_time, sag.attr, sag.seckill_num, sag.seckill_price, sag.use_attr, sag.sale_num, sag.virtual_sales')->asArray()->all();
- $seckill_activity_arr = [];
- if (!empty($seckill_activity_goods)) {
- $last_names = array_column($seckill_activity_goods,'start_time');
- array_multisort($last_names, SORT_ASC, $seckill_activity_goods);
- foreach ($seckill_activity_goods as $activity_good) {
- $activity_good['progress'] = sprintf('%.2f', (($activity_good['sale_num'] + $activity_good['virtual_sales']) / ($activity_good['seckill_num'] + $activity_good['virtual_sales'])) * 100);
- $activity_good['price'] = $goods->price;
- $activity_good['seckill_price'] = sprintf('%.2f', $activity_good['seckill_price']);
- if ($activity_good['start_time'] < time()) { //活动进行中 前端展示距离结束
- $activity_good['status'] = 1;
- $seckill_activity_arr = $activity_good;
- goto seckill_activity_arr;
- }
- if ($activity_good['start_time'] >= time()) {//活动进行中 前端展示距离开始
- $activity_good['status'] = 2;
- $activity_good['progress'] = 0;
- $seckill_activity_arr = $activity_good;
- goto seckill_activity_arr;
- }
- }
- seckill_activity_arr:
- }
- if (!empty($seckill_activity_arr)) {
- $seckill_activity_arr['attr'] = json_decode($seckill_activity_arr['attr'], true);
- if (!empty($seckill_activity_arr['attr'])) {
- foreach ($seckill_activity_arr['attr'] as &$activity_attr) {
- $activity_attr['seckill_price'] = sprintf('%.2f', $activity_attr['seckill_price']);
- }
- }
- }
- //配送时间展示
- $delivery_rules = DeliveryRules::find()->where(['id' => $goods->delivery_rules_id, 'is_delete' => 0, 'status' => 1])->select('id, times, type, days, name')->one();
- if ($delivery_rules) {
- $days = "下单" . $delivery_rules['days'] . "天后";
- $delivery_rules['times'] =
- (int)$delivery_rules['type'] === 1 ? $days : date("m月d日 H:i:s", $delivery_rules['times']);
- $delivery_rules['type'] .= '';
- }
- $data = [
- 'id' => $goods->id,
- 'status' => $goods->status,
- 'pic_list' => $pic_list,
- 'attr' => $is_md ? $md_goods->attr : $goods->attr,
- 'cover_pic' => $goods->cover_pic,
- 'is_negotiable' => $goods->is_negotiable,
- 'max_price' => sprintf('%.2f', max($price)),
- 'min_price' => $min_price,
- 'name' => $goods->name,
- 'cat_id' => $goods->cat_id,
- 'price' => sprintf('%.2f', $goodsPrice),
- 'detail' => $goods->detail,
- 'sales' => $goods->getSalesVolume() + ($is_md ? $md_goods->virtual_sales : $goods->virtual_sales),
- 'attr_group_list' => $goods->getAttrGroupList(),
- 'num' => $goods->getNum(),
- 'is_favorite' => $is_favorite,
- 'service_list' => $new_service_list,
- 'original_price' => sprintf('%.2f', $goods->original_price),
- 'video_url' => $goods->video_url,
- 'unit' => $goods->unit,
- 'use_attr' => intval($goods->use_attr),
- 'mch' => $mch,
- 'max_share_price' => sprintf('%.2f', $res['max_share_price']),
- 'min_member_price' => sprintf('%.2f', $res['min_member_price']),
- 'is_share' => $res['is_share'],
- 'is_level' => $res['is_level'],
- 'is_member_price' => $isMemberPrice,
- 'full_minus' => $GoodsFullMinus,
- 'verify_card_id' => $verify_card,
- 'goods_share_title' => $goods->goods_share_title,
- 'goods_share_desc' => $goods->goods_share_desc,
- 'goods_share_logo' => $goods->goods_share_logo,
- 'product_type' => $goods->product_type,
- 'confine_count' => $goods->confine_count ?: 0,
- 'integral' => json_decode($goods->integral, true) ?: ['give' => 0, 'forehead' => 0, 'forehead_integral' => 0],
- 'integral_price' => $goods->integral_price,
- 'delivery_rules' => $delivery_rules ?: null,
- 'seckill_activity_arr' => $seckill_activity_arr ?: null
- ];
- $store_integral = Option::get(OptionSetting::STORE_INTEGRAL, get_store_id(), 'gift', Option::get(OptionSetting::STORE_INTEGRAL, get_store_id(), 'store')['value'])['value'];
- if ($goods->integral) {
- $goods_integral = Json::decode($goods->integral);
- if ($goods_integral['forehead'] > 0) {
- $data['integral'] = [
- 'give' => $goods_integral['give'],
- 'forehead' => $goods_integral['forehead'],
- 'forehead_integral' => round($store_integral * $goods_integral['forehead'])
- ];
- }
- }
- // 处理app上不显示没加协议的图片
- $data['detail'] = str_replace('src="//', 'src="https://', $data['detail']);
- $now_date = strtotime(date('Y-m-d'));
- $goods_book = GoodsBook::findOne(['goods_id' => $goods->id]);
- // 预约参数配置
- if ($data['product_type'] == Goods::GOODS_TYPE_DATE) {
- $data['num'] = Goods::getGoodsNum($goods)['data'];
-
- $data['date_book'] = [
- 'date_book' => $data['num'] ,
- 'date' => count($data['num'])
- ];
- if ($goods_book && !empty($goods_book->date_book)) {
- $date_book = Json::decode($goods_book->date_book);
- $count = 0;
- foreach ($date_book as $value) {
- if (strtotime($value['date']) >= $now_date) {
- $count++;
- }
- }
- // if ($count <= 0) {
- // return [
- // 'code' => 1,
- // 'msg' => '商品预约数据不存在'
- // ];
- // }
- $data['date_book'] = [
- 'date_book' => $date_book,
- 'date' => count($date_book)
- ];
- } else {
- // return [
- // 'code' => 1,
- // 'msg' => '该商品暂无可预约数据'
- // ];
- }
- }
- if ($data['product_type'] == Goods::GOODS_TYPE_TIME) {
- if ($goods_book && !empty($goods_book->service_book)) {
- $service_book = Json::decode($goods_book->service_book);
- $date_data = $this->getDateByInterval(7);
- $count = 0;
- $new_arr = [
- 'data' => []
- ];
- $order = Order::find()->alias('o')
- ->leftJoin(['od' => OrderDetail::tableName()], 'o.id = od.order_id')
- ->where(['o.trade_status' => [0, 2, 3], 'o.is_delete' => 0, 'o.order_type' => 2, 'goods_id' => $goods['id']])
- ->select('od.attr, od.num')->asArray()->all();
- foreach ($date_data as $index => $datum) {
- $new_arr['data'][$index]['date'] = $datum;
- $new_arr['data'][$index]['time'] = $service_book['data'][0]['time'];
- }
- foreach ($new_arr['data'] as &$value) {
- if (strtotime($value['date']) >= $now_date) {
- foreach ($value['time'] as &$m) {
- foreach ($m['times'] as &$n) {
- $times = explode('-', $n['time']);
- if (strtotime(date('Y-m-d H:i:s')) <= strtotime($value['date'] . $times[1])) {
- $count++;
- }
- foreach ($order as $item) {
- if ($item['attr']) {
- $item['attr'] = json_decode($item['attr'], true);
- $order_time = explode('-', $item['attr']['time']);
- if (
- strtotime($item['attr']['date'] . ' ' . $times[0]) === strtotime($value['date'] . ' ' . $order_time[0]) &&
- strtotime($item['attr']['date'] . ' ' . $times[1]) === strtotime($value['date'] . ' ' . $order_time[1])
- ) {
- $n['num'] = $n['num'] - $item['num'];
- }
- }
- }
- }
- }
- }
- }
- if ($count <= 0) {
- return [
- 'code' => 1,
- 'msg' => '该商品暂无可预约数据'
- ];
- }
- $data['service_book'] = $new_arr;
- } else {
- return [
- 'code' => 1,
- 'msg' => '商品服务预约配置有误'
- ];
- }
- }
- $ProductBatch = ProductBatch::find()->where(['goods_id' => $goods->id, 'is_delete' => 0, 'state' => 1])->one();
- $data['have_product_traceability'] = $ProductBatch ? 1 : 0;
- $data['product_batch_id'] = $ProductBatch ? $ProductBatch->id : 0;
-
- $ruleBuyerLoc = \app\models\OrderRulesBuyerLocation::findOne($goods->order_rules_buyer_location_id);
- $data['order_rules_buyer_location'] = $ruleBuyerLoc;
- return [
- 'code' => 0,
- 'data' => $data
- ];
- }
- // 快速给购买商品
- public function quickGoods($twocatid)
- {
- $goods = Goods::find()
- ->where([
- 'store_id' => $this->store_id,
- 'is_delete' => 0,
- 'status' => 1,
- 'quick_purchase' => 1
- ])
- ->andWhere([
- 'in', 'cat_id', $twocatid
- ])->asArray()
- ->all();
- foreach ($goods as $key => &$value) {
- $value['attr'] = json_decode($value['attr']);
- foreach ($value['attr'] as $key2 => $value2) {
- foreach ($value2->attr_list as $key3 => $value3) {
- $value['attr_name'] = $value3->attr_name;
- }
- $value['num'] = 0;
- }
- }
- return [
- 'code' => 0,
- 'data' => [
- 'list' => $goods,
- ],
- ];
- }
- /**
- * 获取优惠详情
- */
- public function getYouhui()
- {
- if (!$this->validate()) {
- return $this->getErrorSummary(false)[0];
- }
- $data = [];
- $goods = Goods::findOne($this->id);
- // 是否赠送积分
- $integral = json_decode($goods->integral, true);
- if ($integral['give'] > 0) {
- $data[] = [
- 'name' => '赠送积分',
- 'content' => '购买赠送' . $integral['give'] . '积分'
- ];
- }
- if ($integral['forehead'] > 0) {
- $data[] = [
- 'name' => '积分抵扣',
- 'content' => '最高可抵扣' . $integral['forehead'] . '元'
- ];
- }
- $goods_card = Goods::getGoodsCard($goods->id);
- foreach ($goods_card as $card) {
- $data[] = [
- 'name' => '卡券',
- 'content' => $card['name']
- ];
- }
- // 核销卡列表获取
- // 获取商品已添加核销卡
- if (empty($goods->verify_card_id)) {
- $goods_verify_card_list = [];
- } else {
- $verify_cards = explode(',', $goods['verify_card_id']);
- foreach ($verify_cards as $k => $v) {
- $verifyCard = VerifyCard::find()->select(['id', 'name'])->where(['id' => $v, 'is_delete' => 0])->asArray()->one();
- if ($verifyCard) {
- $goods_verify_card_list[] = $verifyCard;
- }
- }
- }
- foreach ((array)$goods_verify_card_list as $verify) {
- $data[] = [
- 'name' => '核销卡',
- 'content' => $verify['name']
- ];
- }
- $coupon_list = Coupon::getList();
- $coupon_list_res = [];
- foreach ($coupon_list as $coupon) {
- if ($coupon['appoint_type'] !== 3) {
- if ($coupon['appoint_type'] == 0) {
- $coupon_list_res[] = $coupon;
- } else {
- if ($coupon['appoint_type'] == 2) {
- $goods_id_arr = array_column($coupon['goods'], 'id');
- if (in_array($goods->id, $goods_id_arr) || empty($goods_id_arr)) {
- $coupon_list_res[] = $coupon;
- }
- } else {
- if ($coupon['appoint_type'] == 1) {
- $cat_list = GoodsCat::find()->where([
- 'goods_id' => $goods->id,
- 'is_delete' => 0,
- 'store_id' => get_store_id()
- ])->all();
- $cat_id_arr = array_column($coupon['cat'], 'id');
- if (empty($cat_id_arr)) {
- $coupon_list_res[] = $coupon;
- } else {
- foreach ($cat_list as $cat) {
- if (in_array($cat->cat_id, $cat_id_arr) || empty($cat_id_arr)) {
- $coupon_list_res[] = $coupon;
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- $dataRes = [
- 'data' => $data,
- 'coupon' => $coupon_list_res
- ];
- return [
- 'code' => 0,
- 'data' => $dataRes
- ];
- }
- /**
- * @description: 获取商品收货地址
- * @param {*}
- * @return {*}
- */
- public function getAddress()
- {
- if ($this->address_id) {
- $query = Address::find()->where(['store_id' => get_store_id(), 'is_delete' => 0, 'id' => $this->address_id]);
- if (is_platform()) {
- $address = $query->andWhere([
- 'user_id' => get_saas_user_id()
- ])->one();
- } else {
- $address = $query->andWhere([
- 'user_id' => get_user_id()
- ])->one();
- }
- } else {
- $query = Address::find()->where(['store_id' => get_store_id(), 'is_delete' => 0]);
- if (is_platform()) {
- $query->andWhere([
- 'user_id' => get_saas_user_id()
- ]);
- } else {
- $query->andWhere([
- 'user_id' => get_user_id()
- ]);
- }
- $address = $query->orderBy(['is_default' => SORT_DESC])->one();
- }
- $goods = Goods::findOne($this->id);
- // 计算运费
- $express_price = $this->getExpressPrice($address, $goods);
- // 计算区域限制购买
- $is_area = $this->getTerritorialLimitation($address, $goods);
- $shop_id = null;
- $shop = null;
- if ($this->shop_id) {
- $shop_id = $this->shop_id;
- } else {
- $order = Order::find()->where([
- 'is_offline' => 1,
- 'user_id' => get_user_id()
- ])->orderBy(['id' => SORT_DESC])->one();
- if ($order) {
- $shop_id = $order->shop_id;
- }
- }
- if ($shop_id) {
- $shop = Shop::findOne($shop_id);
- }
- return [
- 'code' => 0,
- 'data' => [
- 'address' => $address,
- 'shop' => $shop,
- 'express_price' => $express_price,
- 'is_area' => $is_area
- ]
- ];
- }
- /**
- * 门店推荐
- */
- public function mchRecommend()
- {
- $goods_list = Goods::find()->where([
- 'mch_id' => $this->mch_id,
- 'status' => 1,
- 'is_delete' => 0
- ])->orderBy(['sort' => SORT_ASC])
- ->select(['id', 'name', 'cover_pic', 'price'])->limit(6)->all();
- return [
- 'code' => 0,
- 'data' => [
- 'list' => $goods_list
- ]
- ];
- }
- /**
- * 猜你喜欢
- */
- public function guessLike()
- {
- $cat_list = GoodsCat::find()->where(['goods_id' => $this->id, 'is_delete' => 0])->all();
- $cat_id = [];
- foreach ($cat_list as $val) {
- $cat_id[] = $val->cat_id;
- }
- $goods_list = Goods::find()->alias('g')
- ->leftJoin(['gc' => GoodsCat::tableName()], 'gc.goods_id=g.id')
- ->where([
- 'g.status' => 1,
- 'g.is_delete' => 0,
- 'gc.cat_id' => $cat_id
- ])->orderBy(['g.sort' => SORT_DESC])
- ->select(['g.id', 'g.name', 'g.cover_pic', 'g.price'])->groupBy('gc.goods_id')->limit(6)->all();
- return [
- 'code' => 0,
- 'data' => [
- 'list' => $goods_list
- ]
- ];
- }
- /**
- * 计算单个商品的运费
- */
- protected function getExpressPrice($address, $goods)
- {
- $expressPrice = 0;
- if ($address) {
- //再通过运费规则计算运费
- $expressPrice = PostageRules::getExpressPrice($goods->store_id, $address->city_id, $goods, 1, $address->province_id);
- }
- return $expressPrice >= 0 ? $expressPrice : 0;
- }
- /**
- * 计算单个商品是否区域限制购买
- */
- protected function getTerritorialLimitation($address, $goods)
- {
- $isArea = 0;
- if ($address) {
- $area = TerritorialLimitation::findOne([
- 'store_id' => get_store_id(),
- 'is_delete' => 0,
- 'is_enable' => 1,
- ]);
- if ($area) {
- $city_id = []; //限制的地区ID
- $detail = json_decode($area->detail);
- if (!is_array($detail)) {
- $detail = [];
- }
- foreach ($detail as $key => $value) {
- foreach ($value->province_list as $key2 => $value2) {
- $city_id[] = $value2->id;
- }
- }
- $addressArr = [
- $address['province_id'],
- $address['city_id'],
- $address['district_id']
- ];
- $addressArray = array_intersect($addressArr, $city_id);
- if (empty($addressArray)) {
- $isArea = 1;
- }
- }
- }
- return $isArea;
- }
- /**
- * User: chiyanying
- * Date: 2020/9/27
- * Time: 17:27
- * Notes:获取单个商品信息
- */
- public static function getGoods($goods_id = 0, $tore_id = 0, $type = 0)
- {
- if ($type == 0) {
- $form = new GoodsForm();
- $form->id = $goods_id;
- $form->store_id = $tore_id;
- return $form->search()['data'];
- }
- }
- /**
- * 获取店铺信息
- */
- public function getMch($goods)
- {
- $f = new ShopDataForm();
- $f->mch_id = $goods->mch_id;
- $shop = $f->getShop();
- if (isset($shop['code']) && $shop['code'] == 1) {
- return null;
- }
- return $shop;
- }
- public function getDateByInterval(int $num) :array
- {
- //var_dump($st, $et);die;
- $returnData = [];
- $i = 0;
- do {
- $temp = date('Y-m-d', strtotime('+' . $i . ' day', strtotime(date('Y-m-d'))));
- $returnData[] = $temp;
- $i++;
- } while ($i < $num);
- return $returnData;
- }
- }
|