From 1f60f84bc3e9b568359706677c6f3daf5e9f5caa Mon Sep 17 00:00:00 2001
From: ZF sun <34314687@qq.com>
Date: Sat, 17 Jan 2026 08:45:12 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99?=
=?UTF-8?q?=E7=9A=84=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/addon/alioss/config/diy_view.php | 7 -
src/addon/alioss/config/info.php | 8 -
src/addon/alioss/event/ClearAlbumPic.php | 7 -
src/addon/alioss/event/CloseOss.php | 7 -
src/addon/alioss/event/Install.php | 7 -
src/addon/alioss/event/OssType.php | 7 -
src/addon/alioss/event/Put.php | 7 -
src/addon/alioss/event/UnInstall.php | 9 -
src/addon/alioss/model/Alioss.php | 7 -
src/addon/alioss/model/Config.php | 7 -
src/addon/alioss/shop/controller/Config.php | 7 -
src/addon/alipay/config/diy_view.php | 7 -
src/addon/alipay/config/event.php | 7 -
src/addon/alipay/config/info.php | 8 -
src/addon/alipay/config/menu_shop.php | 7 -
src/addon/alipay/event/Install.php | 9 -
src/addon/alipay/event/Pay.php | 7 -
src/addon/alipay/event/PayClose.php | 7 -
src/addon/alipay/event/PayNotify.php | 7 -
src/addon/alipay/event/PayOrderQuery.php | 7 -
src/addon/alipay/event/PayRefund.php | 7 -
src/addon/alipay/event/PayTransfer.php | 7 -
src/addon/alipay/event/PayType.php | 7 -
src/addon/alipay/event/TransferType.php | 7 -
src/addon/alipay/event/UnInstall.php | 9 -
src/addon/alipay/model/Config.php | 7 -
src/addon/alipay/model/Pay.php | 7 -
src/addon/alipay/shop/controller/Pay.php | 7 -
src/addon/cases/config/diy_view.php | 7 -
src/addon/cases/config/info.php | 8 -
src/addon/cases/event/Install.php | 7 -
src/addon/cases/event/UnInstall.php | 9 -
src/addon/coupon/api/controller/Coupon.php | 7 -
src/addon/coupon/config/diy_view.php | 7 -
src/addon/coupon/config/info.php | 8 -
src/addon/coupon/dict/CouponDict.php | 7 -
src/addon/coupon/event/CronCouponEnd.php | 7 -
src/addon/coupon/event/CronCouponTypeEnd.php | 7 -
src/addon/coupon/event/Install.php | 9 -
src/addon/coupon/event/ShowPromotion.php | 7 -
src/addon/coupon/event/UnInstall.php | 9 -
src/addon/coupon/model/Coupon.php | 8 -
src/addon/coupon/model/CouponStat.php | 8 -
src/addon/coupon/model/CouponType.php | 8 -
src/addon/coupon/model/MemberCoupon.php | 8 -
src/addon/coupon/model/share/WchatShare.php | 9 -
src/addon/coupon/model/share/WeappShare.php | 9 -
.../coupon/shopapi/controller/Coupon.php | 8 -
src/addon/diy_default1/config/diy_view.php | 8 -
src/addon/diy_default1/config/info.php | 9 -
src/addon/diy_default1/event/Install.php | 9 -
src/addon/diy_default1/event/UnInstall.php | 8 -
src/addon/diy_default2/config/diy_view.php | 8 -
src/addon/diy_default2/config/info.php | 9 -
src/addon/diy_default2/event/Install.php | 9 -
src/addon/diy_default2/event/UnInstall.php | 8 -
src/addon/electronicsheet/config/diy_view.php | 8 -
src/addon/electronicsheet/config/info.php | 8 -
src/addon/electronicsheet/event/Install.php | 8 -
.../electronicsheet/event/PromotionType.php | 8 -
.../electronicsheet/event/ShowPromotion.php | 8 -
src/addon/electronicsheet/event/UnInstall.php | 8 -
.../model/ElectronicsheetDelivery.php | 8 -
.../model/ExpressElectronicsheet.php | 8 -
.../shop/controller/Config.php | 8 -
.../shop/controller/Electronicsheet.php | 8 -
src/addon/fenxiao/api/controller/Account.php | 8 -
src/addon/fenxiao/api/controller/Apply.php | 8 -
src/addon/fenxiao/api/controller/Config.php | 8 -
src/addon/fenxiao/api/controller/Fenxiao.php | 8 -
src/addon/fenxiao/api/controller/Goods.php | 8 -
.../fenxiao/api/controller/Goodscollect.php | 8 -
src/addon/fenxiao/api/controller/Level.php | 8 -
src/addon/fenxiao/api/controller/Order.php | 8 -
src/addon/fenxiao/api/controller/Withdraw.php | 8 -
src/addon/fenxiao/config/diy_view.php | 8 -
src/addon/fenxiao/event/AddSiteDiyView.php | 8 -
.../fenxiao/event/AddSiteFenxiaoLevel.php | 8 -
.../fenxiao/event/AlterShareRelation.php | 8 -
src/addon/fenxiao/event/FenxiaoUpgrade.php | 8 -
.../fenxiao/event/GoodsListCategoryIds.php | 8 -
.../fenxiao/event/GoodsListPromotion.php | 8 -
src/addon/fenxiao/event/Install.php | 8 -
.../fenxiao/event/MemberAccountFromType.php | 8 -
src/addon/fenxiao/event/MemberCancel.php | 8 -
src/addon/fenxiao/event/MemberRegister.php | 9 -
src/addon/fenxiao/event/OrderComplete.php | 8 -
src/addon/fenxiao/event/OrderCreateAfter.php | 8 -
src/addon/fenxiao/event/OrderGoodsRefund.php | 8 -
src/addon/fenxiao/event/OrderPayAfter.php | 9 -
src/addon/fenxiao/event/OrderSettlement.php | 9 -
.../fenxiao/event/PresaleOrderCreate.php | 8 -
src/addon/fenxiao/event/PromotionType.php | 8 -
src/addon/fenxiao/event/ShowPromotion.php | 8 -
src/addon/fenxiao/event/UnInstall.php | 8 -
src/addon/fenxiao/event/WchatShareConfig.php | 8 -
src/addon/fenxiao/event/WchatShareData.php | 9 -
src/addon/fenxiao/event/WeappShareConfig.php | 9 -
src/addon/fenxiao/event/WeappShareData.php | 9 -
src/addon/fenxiao/model/Config.php | 8 -
src/addon/fenxiao/model/Fenxiao.php | 8 -
src/addon/fenxiao/model/FenxiaoAccount.php | 8 -
src/addon/fenxiao/model/FenxiaoApply.php | 8 -
src/addon/fenxiao/model/FenxiaoData.php | 8 -
src/addon/fenxiao/model/FenxiaoGoods.php | 8 -
.../fenxiao/model/FenxiaoGoodsCollect.php | 8 -
src/addon/fenxiao/model/FenxiaoGoodsSku.php | 8 -
src/addon/fenxiao/model/FenxiaoLevel.php | 8 -
src/addon/fenxiao/model/FenxiaoOrder.php | 8 -
src/addon/fenxiao/model/FenxiaoStat.php | 8 -
src/addon/fenxiao/model/FenxiaoWithdraw.php | 8 -
src/addon/fenxiao/model/Poster.php | 8 -
src/addon/fenxiao/model/share/WchatShare.php | 9 -
src/addon/fenxiao/model/share/WeappShare.php | 9 -
src/addon/fenxiao/shop/controller/Config.php | 8 -
src/addon/fenxiao/shop/controller/Fenxiao.php | 8 -
src/addon/fenxiao/shop/controller/Goods.php | 8 -
src/addon/fenxiao/shop/controller/Level.php | 8 -
src/addon/fenxiao/shop/controller/Market.php | 8 -
src/addon/fenxiao/shop/controller/Order.php | 8 -
.../shop/controller/Postertemplate.php | 8 -
.../fenxiao/shop/controller/Withdraw.php | 8 -
src/addon/form/api/controller/Form.php | 9 -
src/addon/form/config/diy_view.php | 8 -
src/addon/form/config/info.php | 9 -
src/addon/form/event/Install.php | 9 -
src/addon/form/event/OrderCreateAfter.php | 8 -
src/addon/form/event/OrderPayment.php | 8 -
src/addon/form/event/ShowPromotion.php | 8 -
src/addon/form/event/UnInstall.php | 9 -
src/addon/form/model/Form.php | 8 -
src/addon/form/model/FormData.php | 8 -
src/addon/form/shop/controller/Form.php | 8 -
src/addon/form/shopapi/controller/Form.php | 8 -
src/addon/freeshipping/config/diy_view.php | 8 -
src/addon/freeshipping/config/info.php | 8 -
src/addon/freeshipping/event/Install.php | 8 -
.../freeshipping/event/PromotionType.php | 9 -
.../freeshipping/event/ShowPromotion.php | 8 -
src/addon/freeshipping/event/UnInstall.php | 8 -
src/addon/freeshipping/model/Freeshipping.php | 8 -
.../shop/controller/Freeshipping.php | 8 -
src/addon/manjian/api/controller/Manjian.php | 8 -
src/addon/manjian/config/diy_view.php | 8 -
src/addon/manjian/config/info.php | 9 -
src/addon/manjian/event/CloseManjian.php | 9 -
src/addon/manjian/event/Install.php | 9 -
.../manjian/event/MemberAccountFromType.php | 9 -
src/addon/manjian/event/OpenManjian.php | 9 -
src/addon/manjian/event/OrderPayAfter.php | 9 -
.../manjian/event/OrderRefundAllFinish.php | 8 -
src/addon/manjian/event/ShowPromotion.php | 8 -
src/addon/manjian/event/UnInstall.php | 8 -
src/addon/manjian/model/Manjian.php | 8 -
src/addon/manjian/model/Order.php | 8 -
src/addon/manjian/shop/controller/Manjian.php | 8 -
src/addon/membercancel/config/diy_view.php | 8 -
src/addon/membercancel/config/info.php | 31 +-
src/addon/membercancel/event/Install.php | 43 +-
.../membercancel/event/PromotionType.php | 44 +-
.../membercancel/event/ShowPromotion.php | 7 -
src/addon/membercancel/event/UnInstall.php | 8 -
src/addon/membercancel/model/MemberCancel.php | 996 ++++----
.../shop/controller/Membercancel.php | 322 ++-
src/addon/memberprice/config/diy_view.php | 66 +-
src/addon/memberprice/config/info.php | 30 +-
src/addon/memberprice/event/Install.php | 40 +-
src/addon/memberprice/event/PromotionType.php | 44 +-
src/addon/memberprice/event/UnInstall.php | 40 +-
src/addon/memberprice/model/MemberPrice.php | 94 +-
.../memberprice/shop/controller/Goods.php | 114 +-
.../api/controller/Memberrecharge.php | 108 +-
.../memberrecharge/api/controller/Order.php | 72 +-
src/addon/memberrecharge/config/diy_view.php | 66 +-
src/addon/memberrecharge/config/info.php | 31 +-
.../memberrecharge/event/IncomeStatistics.php | 55 +-
src/addon/memberrecharge/event/Install.php | 41 +-
.../event/MemberAccountFromType.php | 91 +-
.../event/MemberrechargeOrderClose.php | 45 +-
.../event/MemberrechargeOrderPayNotify.php | 46 +-
.../memberrecharge/event/PrinterContent.php | 240 +-
.../memberrecharge/event/PrinterHtml.php | 41 +-
.../event/PrinterTemplateType.php | 51 +-
.../memberrecharge/event/PromotionType.php | 44 +-
.../memberrecharge/event/ShowPromotion.php | 158 +-
src/addon/memberrecharge/event/UnInstall.php | 41 +-
.../model/MemberRechargeCard.php | 256 +-
.../memberrecharge/model/Memberrecharge.php | 304 ++-
.../model/MemberrechargeOrder.php | 604 +++--
.../model/MemberrechargeOrderCreate.php | 240 +-
.../shop/controller/Memberrecharge.php | 984 ++++---
src/addon/memberwithdraw/config/diy_view.php | 66 +-
src/addon/memberwithdraw/config/info.php | 31 +-
src/addon/memberwithdraw/event/Install.php | 41 +-
src/addon/memberwithdraw/event/UnInstall.php | 41 +-
src/addon/memberwithdraw/model/Withdraw.php | 112 +-
.../shop/controller/Withdraw.php | 60 +-
src/addon/merch/config/diy_view.php | 86 +-
src/addon/merch/event/Install.php | 40 +-
src/addon/merch/event/UnInstall.php | 49 +-
src/addon/personnel/config/diy_view.php | 7 -
src/addon/personnel/config/info.php | 8 -
src/addon/personnel/data/install.sql | 12 +-
src/addon/personnel/event/Install.php | 7 -
src/addon/personnel/event/UnInstall.php | 8 -
src/addon/personnel/shop/view/public/diy.js | 20 +-
src/addon/pointcash/config/diy_view.php | 66 +-
src/addon/pointcash/config/info.php | 30 +-
src/addon/pointcash/event/Install.php | 40 +-
.../pointcash/event/MemberAccountFromType.php | 63 +-
src/addon/pointcash/event/PointRule.php | 57 +-
src/addon/pointcash/event/ShowPromotion.php | 180 +-
src/addon/pointcash/event/UnInstall.php | 40 +-
src/addon/pointcash/model/Config.php | 108 +-
.../pointcash/shop/controller/Config.php | 78 +-
.../pointexchange/api/controller/Goods.php | 408 ++-
.../pointexchange/api/controller/Order.php | 155 +-
src/addon/pointexchange/config/info.php | 30 +-
.../pointexchange/event/CouponGetType.php | 41 +-
.../event/CronExchangeOrderClose.php | 46 +-
src/addon/pointexchange/event/Install.php | 42 +-
.../event/MemberAccountFromType.php | 81 +-
src/addon/pointexchange/event/OrderClose.php | 72 +-
.../event/OrderPromotionType.php | 47 +-
.../event/PointexchangeOrderPayNotify.php | 47 +-
.../pointexchange/event/ShowPromotion.php | 94 +-
src/addon/pointexchange/event/UnInstall.php | 42 +-
src/addon/pointexchange/model/Exchange.php | 1438 ++++++-----
.../pointexchange/model/share/WchatShare.php | 301 ++-
.../pointexchange/model/share/WeappShare.php | 8 -
.../shop/controller/Exchange.php | 594 +++--
.../shop/controller/Pointexchange.php | 216 +-
src/addon/printer/config/diy_view.php | 66 +-
src/addon/printer/config/info.php | 30 +-
src/addon/printer/event/Install.php | 40 +-
.../printer/event/MemberRechargeOrderPay.php | 54 +-
.../event/MemberRechargeOrderPayPrinter.php | 47 +-
src/addon/printer/event/OrderPay.php | 46 +-
src/addon/printer/event/OrderPayPrinter.php | 50 +-
.../printer/event/OrderTakeDeliveryAfter.php | 46 +-
.../event/OrderTakeDeliveryPrinter.php | 54 +-
src/addon/printer/event/PrintOrder.php | 42 +-
src/addon/printer/event/PrinterContent.php | 630 +++--
src/addon/printer/event/PrinterTemplate.php | 46 +-
src/addon/printer/event/PromotionType.php | 44 +-
src/addon/printer/event/ShowPromotion.php | 82 +-
src/addon/printer/event/UnInstall.php | 40 +-
src/addon/printer/model/Printer.php | 584 +++--
src/addon/printer/model/PrinterOrder.php | 812 +++---
src/addon/printer/model/PrinterTemplate.php | 218 +-
.../shop/controller/BaseController.php | 44 +-
src/addon/printer/shop/controller/Printer.php | 528 ++--
.../printer/shop/controller/Template.php | 258 +-
.../printer/storeapi/controller/Printer.php | 466 ++--
src/addon/qiniu/config/diy_view.php | 66 +-
src/addon/qiniu/config/info.php | 31 +-
src/addon/qiniu/event/ClearAlbumPic.php | 66 +-
src/addon/qiniu/event/CloseOss.php | 43 +-
src/addon/qiniu/event/Install.php | 41 +-
src/addon/qiniu/event/OssType.php | 55 +-
src/addon/qiniu/event/Put.php | 48 +-
src/addon/qiniu/event/UnInstall.php | 41 +-
src/addon/qiniu/model/Config.php | 101 +-
src/addon/qiniu/model/Qiniu.php | 252 +-
src/addon/qiniu/shop/controller/Config.php | 93 +-
src/addon/seckill/api/controller/Seckill.php | 126 +-
.../seckill/api/controller/Seckillgoods.php | 434 ++--
src/addon/seckill/config/diy_view.php | 125 +-
src/addon/seckill/config/info.php | 30 +-
src/addon/seckill/event/CloseSeckill.php | 44 +-
src/addon/seckill/event/CronOrderClose.php | 56 +-
src/addon/seckill/event/GoodsPromotion.php | 119 +-
.../seckill/event/GoodsPromotionType.php | 45 +-
src/addon/seckill/event/Install.php | 54 +-
src/addon/seckill/event/OpenSeckill.php | 44 +-
.../seckill/event/OrderPromotionType.php | 44 +-
src/addon/seckill/event/PromotionType.php | 44 +-
src/addon/seckill/event/SeckillZoneConfig.php | 64 +-
src/addon/seckill/event/ShowPromotion.php | 172 +-
src/addon/seckill/event/UnInstall.php | 54 +-
src/addon/seckill/model/Poster.php | 1226 +++++----
src/addon/seckill/model/Seckill.php | 1792 +++++++------
src/addon/seckill/model/SeckillOrder.php | 140 +-
.../seckill/model/SeckillOrderCreate.php | 610 +++--
src/addon/seckill/model/share/WchatShare.php | 273 +-
src/addon/seckill/model/share/WeappShare.php | 8 -
src/addon/seckill/shop/controller/Seckill.php | 778 +++---
src/addon/virtualcard/config/diy_view.php | 66 +-
src/addon/virtualcard/config/info.php | 30 +-
src/addon/virtualcard/event/Install.php | 42 +-
src/addon/virtualcard/event/UnInstall.php | 42 +-
src/addon/virtualcard/model/VirtualGoods.php | 2268 ++++++++---------
.../virtualcard/shop/controller/Goods.php | 910 ++++---
.../virtualevaluation/config/diy_view.php | 66 +-
src/addon/virtualevaluation/config/info.php | 30 +-
src/addon/virtualevaluation/event/Install.php | 42 +-
.../virtualevaluation/event/UnInstall.php | 42 +-
.../model/VirtualEvaluation.php | 600 +++--
.../virtualevaluation/model/VirtualStock.php | 362 ++-
.../shop/controller/Comment.php | 820 +++---
src/addon/weapp/api/controller/Auth.php | 69 +-
src/addon/weapp/api/controller/Weapp.php | 166 +-
src/addon/weapp/config/diy_view.php | 66 +-
src/addon/weapp/config/info.php | 7 -
src/addon/weapp/event/DecryptData.php | 8 -
src/addon/weapp/event/Install.php | 8 -
src/addon/weapp/event/OrderDeliveryAfter.php | 8 -
.../weapp/event/OrderTakeDeliveryAfter.php | 8 -
src/addon/weapp/event/PhoneNumber.php | 8 -
src/addon/weapp/event/Qrcode.php | 8 -
src/addon/weapp/event/UnInstall.php | 8 -
src/addon/weapp/model/Config.php | 8 -
src/addon/weapp/model/Message.php | 8 -
src/addon/weapp/model/Stat.php | 8 -
src/addon/weapp/model/Weapp.php | 8 -
src/addon/weapp/shop/controller/Message.php | 11 +-
src/addon/weapp/shop/controller/Stat.php | 8 -
src/addon/weapp/shop/view/message/config.html | 7 +-
src/addon/weapp/shop/view/stat/stat.html | 6 +-
src/addon/weapp/shop/view/weapp/config.html | 4 -
src/addon/wechatpay/config/diy_view.php | 8 -
src/addon/wechatpay/config/info.php | 7 -
src/addon/wechatpay/event/AuthcodePay.php | 1 +
src/addon/wechatpay/event/Install.php | 8 -
src/addon/wechatpay/event/Pay.php | 8 -
src/addon/wechatpay/event/PayClose.php | 7 -
src/addon/wechatpay/event/PayOrderQuery.php | 7 -
src/addon/wechatpay/event/PayRefund.php | 8 -
src/addon/wechatpay/event/PayTransfer.php | 8 -
src/addon/wechatpay/event/PayType.php | 7 -
src/addon/wechatpay/event/TransferType.php | 8 -
src/addon/wechatpay/event/UnInstall.php | 8 -
src/addon/wechatpay/model/Config.php | 7 -
src/addon/wechatpay/model/Pay.php | 7 -
src/addon/wechatpay/model/V3.php | 7 -
src/addon/wechatpay/shop/controller/Pay.php | 7 -
src/app/ExceptionHandle.php | 9 +
src/app/Request.php | 2 +-
src/app/api/controller/BaseApi.php | 8 -
src/app/api/controller/Memberwithdraw.php | 8 -
src/app/api/controller/Notice.php | 8 -
src/app/common.php | 228 +-
src/app/component/view/article/js/design.js | 2 +-
src/app/dict/goods/GoodsDict.php | 9 -
src/app/dict/member_account/AccountDict.php | 9 -
src/app/dict/order/OrderDict.php | 9 -
src/app/dict/order/OrderGoodsDict.php | 9 -
src/app/dict/order/OrderPayDict.php | 9 -
src/app/dict/order_refund/OrderRefundDict.php | 9 -
src/app/dict/pay/PayDict.php | 7 -
src/app/dict/system/ScheduleDict.php | 9 -
src/app/event.php | 8 -
src/app/event/Qrcode.php | 8 -
.../addsite/AddMemberClusterCronRefresh.php | 8 -
src/app/event/addsite/AddMemberLevel.php | 9 -
.../event/addsite/AddRegisterAgreement.php | 9 -
src/app/event/addsite/AddSiteAdv.php | 8 -
src/app/event/addsite/AddSiteConfig.php | 8 -
src/app/event/addsite/AddSiteDelivery.php | 8 -
src/app/event/addsite/AddSiteDiyView.php | 10 +-
.../event/addsite/AddSiteExpressCompany.php | 8 -
src/app/event/addsite/AddStoreDiyView.php | 8 -
src/app/event/addsite/AddYanshiData.php | 13 +-
src/app/event/goods/CronGoodsTimerOff.php | 8 -
src/app/event/goods/CronGoodsTimerOn.php | 8 -
src/app/event/goods/GoodsClass.php | 8 -
src/app/event/goods/VirtualGoodsClass.php | 8 -
src/app/event/init/AppEnd.php | 8 -
src/app/event/init/InitAddon.php | 8 -
src/app/event/init/InitConfig.php | 16 +-
src/app/event/init/InitCron.php | 9 -
src/app/event/member/AddMemberAccount.php | 8 -
.../event/member/CronMemberClusterRefresh.php | 8 -
src/app/event/member/MemberDetail.php | 8 -
src/app/event/member/MemberLogin.php | 9 -
.../message/MessageAccountChangeNotice.php | 8 -
src/app/event/message/MessageBindCode.php | 8 -
.../event/message/MessageBuyerPaySuccess.php | 8 -
src/app/event/message/MessageCancelApply.php | 8 -
src/app/event/message/MessageCancelFail.php | 8 -
.../event/message/MessageCancelSuccess.php | 8 -
.../MessageCashierMemberVerifyCode.php | 8 -
.../message/MessageFenxiaoWithdrawalApply.php | 8 -
.../message/MessageFenxiaoWithdrawalError.php | 8 -
.../MessageFenxiaoWithdrawalSuccess.php | 8 -
src/app/event/message/MessageFindCode.php | 8 -
src/app/event/message/MessageLogin.php | 8 -
src/app/event/message/MessageLoginCode.php | 9 -
.../message/MessageMemberPayPassword.php | 9 -
src/app/event/message/MessageOrderClose.php | 9 -
.../event/message/MessageOrderComplete.php | 9 -
.../event/message/MessageOrderDelivery.php | 9 -
.../event/message/MessageOrderPaySuccess.php | 9 -
.../event/message/MessageOrderRefundApply.php | 9 -
.../message/MessageOrderRefundDelivery.php | 8 -
.../event/message/MessagePayPasswordCode.php | 8 -
src/app/event/message/MessageRegisterCode.php | 8 -
src/app/event/message/MessageSetPassWord.php | 14 -
.../event/message/MessageShopRefundAgree.php | 9 -
.../event/message/MessageShopRefundRefuse.php | 9 -
src/app/event/message/MessageShopVerified.php | 9 -
.../message/MessageUserWithdrawalApply.php | 9 -
.../message/MessageUserWithdrawalError.php | 9 -
.../message/MessageUserWithdrawalSuccess.php | 9 -
.../event/order/CronOrderAfterSaleClose.php | 8 -
src/app/event/order/CronOrderTakeDelivery.php | 8 -
src/app/event/order/OrderComplete.php | 8 -
src/app/event/order/OrderCreate.php | 8 -
src/app/event/order/OrderPay.php | 8 -
src/app/event/order/OrderPayAfter.php | 8 -
src/app/event/order/OrderPayNotify.php | 9 -
src/app/event/order/OrderRefundFinish.php | 9 -
src/app/event/promotion/CloseGame.php | 9 -
src/app/event/promotion/OpenGame.php | 9 -
src/app/event/promotion/PromotionQrcode.php | 8 -
src/app/event/promotion/ShowPromotion.php | 8 -
src/app/event/stat/CronStatShop.php | 8 -
src/app/event/stat/CronStatShopHour.php | 8 -
src/app/event/stat/CronStatStore.php | 8 -
src/app/event/stat/CronStatStoreHour.php | 8 -
src/app/event/verify/CronVerifyCodeExpire.php | 8 -
src/app/event/verify/PickupOrderVerify.php | 8 -
src/app/event/verify/VerifyOrderOutTime.php | 8 -
src/app/event/verify/VirtualGoodsVerify.php | 8 -
src/app/event/wechat/WchatShareConfig.php | 9 -
src/app/event/wechat/WchatShareData.php | 9 -
src/app/event/wechat/WeappShareConfig.php | 9 -
src/app/event/wechat/WeappShareData.php | 9 -
src/app/index/controller/Index.php | 9 -
src/app/index/view/index/h5_preview.html | 3 +
src/app/job/order/OrderDeliveryAfter.php | 3 +-
src/app/middleware.php | 1 +
src/app/model/account/Point.php | 7 -
src/app/model/article/Article.php | 8 -
src/app/model/article/ArticleCategory.php | 8 -
src/app/model/cart/CartCalculate.php | 9 -
src/app/model/express/Config.php | 8 -
src/app/model/express/Express.php | 8 -
src/app/model/express/ExpressCompany.php | 8 -
.../model/express/ExpressCompanyTemplate.php | 8 -
src/app/model/express/ExpressDeliver.php | 8 -
src/app/model/express/ExpressDelivery.php | 8 -
src/app/model/express/ExpressPackage.php | 7 -
src/app/model/express/ExpressTemplate.php | 8 -
src/app/model/express/Kd100.php | 8 -
src/app/model/express/Kdbird.php | 8 -
src/app/model/express/Local.php | 328 ++-
src/app/model/express/LocalPackage.php | 8 -
src/app/model/express/Trace.php | 10 +-
src/app/model/games/Games.php | 8 -
src/app/model/games/Record.php | 9 -
src/app/model/goods/Batch.php | 8 -
src/app/model/goods/Cart.php | 14 +-
src/app/model/goods/Config.php | 8 -
src/app/model/goods/Goods.php | 8 -
src/app/model/goods/GoodsAttribute.php | 9 -
src/app/model/goods/GoodsBrowse.php | 8 -
src/app/model/goods/GoodsCategory.php | 8 -
src/app/model/goods/GoodsCollect.php | 8 -
src/app/model/goods/GoodsExport.php | 8 -
src/app/model/goods/GoodsLabel.php | 8 -
src/app/model/goods/GoodsPoster.php | 8 -
src/app/model/goods/GoodsService.php | 9 -
src/app/model/goods/GoodsStock.php | 8 -
src/app/model/goods/GoodsVerify.php | 8 -
src/app/model/goods/ServiceCategory.php | 8 -
src/app/model/goods/VirtualGoods.php | 8 -
src/app/model/member/Config.php | 8 -
src/app/model/member/Login.php | 8 -
src/app/model/member/Member.php | 8 -
src/app/model/member/MemberAddress.php | 9 -
src/app/model/member/MemberAuth.php | 9 -
src/app/model/member/MemberBankAccount.php | 9 -
src/app/model/member/MemberCluster.php | 8 -
src/app/model/member/MemberLabel.php | 9 -
src/app/model/member/MemberSignin.php | 8 -
src/app/model/member/Register.php | 8 -
src/app/model/member/Withdraw.php | 8 -
src/app/model/message/Message.php | 8 -
src/app/model/message/MessageTemplate.php | 8 -
src/app/model/order/CashOrder.php | 8 -
src/app/model/order/OrderExport.php | 8 -
src/app/model/order/OrderGoods.php | 8 -
src/app/model/order/OrderImportFile.php | 9 -
src/app/model/order/OrderPay.php | 9 -
src/app/model/order/event/OrderComplete.php | 8 -
src/app/model/order/event/OrderDelivery.php | 8 -
src/app/model/order/orderrefund/Apply.php | 8 -
src/app/model/order/orderrefund/Cancel.php | 8 -
src/app/model/order/orderrefund/Close.php | 8 -
src/app/model/order/orderrefund/Confirm.php | 8 -
src/app/model/order/orderrefund/Delivery.php | 8 -
src/app/model/order/orderrefund/Finish.php | 8 -
.../model/order/orderrefund/FinishAction.php | 8 -
src/app/model/order/orderrefund/Refuse.php | 8 -
.../model/order/orderrefund/TakeDelivery.php | 8 -
src/app/model/rrmodel/Lshop.php | 8 -
src/app/model/share/WchatShare.php | 8 -
src/app/model/share/WchatShareBase.php | 8 -
src/app/model/share/WeappShare.php | 8 -
src/app/model/share/WeappShareBase.php | 8 -
src/app/model/shop/Shop.php | 8 -
src/app/model/shop/ShopAcceptMessage.php | 9 -
src/app/model/shop/ShopAddress.php | 9 -
src/app/model/stat/GoodsCartStat.php | 8 -
src/app/model/stat/GoodsStat.php | 8 -
src/app/model/stat/MemberLevelStat.php | 8 -
src/app/model/stat/MemberStat.php | 8 -
src/app/model/stat/MemberWithdrawStat.php | 8 -
src/app/model/stat/OrderStat.php | 8 -
src/app/model/stat/RechargeStat.php | 8 -
src/app/model/stat/StatShop.php | 8 -
src/app/model/stat/StatStore.php | 8 -
src/app/model/stat/VisitStat.php | 8 -
src/app/model/store/Stat.php | 8 -
src/app/model/store/Store.php | 8 -
src/app/model/storegoods/StoreGoods.php | 8 -
src/app/model/storegoods/StoreSale.php | 8 -
src/app/model/system/Addon.php | 9 -
src/app/model/system/AddonQuick.php | 8 -
src/app/model/system/Api.php | 8 -
src/app/model/system/Config.php | 8 -
src/app/model/system/Database.php | 9 -
src/app/model/system/DiyTemplate.php | 8 -
src/app/model/system/Document.php | 9 -
src/app/model/system/Group.php | 8 -
src/app/model/system/H5.php | 8 -
src/app/model/system/Menu.php | 8 -
src/app/model/system/Pay.php | 28 +-
src/app/model/system/PayBalance.php | 8 -
src/app/model/system/Poster.php | 8 -
src/app/model/system/Promotion.php | 72 +-
src/app/model/system/Qrcode.php | 23 +-
src/app/model/system/Site.php | 9 -
src/app/model/system/Stat.php | 56 -
src/app/model/system/SystemConfig.php | 8 -
src/app/model/system/Upgrade.php | 8 -
src/app/model/system/User.php | 8 -
src/app/model/system/UserGroup.php | 9 -
src/app/model/system/Visit.php | 9 -
src/app/model/system/Web.php | 8 -
src/app/model/upload/Album.php | 7 -
src/app/model/upload/Config.php | 7 -
src/app/model/upload/Upload.php | 12 +-
src/app/model/verify/Verifier.php | 9 -
src/app/model/verify/Verify.php | 9 -
src/app/model/verify/VerifyRecord.php | 9 -
src/app/model/web/Account.php | 8 -
src/app/model/web/Config.php | 57 +
src/app/model/web/DiyView.php | 8 -
src/app/model/web/Help.php | 8 -
src/app/model/web/Notice.php | 8 -
src/app/model/web/WebSite.php | 9 -
src/app/pay/controller/Pay.php | 9 -
src/app/shop/controller/Account.php | 9 -
src/app/shop/controller/Articlecategory.php | 9 -
src/app/shop/controller/BaseShop.php | 8 -
src/app/shop/controller/Cashorder.php | 8 -
src/app/shop/controller/Config.php | 29 +-
src/app/shop/controller/Delivery.php | 8 -
src/app/shop/controller/Error.php | 8 -
src/app/shop/controller/Express.php | 8 -
src/app/shop/controller/Gamesrecords.php | 8 -
src/app/shop/controller/Goodsattr.php | 8 -
src/app/shop/controller/Goodslabel.php | 9 -
src/app/shop/controller/Goodsservice.php | 8 -
src/app/shop/controller/H5.php | 8 -
src/app/shop/controller/Help.php | 8 -
src/app/shop/controller/Local.php | 8 -
src/app/shop/controller/Localorder.php | 8 -
src/app/shop/controller/Memberaccount.php | 8 -
src/app/shop/controller/Membercluster.php | 8 -
src/app/shop/controller/Memberlabel.php | 8 -
src/app/shop/controller/Memberlevel.php | 8 -
src/app/shop/controller/Memberwithdraw.php | 8 -
src/app/shop/controller/Message.php | 10 +-
src/app/shop/controller/Notice.php | 8 -
src/app/shop/controller/Orderimportfile.php | 8 -
src/app/shop/controller/Orderrefund.php | 8 -
src/app/shop/controller/Printer.php | 8 -
src/app/shop/controller/Promotion.php | 8 -
src/app/shop/controller/Shopacceptmessage.php | 8 -
src/app/shop/controller/Shophelp.php | 8 -
src/app/shop/controller/Store.php | 8 -
src/app/shop/controller/Storeorder.php | 8 -
src/app/shop/controller/System.php | 8 -
src/app/shop/controller/Ueditor.php | 8 -
src/app/shop/controller/Upload.php | 8 -
src/app/shop/controller/User.php | 8 -
src/app/shop/controller/Verify.php | 8 -
src/app/shop/controller/Virtualgoods.php | 8 -
src/app/shop/controller/Virtualorder.php | 8 -
src/app/shop/view/cashorder/detail.html | 54 +-
src/app/shop/view/config/map.html | 18 +-
src/app/shop/view/config/pay.html | 16 +-
src/app/shop/view/config/servicer.html | 86 +-
src/app/shop/view/diy/heat_map.html | 1 -
src/app/shop/view/message/lists.html | 21 +-
src/app/shop/view/public/js/route.js | 32 +-
src/app/shopapi/controller/Addon.php | 8 -
src/app/shopapi/controller/Address.php | 8 -
src/app/shopapi/controller/Album.php | 8 -
src/app/shopapi/controller/Apply.php | 8 -
src/app/shopapi/controller/BaseApi.php | 8 -
src/app/shopapi/controller/Config.php | 8 -
src/app/shopapi/controller/Index.php | 8 -
src/app/shopapi/controller/Login.php | 8 -
src/app/shopapi/controller/Notice.php | 8 -
src/app/shopapi/controller/Register.php | 8 -
src/app/shopapi/controller/Statistics.php | 8 -
src/app/shopapi/controller/Store.php | 8 -
src/app/shopapi/controller/Upload.php | 8 -
src/app/storeapi/controller/BaseStoreApi.php | 8 -
src/composer.json | 16 +-
src/config/diy_view.php | 15 +-
src/config/info.php | 9 -
src/config/menu_shop.php | 438 +++-
src/config/route.php | 1 -
src/extend/File.php | 8 -
src/extend/Stat.php | 8 -
src/extend/Upload.php | 9 -
.../static/ext/diyview/js/custom_template.js | 2 +-
622 files changed, 14123 insertions(+), 18365 deletions(-)
diff --git a/src/addon/alioss/config/diy_view.php b/src/addon/alioss/config/diy_view.php
index c3c657905..734b3871d 100644
--- a/src/addon/alioss/config/diy_view.php
+++ b/src/addon/alioss/config/diy_view.php
@@ -1,12 +1,5 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/alioss/config/info.php b/src/addon/alioss/config/info.php
index e1ce32c76..19d88c5b4 100644
--- a/src/addon/alioss/config/info.php
+++ b/src/addon/alioss/config/info.php
@@ -1,13 +1,5 @@
'alioss',
'title' => '阿里云OSS',
diff --git a/src/addon/alioss/event/ClearAlbumPic.php b/src/addon/alioss/event/ClearAlbumPic.php
index f676c2751..c20ac994d 100644
--- a/src/addon/alioss/event/ClearAlbumPic.php
+++ b/src/addon/alioss/event/ClearAlbumPic.php
@@ -1,13 +1,6 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/alipay/config/event.php b/src/addon/alipay/config/event.php
index 0bc30b9f4..0b8e64fd0 100644
--- a/src/addon/alipay/config/event.php
+++ b/src/addon/alipay/config/event.php
@@ -1,12 +1,5 @@
[
diff --git a/src/addon/alipay/config/info.php b/src/addon/alipay/config/info.php
index e7ce28878..42c9b7911 100644
--- a/src/addon/alipay/config/info.php
+++ b/src/addon/alipay/config/info.php
@@ -1,13 +1,5 @@
'alipay',
'title' => '支付宝支付',
diff --git a/src/addon/alipay/config/menu_shop.php b/src/addon/alipay/config/menu_shop.php
index 862ee7d2d..1f5c35285 100644
--- a/src/addon/alipay/config/menu_shop.php
+++ b/src/addon/alipay/config/menu_shop.php
@@ -1,12 +1,5 @@
'ALI_PAY_CONFIG',
diff --git a/src/addon/alipay/event/Install.php b/src/addon/alipay/event/Install.php
index f7fd8e178..bb77805e4 100644
--- a/src/addon/alipay/event/Install.php
+++ b/src/addon/alipay/event/Install.php
@@ -1,13 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/cases/config/info.php b/src/addon/cases/config/info.php
index 85d37bb95..e862aabb3 100644
--- a/src/addon/cases/config/info.php
+++ b/src/addon/cases/config/info.php
@@ -1,13 +1,5 @@
'cases',
'title' => '案例展示',
diff --git a/src/addon/cases/event/Install.php b/src/addon/cases/event/Install.php
index 3b17ea916..6bfdb8839 100644
--- a/src/addon/cases/event/Install.php
+++ b/src/addon/cases/event/Install.php
@@ -1,13 +1,6 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/coupon/config/info.php b/src/addon/coupon/config/info.php
index a57819fca..4f6e92943 100644
--- a/src/addon/coupon/config/info.php
+++ b/src/addon/coupon/config/info.php
@@ -1,13 +1,5 @@
'coupon',
'title' => '优惠券',
diff --git a/src/addon/coupon/dict/CouponDict.php b/src/addon/coupon/dict/CouponDict.php
index 32f53405c..c7745d5a4 100644
--- a/src/addon/coupon/dict/CouponDict.php
+++ b/src/addon/coupon/dict/CouponDict.php
@@ -1,14 +1,7 @@
'diy_default1',
'title' => '官方模板一',
diff --git a/src/addon/diy_default1/event/Install.php b/src/addon/diy_default1/event/Install.php
index 91bf44562..a5b62705b 100644
--- a/src/addon/diy_default1/event/Install.php
+++ b/src/addon/diy_default1/event/Install.php
@@ -1,13 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/diy_default2/config/info.php b/src/addon/diy_default2/config/info.php
index f1b408d5c..67d141743 100644
--- a/src/addon/diy_default2/config/info.php
+++ b/src/addon/diy_default2/config/info.php
@@ -1,13 +1,4 @@
'diy_default2',
'title' => '官方模板二',
diff --git a/src/addon/diy_default2/event/Install.php b/src/addon/diy_default2/event/Install.php
index 88edac4b9..0b3d58e7e 100644
--- a/src/addon/diy_default2/event/Install.php
+++ b/src/addon/diy_default2/event/Install.php
@@ -1,13 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/electronicsheet/config/info.php b/src/addon/electronicsheet/config/info.php
index 0965d2058..12c208b4e 100644
--- a/src/addon/electronicsheet/config/info.php
+++ b/src/addon/electronicsheet/config/info.php
@@ -1,12 +1,4 @@
'electronicsheet',
'title' => '电子面单',
diff --git a/src/addon/electronicsheet/event/Install.php b/src/addon/electronicsheet/event/Install.php
index 10dab9ad0..ad2b543f5 100644
--- a/src/addon/electronicsheet/event/Install.php
+++ b/src/addon/electronicsheet/event/Install.php
@@ -1,12 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/fenxiao/event/AddSiteDiyView.php b/src/addon/fenxiao/event/AddSiteDiyView.php
index 7a83dfeb5..035eb8c59 100644
--- a/src/addon/fenxiao/event/AddSiteDiyView.php
+++ b/src/addon/fenxiao/event/AddSiteDiyView.php
@@ -1,12 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/form/config/info.php b/src/addon/form/config/info.php
index 71426c629..b80cf0525 100644
--- a/src/addon/form/config/info.php
+++ b/src/addon/form/config/info.php
@@ -1,13 +1,4 @@
'form',
'title' => '系统表单',
diff --git a/src/addon/form/event/Install.php b/src/addon/form/event/Install.php
index a27492fe0..5f3c8c576 100644
--- a/src/addon/form/event/Install.php
+++ b/src/addon/form/event/Install.php
@@ -1,13 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/freeshipping/config/info.php b/src/addon/freeshipping/config/info.php
index 048afea0d..48631b7c3 100644
--- a/src/addon/freeshipping/config/info.php
+++ b/src/addon/freeshipping/config/info.php
@@ -1,12 +1,4 @@
'freeshipping',
'title' => '满额包邮',
diff --git a/src/addon/freeshipping/event/Install.php b/src/addon/freeshipping/event/Install.php
index b2f3d0243..dd922d3ab 100644
--- a/src/addon/freeshipping/event/Install.php
+++ b/src/addon/freeshipping/event/Install.php
@@ -1,12 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/manjian/config/info.php b/src/addon/manjian/config/info.php
index 6caa29b96..be683508e 100644
--- a/src/addon/manjian/config/info.php
+++ b/src/addon/manjian/config/info.php
@@ -1,13 +1,4 @@
'manjian',
'title' => '满额立减',
diff --git a/src/addon/manjian/event/CloseManjian.php b/src/addon/manjian/event/CloseManjian.php
index 141ea9226..b02cfce61 100644
--- a/src/addon/manjian/event/CloseManjian.php
+++ b/src/addon/manjian/event/CloseManjian.php
@@ -1,13 +1,4 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/membercancel/config/info.php b/src/addon/membercancel/config/info.php
index d64123bc5..553b5074a 100644
--- a/src/addon/membercancel/config/info.php
+++ b/src/addon/membercancel/config/info.php
@@ -1,21 +1,12 @@
- 'membercancel',
- 'title' => '会员注销',
- 'description' => '会员注销',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'membercancel',
+ 'title' => '会员注销',
+ 'description' => '会员注销',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/membercancel/event/Install.php b/src/addon/membercancel/event/Install.php
index b6982ee26..c534953a5 100644
--- a/src/addon/membercancel/event/Install.php
+++ b/src/addon/membercancel/event/Install.php
@@ -1,27 +1,18 @@
- "会员注销", "type" => "membercancel" ];
- }
+ "会员注销", "type" => "membercancel" ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/membercancel/event/ShowPromotion.php b/src/addon/membercancel/event/ShowPromotion.php
index 5b1d1a258..afcb17fbe 100644
--- a/src/addon/membercancel/event/ShowPromotion.php
+++ b/src/addon/membercancel/event/ShowPromotion.php
@@ -1,13 +1,6 @@
getCancelConfig($param[ 'site_id' ], 'shop');
- $value = $config_info[ 'data' ][ 'value' ];
- $value[ 'is_enable' ] = 1;//默认打开注销
- $value[ 'is_audit' ] = 0;//默认打开注销
- if ($value[ 'is_enable' ] == 0) {
- return $this->error('', '未开放注1销');
- }
- //获取用户信息
- $member_info = model('member')->getInfo(
- [
- [ 'site_id', '=', $param[ 'site_id' ] ],
- [ 'member_id', '=', $param[ 'member_id' ] ],
- [ 'is_delete', '=', 0 ]
- ]
- );
- if (empty($member_info)) {
- return $this->error('', '会员不存在');
- }
- if ($member_info[ 'balance_withdraw_apply' ] > 0) {
- return $this->error('', '有余额正在提现中,请提现成功后在申请注销');
- }
- $member_json = json_encode($member_info);
-
- //判断是否申请过
- $member_cancel_info = model('member_cancel')->getInfo([ [ 'site_id', '=', $param[ 'site_id' ] ], [ 'member_id', '=', $param[ 'member_id' ] ] ]);
- if (!empty($member_cancel_info)) {
- if ($member_cancel_info[ 'status' ] != -1) {
- return $this->error('', '请勿重复申请注销');
- }
- }
-
- //判断是否有未完成的订单
- $order_condition = [
- [ 'site_id', '=', $param[ 'site_id' ] ],
- [ 'member_id', '=', $param[ 'member_id' ] ],
- [ 'order_status', 'in', [ 1, 3, 4 ] ]
- ];
- $order_count = model('order')->getCount($order_condition);
- if ($order_count > 0) {
- return $this->error('', '还有订单未完成,请等订单完成后在申请注销');
- }
-
- //分销
- $fenxiao_json = '';
- if (addon_is_exit('fenxiao', $param[ 'site_id' ]) == 1) {
- //获取分销商信息
- $fenxiao_info = model('fenxiao')->getInfo([ [ 'site_id', '=', $param[ 'site_id' ] ], [ 'member_id', '=', $param[ 'member_id' ] ] ]);
- if (!empty($fenxiao_info)) {
- if ($fenxiao_info[ 'account_withdraw_apply' ] > 0) {
- return $this->error('', '有分销佣金正在提现中,请提现成功后在申请注销');
- }
-
- //判断是否存在未结算的分销订单
- $fenxiao_condition = [
- [ 'site_id', '=', $param[ 'site_id' ] ],
- [ 'one_fenxiao_id|two_fenxiao_id|three_fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ],
- [ 'is_settlement', '=', 0 ]
- ];
- $fenxiao_order_count = model('fenxiao_order')->getCount($fenxiao_condition);
- if ($fenxiao_order_count > 0) {
- return $this->error('', '还有分销订单未结算,请等订单结算后在申请注销');
- }
-
- $fenxiao_json = json_encode($fenxiao_info);
- }
- }
-
- model('member_cancel')->startTrans();
- try {
- if (!empty($member_cancel_info)) {
- $id = $member_cancel_info[ 'id' ];
- $data = [
- 'status' => 0,
- 'audit_uid' => '',
- 'audit_username' => '',
- 'reason' => '',
- 'audit_time' => ''
- ];
- model('member_cancel')->update($data, [ [ 'id', '=', $id ] ]);
-
- } else {
- $data = [
- 'member_id' => $member_info[ 'member_id' ],
- 'site_id' => $param[ 'site_id' ],
- 'username' => $member_info[ 'username' ],
- 'mobile' => $member_info[ 'mobile' ],
- 'nickname' => $member_info[ 'nickname' ],
- 'create_time' => time(),
- 'member_json' => $member_json,
- 'fenxiao_json' => $fenxiao_json
- ];
- $id = model('member_cancel')->add($data);
- }
-
- //审核开关关闭
- if ($value[ 'is_audit' ] == 0) {
- //todo 调用审核成功接口
- $param[ 'id' ] = $id;
- $param[ 'audit_uid' ] = '';
- $param[ 'audit_username' ] = '';
- $res = $this->memberCancelAuditPass($param);
- if ($res[ 'code' ] < 0) {
- model('member_cancel')->rollback();
- return $res;
- }
- }
- model('member_cancel')->commit();
-
- //会员申请注销消息
- $message_model = new Message();
- $message_model->sendMessage([ 'keywords' => "USER_CANCEL_APPLY", 'member_id' => $member_info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
- $res[ 'is_audit' ] = $value[ 'is_audit' ];
- return $this->success($res);
- } catch (\Exception $e) {
- model('member_cancel')->rollback();
- return $this->error('', $e->getMessage());
- }
- }
-
- /**
- * 撤销申请注销
- * @param $member_id
- * @param $site_id
- * @return array
- */
- public function cancelApplyMemberCancel($member_id, $site_id)
- {
- $member_cancel_info = model('member_cancel')->getInfo(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ]
- ]
- );
- if (empty($member_cancel_info)) {
- return $this->error('', '数据不合法');
- }
- if ($member_cancel_info[ 'status' ] == 1) {
- return $this->error('', '数据不合法');
- }
-
- $res = model('member_cancel')->delete([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $site_id ] ]);
- return $this->success($res);
- }
-
- /**
- * 审核通过
- * @param $param
- * @return array
- */
- public function memberCancelAuditPass($param)
- {
- $info = model('member_cancel')->getInfo([ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ], 'member_id,status');
- if (empty($info)) {
- return $this->error('', '请核实数据后重试');
- }
- if ($info[ 'status' ] != 0) {
- return $this->error('', '该数据已审核,请勿重复审核');
- }
-
- model('member_cancel')->startTrans();
- try {
-
- //修改注销状态
- $data = [
- 'status' => 1,
- 'audit_uid' => $param[ 'audit_uid' ],
- 'audit_username' => $param[ 'audit_username' ],
- 'audit_time' => time()
- ];
- model('member_cancel')->update($data, [ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
-
- //删除会员信息
- model('member')->update([ 'is_delete' => 1, 'status' => 0 ], [ [ 'member_id', '=', $info[ 'member_id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
- Cache::set('member_blacklist_' . $param[ 'site_id' ], null);
-
- event('MemberCancel', [ 'member_id' => $info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
-
- model('member_cancel')->commit();
-
- //会员注销成功消息
- $message_model = new Message();
- $message_model->sendMessage([ 'keywords' => "USER_CANCEL_SUCCESS", 'member_id' => $info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
-
- return $this->success();
- } catch (\Exception $e) {
- model('member_cancel')->rollback();
- return $this->error('', $e->getMessage());
- }
- }
-
- /**
- * 审核拒绝
- * @param $param
- * @return array
- */
- public function memberCancelAuditRefuse($param)
- {
- $info = model('member_cancel')->getInfo([ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ], 'status,member_id');
-
- if (empty($info)) {
- return $this->error('', '请核实数据后重试');
- }
- if ($info[ 'status' ] != 0) {
- return $this->error('', '该数据已审核,请勿重复审核');
- }
-
- $data = [
- 'status' => -1,
- 'audit_uid' => $param[ 'audit_uid' ],
- 'audit_username' => $param[ 'audit_username' ],
- 'reason' => $param[ 'reason' ],
- 'audit_time' => time()
- ];
- $res = model('member_cancel')->update($data, [ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
-
- //会员注销失败消息
- $message_model = new Message();
- $message_model->sendMessage([ 'keywords' => "USER_CANCEL_FAIL", 'member_id' => $info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
-
- return $this->success($res);
- }
-
- /**
- * 获取会员注销信息
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getMemberCancelInfo($condition = [], $field = '*')
- {
- $info = model('member_cancel')->getInfo($condition, $field);
- return $this->success($info);
- }
-
- /**
- * 获取会员注销分页列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getMemberCancelPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'id desc', $field = '*')
- {
- $list = model('member_cancel')->pageList($condition, $field, $order, $page, $page_size);
- return $this->success($list);
- }
-
- /**
- * 获取用户账户信息
- * @param $member_id
- * @param $site_id
- * @return array
- */
- public function getMemberAccountInfo($member_id, $site_id)
- {
- $data = [];
- //会员信息
- $member_info = model('member')->getInfo(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'is_delete', '=', 0 ]
- ],
- 'is_fenxiao,point,balance,balance_money,balance_withdraw_apply'
- );
- $data[ 'member_info' ] = $member_info;
- //优惠券数量
- $data[ 'member_coupon_count' ] = model('promotion_coupon')->getCount(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'state', '=', 1 ]
- ]
- );
-
- //订单待发货
- $data[ 'order_pay_count' ] = model('order')->getCount(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'order_status', '=', OrderCommon::ORDER_PAY ]
- ]
- );
- //订单待收货
- $data[ 'order_delivery_count' ] = model('order')->getCount(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'order_status', '=', OrderCommon::ORDER_DELIVERY ]
- ]
- );
- //订单待完成
- $data[ 'order_take_delivery_count' ] = model('order')->getCount(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'order_status', '=', OrderCommon::ORDER_TAKE_DELIVERY ]
- ]
- );
- //退款订单
- $data[ 'order_refund_count' ] = model('order')->getCount(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'refund_status', 'not in', [ OrderRefundDict::REFUND_NOT_APPLY, OrderRefundDict::REFUND_COMPLETE ] ]
- ]
- );
-
- //判断用户是否是分销商
- if ($member_info[ 'is_fenxiao' ] == 1 && addon_is_exit('fenxiao', $site_id)) {
-
- //分销商信息
- $fenxiao_model = new Fenxiao();
- $fenxiao_info = $fenxiao_model->getFenxiaoInfo(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ]
- ],
- 'account,account_withdraw,account_withdraw_apply,total_commission'
- );
- $data[ 'fenxiao_info' ] = $fenxiao_info[ 'data' ];
-
- //分销待结算订单
- $fenxiao_order_model = new FenxiaoOrder();
- $fenxiao_order_count = $fenxiao_order_model->getFenxiaoOrderCount(
- [
- [ 'member_id', '=', $member_id ],
- [ 'site_id', '=', $site_id ],
- [ 'is_settlement', '=', 0 ]
- ]
- );
- $data[ 'fenxiao_order_count' ] = $fenxiao_order_count[ 'data' ];
- }
-
- return $this->success($data);
- }
-
- /****************************************** 会员注销通知 start **********************************************/
-
- /**
- * 会员注销成功
- * @param $data
- * @return array
- */
- public function memberCancelSuccess($data)
- {
- $member_cancel = model('member_cancel')->getInfo(
- [
- [ 'member_id', '=', $data[ 'member_id' ] ],
- [ 'site_id', '=', $data[ 'site_id' ] ]
- ]
- );
- if (empty($member_cancel)) {
- return $this->success();
- }
- $member_info = model('member')->getInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'username,mobile,nickname');
-
- //发送短信
- $sms_model = new Sms();
-
- $name = $member_info[ "nickname" ] == '' ? $member_info[ "mobile" ] : $member_info[ "nickname" ];
- $var_parse = array (
- "username" => $name,
- );
-
- $data[ "sms_account" ] = $member_info[ "mobile" ] ?? '';//手机号
- $data[ "var_parse" ] = $var_parse;
- $sms_result = $sms_model->sendMessage($data);
-
- return $this->success();
- }
-
- /**
- * 会员注销失败
- * @param $data
- * @return array
- */
- public function memberCancelFail($data)
- {
- $member_cancel = model('member_cancel')->getInfo(
- [
- [ 'member_id', '=', $data[ 'member_id' ] ],
- [ 'site_id', '=', $data[ 'site_id' ] ]
- ]
- );
- if (empty($member_cancel)) {
- return $this->success();
- }
- $member_info = model('member')->getInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'username,mobile,nickname');
-
- //发送短信
- $sms_model = new Sms();
-
- $name = $member_info[ "nickname" ] == '' ? $member_info[ "mobile" ] : $member_info[ "nickname" ];
- $var_parse = array (
- "username" => $name,
- );
-
- $data[ "sms_account" ] = $member_info[ "mobile" ] ?? '';//手机号
- $data[ "var_parse" ] = $var_parse;
- $sms_result = $sms_model->sendMessage($data);
-
- return $this->success();
- }
-
- /**
- * 会员注销申请通知(店铺)
- * @param $data
- * @return array
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function memberCancelApply($data)
- {
- $member_cancel = model('member_cancel')->getInfo(
- [
- [ 'member_id', '=', $data[ 'member_id' ] ],
- [ 'site_id', '=', $data[ 'site_id' ] ]
- ]
- );
- if (empty($member_cancel)) {
- return $this->success();
- }
- $member_info = model('member')->getInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'username,mobile,nickname');
- $name = $member_info[ "nickname" ] == '' ? $member_info[ "mobile" ] : $member_info[ "nickname" ];
- //发送短信
- $sms_model = new Sms();
-
- $var_parse = array (
- "username" => $name,
- );
-// $site_id = $data['site_id'];
-// $shop_info = model("shop")->getInfo([["site_id", "=", $site_id]], "mobile,email");
-// $message_data["sms_account"] = $shop_info["mobile"];//手机号
- $data[ "var_parse" ] = $var_parse;
-
- $shop_accept_message_model = new ShopAcceptMessage();
- $result = $shop_accept_message_model->getShopAcceptMessageList();
- $list = $result[ 'data' ];
- if (!empty($list)) {
- foreach ($list as $v) {
- $message_data = $data;
- $message_data[ "sms_account" ] = $v[ "mobile" ];//手机号
- $sms_model->sendMessage($message_data);
-
- if ($v[ 'wx_openid' ] != '') {
- $wechat_model = new WechatMessage();
- $data[ "openid" ] = $v[ 'wx_openid' ];
- $data[ "template_data" ] = [
- 'thing2' => replaceSpecialChar($name), // 申请人
- 'time4' => time_to_date(time()) // 注销时间
- ];
-
- $data[ "page" ] = "";
- $wechat_model->sendMessage($data);
- }
- }
- }
- }
-
- /****************************************** 会员注销通知 end ************************************************/
+getCancelConfig($param[ 'site_id' ], 'shop');
+ $value = $config_info[ 'data' ][ 'value' ];
+ $value[ 'is_enable' ] = 1;//默认打开注销
+ $value[ 'is_audit' ] = 0;//默认打开注销
+ if ($value[ 'is_enable' ] == 0) {
+ return $this->error('', '未开放注1销');
+ }
+ //获取用户信息
+ $member_info = model('member')->getInfo(
+ [
+ [ 'site_id', '=', $param[ 'site_id' ] ],
+ [ 'member_id', '=', $param[ 'member_id' ] ],
+ [ 'is_delete', '=', 0 ]
+ ]
+ );
+ if (empty($member_info)) {
+ return $this->error('', '会员不存在');
+ }
+ if ($member_info[ 'balance_withdraw_apply' ] > 0) {
+ return $this->error('', '有余额正在提现中,请提现成功后在申请注销');
+ }
+ $member_json = json_encode($member_info);
+
+ //判断是否申请过
+ $member_cancel_info = model('member_cancel')->getInfo([ [ 'site_id', '=', $param[ 'site_id' ] ], [ 'member_id', '=', $param[ 'member_id' ] ] ]);
+ if (!empty($member_cancel_info)) {
+ if ($member_cancel_info[ 'status' ] != -1) {
+ return $this->error('', '请勿重复申请注销');
+ }
+ }
+
+ //判断是否有未完成的订单
+ $order_condition = [
+ [ 'site_id', '=', $param[ 'site_id' ] ],
+ [ 'member_id', '=', $param[ 'member_id' ] ],
+ [ 'order_status', 'in', [ 1, 3, 4 ] ]
+ ];
+ $order_count = model('order')->getCount($order_condition);
+ if ($order_count > 0) {
+ return $this->error('', '还有订单未完成,请等订单完成后在申请注销');
+ }
+
+ //分销
+ $fenxiao_json = '';
+ if (addon_is_exit('fenxiao', $param[ 'site_id' ]) == 1) {
+ //获取分销商信息
+ $fenxiao_info = model('fenxiao')->getInfo([ [ 'site_id', '=', $param[ 'site_id' ] ], [ 'member_id', '=', $param[ 'member_id' ] ] ]);
+ if (!empty($fenxiao_info)) {
+ if ($fenxiao_info[ 'account_withdraw_apply' ] > 0) {
+ return $this->error('', '有分销佣金正在提现中,请提现成功后在申请注销');
+ }
+
+ //判断是否存在未结算的分销订单
+ $fenxiao_condition = [
+ [ 'site_id', '=', $param[ 'site_id' ] ],
+ [ 'one_fenxiao_id|two_fenxiao_id|three_fenxiao_id', '=', $fenxiao_info[ 'fenxiao_id' ] ],
+ [ 'is_settlement', '=', 0 ]
+ ];
+ $fenxiao_order_count = model('fenxiao_order')->getCount($fenxiao_condition);
+ if ($fenxiao_order_count > 0) {
+ return $this->error('', '还有分销订单未结算,请等订单结算后在申请注销');
+ }
+
+ $fenxiao_json = json_encode($fenxiao_info);
+ }
+ }
+
+ model('member_cancel')->startTrans();
+ try {
+ if (!empty($member_cancel_info)) {
+ $id = $member_cancel_info[ 'id' ];
+ $data = [
+ 'status' => 0,
+ 'audit_uid' => '',
+ 'audit_username' => '',
+ 'reason' => '',
+ 'audit_time' => ''
+ ];
+ model('member_cancel')->update($data, [ [ 'id', '=', $id ] ]);
+
+ } else {
+ $data = [
+ 'member_id' => $member_info[ 'member_id' ],
+ 'site_id' => $param[ 'site_id' ],
+ 'username' => $member_info[ 'username' ],
+ 'mobile' => $member_info[ 'mobile' ],
+ 'nickname' => $member_info[ 'nickname' ],
+ 'create_time' => time(),
+ 'member_json' => $member_json,
+ 'fenxiao_json' => $fenxiao_json
+ ];
+ $id = model('member_cancel')->add($data);
+ }
+
+ //审核开关关闭
+ if ($value[ 'is_audit' ] == 0) {
+ //todo 调用审核成功接口
+ $param[ 'id' ] = $id;
+ $param[ 'audit_uid' ] = '';
+ $param[ 'audit_username' ] = '';
+ $res = $this->memberCancelAuditPass($param);
+ if ($res[ 'code' ] < 0) {
+ model('member_cancel')->rollback();
+ return $res;
+ }
+ }
+ model('member_cancel')->commit();
+
+ //会员申请注销消息
+ $message_model = new Message();
+ $message_model->sendMessage([ 'keywords' => "USER_CANCEL_APPLY", 'member_id' => $member_info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
+ $res[ 'is_audit' ] = $value[ 'is_audit' ];
+ return $this->success($res);
+ } catch (\Exception $e) {
+ model('member_cancel')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+ }
+
+ /**
+ * 撤销申请注销
+ * @param $member_id
+ * @param $site_id
+ * @return array
+ */
+ public function cancelApplyMemberCancel($member_id, $site_id)
+ {
+ $member_cancel_info = model('member_cancel')->getInfo(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ]
+ ]
+ );
+ if (empty($member_cancel_info)) {
+ return $this->error('', '数据不合法');
+ }
+ if ($member_cancel_info[ 'status' ] == 1) {
+ return $this->error('', '数据不合法');
+ }
+
+ $res = model('member_cancel')->delete([ [ 'member_id', '=', $member_id ], [ 'site_id', '=', $site_id ] ]);
+ return $this->success($res);
+ }
+
+ /**
+ * 审核通过
+ * @param $param
+ * @return array
+ */
+ public function memberCancelAuditPass($param)
+ {
+ $info = model('member_cancel')->getInfo([ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ], 'member_id,status');
+ if (empty($info)) {
+ return $this->error('', '请核实数据后重试');
+ }
+ if ($info[ 'status' ] != 0) {
+ return $this->error('', '该数据已审核,请勿重复审核');
+ }
+
+ model('member_cancel')->startTrans();
+ try {
+
+ //修改注销状态
+ $data = [
+ 'status' => 1,
+ 'audit_uid' => $param[ 'audit_uid' ],
+ 'audit_username' => $param[ 'audit_username' ],
+ 'audit_time' => time()
+ ];
+ model('member_cancel')->update($data, [ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
+
+ //删除会员信息
+ model('member')->update([ 'is_delete' => 1, 'status' => 0 ], [ [ 'member_id', '=', $info[ 'member_id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
+ Cache::set('member_blacklist_' . $param[ 'site_id' ], null);
+
+ event('MemberCancel', [ 'member_id' => $info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
+
+ model('member_cancel')->commit();
+
+ //会员注销成功消息
+ $message_model = new Message();
+ $message_model->sendMessage([ 'keywords' => "USER_CANCEL_SUCCESS", 'member_id' => $info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
+
+ return $this->success();
+ } catch (\Exception $e) {
+ model('member_cancel')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+ }
+
+ /**
+ * 审核拒绝
+ * @param $param
+ * @return array
+ */
+ public function memberCancelAuditRefuse($param)
+ {
+ $info = model('member_cancel')->getInfo([ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ], 'status,member_id');
+
+ if (empty($info)) {
+ return $this->error('', '请核实数据后重试');
+ }
+ if ($info[ 'status' ] != 0) {
+ return $this->error('', '该数据已审核,请勿重复审核');
+ }
+
+ $data = [
+ 'status' => -1,
+ 'audit_uid' => $param[ 'audit_uid' ],
+ 'audit_username' => $param[ 'audit_username' ],
+ 'reason' => $param[ 'reason' ],
+ 'audit_time' => time()
+ ];
+ $res = model('member_cancel')->update($data, [ [ 'id', '=', $param[ 'id' ] ], [ 'site_id', '=', $param[ 'site_id' ] ] ]);
+
+ //会员注销失败消息
+ $message_model = new Message();
+ $message_model->sendMessage([ 'keywords' => "USER_CANCEL_FAIL", 'member_id' => $info[ 'member_id' ], 'site_id' => $param[ 'site_id' ] ]);
+
+ return $this->success($res);
+ }
+
+ /**
+ * 获取会员注销信息
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getMemberCancelInfo($condition = [], $field = '*')
+ {
+ $info = model('member_cancel')->getInfo($condition, $field);
+ return $this->success($info);
+ }
+
+ /**
+ * 获取会员注销分页列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @return array
+ */
+ public function getMemberCancelPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'id desc', $field = '*')
+ {
+ $list = model('member_cancel')->pageList($condition, $field, $order, $page, $page_size);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取用户账户信息
+ * @param $member_id
+ * @param $site_id
+ * @return array
+ */
+ public function getMemberAccountInfo($member_id, $site_id)
+ {
+ $data = [];
+ //会员信息
+ $member_info = model('member')->getInfo(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'is_delete', '=', 0 ]
+ ],
+ 'is_fenxiao,point,balance,balance_money,balance_withdraw_apply'
+ );
+ $data[ 'member_info' ] = $member_info;
+ //优惠券数量
+ $data[ 'member_coupon_count' ] = model('promotion_coupon')->getCount(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'state', '=', 1 ]
+ ]
+ );
+
+ //订单待发货
+ $data[ 'order_pay_count' ] = model('order')->getCount(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'order_status', '=', OrderCommon::ORDER_PAY ]
+ ]
+ );
+ //订单待收货
+ $data[ 'order_delivery_count' ] = model('order')->getCount(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'order_status', '=', OrderCommon::ORDER_DELIVERY ]
+ ]
+ );
+ //订单待完成
+ $data[ 'order_take_delivery_count' ] = model('order')->getCount(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'order_status', '=', OrderCommon::ORDER_TAKE_DELIVERY ]
+ ]
+ );
+ //退款订单
+ $data[ 'order_refund_count' ] = model('order')->getCount(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'refund_status', 'not in', [ OrderRefundDict::REFUND_NOT_APPLY, OrderRefundDict::REFUND_COMPLETE ] ]
+ ]
+ );
+
+ //判断用户是否是分销商
+ if ($member_info[ 'is_fenxiao' ] == 1 && addon_is_exit('fenxiao', $site_id)) {
+
+ //分销商信息
+ $fenxiao_model = new Fenxiao();
+ $fenxiao_info = $fenxiao_model->getFenxiaoInfo(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ]
+ ],
+ 'account,account_withdraw,account_withdraw_apply,total_commission'
+ );
+ $data[ 'fenxiao_info' ] = $fenxiao_info[ 'data' ];
+
+ //分销待结算订单
+ $fenxiao_order_model = new FenxiaoOrder();
+ $fenxiao_order_count = $fenxiao_order_model->getFenxiaoOrderCount(
+ [
+ [ 'member_id', '=', $member_id ],
+ [ 'site_id', '=', $site_id ],
+ [ 'is_settlement', '=', 0 ]
+ ]
+ );
+ $data[ 'fenxiao_order_count' ] = $fenxiao_order_count[ 'data' ];
+ }
+
+ return $this->success($data);
+ }
+
+ /****************************************** 会员注销通知 start **********************************************/
+
+ /**
+ * 会员注销成功
+ * @param $data
+ * @return array
+ */
+ public function memberCancelSuccess($data)
+ {
+ $member_cancel = model('member_cancel')->getInfo(
+ [
+ [ 'member_id', '=', $data[ 'member_id' ] ],
+ [ 'site_id', '=', $data[ 'site_id' ] ]
+ ]
+ );
+ if (empty($member_cancel)) {
+ return $this->success();
+ }
+ $member_info = model('member')->getInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'username,mobile,nickname');
+
+ //发送短信
+ $sms_model = new Sms();
+
+ $name = $member_info[ "nickname" ] == '' ? $member_info[ "mobile" ] : $member_info[ "nickname" ];
+ $var_parse = array (
+ "username" => $name,
+ );
+
+ $data[ "sms_account" ] = $member_info[ "mobile" ] ?? '';//手机号
+ $data[ "var_parse" ] = $var_parse;
+ $sms_result = $sms_model->sendMessage($data);
+
+ return $this->success();
+ }
+
+ /**
+ * 会员注销失败
+ * @param $data
+ * @return array
+ */
+ public function memberCancelFail($data)
+ {
+ $member_cancel = model('member_cancel')->getInfo(
+ [
+ [ 'member_id', '=', $data[ 'member_id' ] ],
+ [ 'site_id', '=', $data[ 'site_id' ] ]
+ ]
+ );
+ if (empty($member_cancel)) {
+ return $this->success();
+ }
+ $member_info = model('member')->getInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'username,mobile,nickname');
+
+ //发送短信
+ $sms_model = new Sms();
+
+ $name = $member_info[ "nickname" ] == '' ? $member_info[ "mobile" ] : $member_info[ "nickname" ];
+ $var_parse = array (
+ "username" => $name,
+ );
+
+ $data[ "sms_account" ] = $member_info[ "mobile" ] ?? '';//手机号
+ $data[ "var_parse" ] = $var_parse;
+ $sms_result = $sms_model->sendMessage($data);
+
+ return $this->success();
+ }
+
+ /**
+ * 会员注销申请通知(店铺)
+ * @param $data
+ * @return array
+ * @throws \GuzzleHttp\Exception\GuzzleException
+ */
+ public function memberCancelApply($data)
+ {
+ $member_cancel = model('member_cancel')->getInfo(
+ [
+ [ 'member_id', '=', $data[ 'member_id' ] ],
+ [ 'site_id', '=', $data[ 'site_id' ] ]
+ ]
+ );
+ if (empty($member_cancel)) {
+ return $this->success();
+ }
+ $member_info = model('member')->getInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'username,mobile,nickname');
+ $name = $member_info[ "nickname" ] == '' ? $member_info[ "mobile" ] : $member_info[ "nickname" ];
+ //发送短信
+ $sms_model = new Sms();
+
+ $var_parse = array (
+ "username" => $name,
+ );
+// $site_id = $data['site_id'];
+// $shop_info = model("shop")->getInfo([["site_id", "=", $site_id]], "mobile,email");
+// $message_data["sms_account"] = $shop_info["mobile"];//手机号
+ $data[ "var_parse" ] = $var_parse;
+
+ $shop_accept_message_model = new ShopAcceptMessage();
+ $result = $shop_accept_message_model->getShopAcceptMessageList();
+ $list = $result[ 'data' ];
+ if (!empty($list)) {
+ foreach ($list as $v) {
+ $message_data = $data;
+ $message_data[ "sms_account" ] = $v[ "mobile" ];//手机号
+ $sms_model->sendMessage($message_data);
+
+ if ($v[ 'wx_openid' ] != '') {
+ $wechat_model = new WechatMessage();
+ $data[ "openid" ] = $v[ 'wx_openid' ];
+ $data[ "template_data" ] = [
+ 'thing2' => replaceSpecialChar($name), // 申请人
+ 'time4' => time_to_date(time()) // 注销时间
+ ];
+
+ $data[ "page" ] = "";
+ $wechat_model->sendMessage($data);
+ }
+ }
+ }
+ }
+
+ /****************************************** 会员注销通知 end ************************************************/
}
\ No newline at end of file
diff --git a/src/addon/membercancel/shop/controller/Membercancel.php b/src/addon/membercancel/shop/controller/Membercancel.php
index 95ab355b7..526517c05 100644
--- a/src/addon/membercancel/shop/controller/Membercancel.php
+++ b/src/addon/membercancel/shop/controller/Membercancel.php
@@ -1,166 +1,158 @@
-isJson()) {
-
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
-
- $condition = [ [ 'site_id', '=', $this->site_id ] ];
-
- $search_text = input('search_text', '');
- $search_type = input('search_type', '');
- if (!empty($search_text)) {
- $condition[] = [
- $search_type, 'like', '%' . $search_text . '%'
- ];
- }
- //状态
- $status = input('status', '');
- if ($status !== '') {
- $condition[] = [ 'status', '=', $status ];
- }
- //注销时间
- $start_time = input('start_time', '');
- $end_time = input('end_time', '');
- if ($start_time && $end_time) {
- $condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
- } elseif (!$start_time && $end_time) {
- $condition[] = [ 'create_time', '<=', date_to_time($end_time) ];
-
- } elseif ($start_time && !$end_time) {
- $condition[] = [ 'create_time', '>=', date_to_time($start_time) ];
- }
-
- $member_cancel_model = new MemberCancelModel();
- $list = $member_cancel_model->getMemberCancelPageList($condition, $page, $page_size);
- return $list;
- } else {
-
- //筛选条件
- $search_type = [
- 'username' => '会员账号',
- 'mobile' => '手机号',
- 'nickname' => '昵称'
- ];
- $this->assign('search_type', $search_type);
-
- return $this->fetch('membercancel/lists');
- }
- }
-
- /**
- * 审核通过
- */
- public function auditPass()
- {
- if (request()->isJson()) {
-
- $id = input('id', '');
-
- $data = [
- 'id' => $id,
- 'site_id' => $this->site_id,
- 'audit_uid' => $this->user_info[ 'uid' ],
- 'audit_username' => $this->user_info[ 'username' ]
- ];
-
- $member_cancel_model = new MemberCancelModel();
- $res = $member_cancel_model->memberCancelAuditPass($data);
- return $res;
- }
- }
-
- /**
- * 审核失败
- */
- public function auditRefuse()
- {
- if (request()->isJson()) {
-
- $id = input('id', '');
- $reason = input('reason', '');
- $data = [
- 'id' => $id,
- 'site_id' => $this->site_id,
- 'audit_uid' => $this->user_info[ 'uid' ],
- 'audit_username' => $this->user_info[ 'username' ],
- 'reason' => $reason
- ];
-
- $member_cancel_model = new MemberCancelModel();
- $res = $member_cancel_model->memberCancelAuditRefuse($data);
- return $res;
- }
- }
-
- /**
- * 注销协议
- */
- public function cancelAgreement()
- {
- if (request()->isJson()) {
- //设置注销协议
- $title = input('title', '');
- $content = input('content', '');
- $config_model = new ConfigModel();
- return $config_model->setCancelDocument($title, $content, $this->site_id, 'shop');
- } else {
- //获取注销协议
- $config_model = new ConfigModel();
- $document_info = $config_model->getCancelDocument($this->site_id, 'shop');
- $this->assign('document_info', $document_info);
-
- return $this->fetch('membercancel/cancel_agreement');
- }
- }
-
- /**
- * 注销设置
- */
- public function cancelConfig()
- {
- $config_model = new ConfigModel();
- if (request()->isJson()) {
- //设置注册设置
- $data = array (
- 'is_enable' => input('is_enable', 0),
- 'is_audit' => input('is_audit', 1),
- );
- return $config_model->setCancelConfig($data, $this->site_id, 'shop');
- } else {
- //获取注册设置
- $config_info = $config_model->getCancelConfig($this->site_id, 'shop');
- $value = $config_info[ 'data' ][ 'value' ];
-
- $this->assign('value', $value);
-
- return $this->fetch('membercancel/cancel_config');
- }
- }
-
+isJson()) {
+
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+
+ $condition = [ [ 'site_id', '=', $this->site_id ] ];
+
+ $search_text = input('search_text', '');
+ $search_type = input('search_type', '');
+ if (!empty($search_text)) {
+ $condition[] = [
+ $search_type, 'like', '%' . $search_text . '%'
+ ];
+ }
+ //状态
+ $status = input('status', '');
+ if ($status !== '') {
+ $condition[] = [ 'status', '=', $status ];
+ }
+ //注销时间
+ $start_time = input('start_time', '');
+ $end_time = input('end_time', '');
+ if ($start_time && $end_time) {
+ $condition[] = [ 'create_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
+ } elseif (!$start_time && $end_time) {
+ $condition[] = [ 'create_time', '<=', date_to_time($end_time) ];
+
+ } elseif ($start_time && !$end_time) {
+ $condition[] = [ 'create_time', '>=', date_to_time($start_time) ];
+ }
+
+ $member_cancel_model = new MemberCancelModel();
+ $list = $member_cancel_model->getMemberCancelPageList($condition, $page, $page_size);
+ return $list;
+ } else {
+
+ //筛选条件
+ $search_type = [
+ 'username' => '会员账号',
+ 'mobile' => '手机号',
+ 'nickname' => '昵称'
+ ];
+ $this->assign('search_type', $search_type);
+
+ return $this->fetch('membercancel/lists');
+ }
+ }
+
+ /**
+ * 审核通过
+ */
+ public function auditPass()
+ {
+ if (request()->isJson()) {
+
+ $id = input('id', '');
+
+ $data = [
+ 'id' => $id,
+ 'site_id' => $this->site_id,
+ 'audit_uid' => $this->user_info[ 'uid' ],
+ 'audit_username' => $this->user_info[ 'username' ]
+ ];
+
+ $member_cancel_model = new MemberCancelModel();
+ $res = $member_cancel_model->memberCancelAuditPass($data);
+ return $res;
+ }
+ }
+
+ /**
+ * 审核失败
+ */
+ public function auditRefuse()
+ {
+ if (request()->isJson()) {
+
+ $id = input('id', '');
+ $reason = input('reason', '');
+ $data = [
+ 'id' => $id,
+ 'site_id' => $this->site_id,
+ 'audit_uid' => $this->user_info[ 'uid' ],
+ 'audit_username' => $this->user_info[ 'username' ],
+ 'reason' => $reason
+ ];
+
+ $member_cancel_model = new MemberCancelModel();
+ $res = $member_cancel_model->memberCancelAuditRefuse($data);
+ return $res;
+ }
+ }
+
+ /**
+ * 注销协议
+ */
+ public function cancelAgreement()
+ {
+ if (request()->isJson()) {
+ //设置注销协议
+ $title = input('title', '');
+ $content = input('content', '');
+ $config_model = new ConfigModel();
+ return $config_model->setCancelDocument($title, $content, $this->site_id, 'shop');
+ } else {
+ //获取注销协议
+ $config_model = new ConfigModel();
+ $document_info = $config_model->getCancelDocument($this->site_id, 'shop');
+ $this->assign('document_info', $document_info);
+
+ return $this->fetch('membercancel/cancel_agreement');
+ }
+ }
+
+ /**
+ * 注销设置
+ */
+ public function cancelConfig()
+ {
+ $config_model = new ConfigModel();
+ if (request()->isJson()) {
+ //设置注册设置
+ $data = array (
+ 'is_enable' => input('is_enable', 0),
+ 'is_audit' => input('is_audit', 1),
+ );
+ return $config_model->setCancelConfig($data, $this->site_id, 'shop');
+ } else {
+ //获取注册设置
+ $config_info = $config_model->getCancelConfig($this->site_id, 'shop');
+ $value = $config_info[ 'data' ][ 'value' ];
+
+ $this->assign('value', $value);
+
+ return $this->fetch('membercancel/cancel_config');
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberprice/config/diy_view.php b/src/addon/memberprice/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/memberprice/config/diy_view.php
+++ b/src/addon/memberprice/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/memberprice/config/info.php b/src/addon/memberprice/config/info.php
index aa27c8365..bb53d666e 100644
--- a/src/addon/memberprice/config/info.php
+++ b/src/addon/memberprice/config/info.php
@@ -1,20 +1,12 @@
- 'memberprice',
- 'title' => '会员价',
- 'description' => '会员价',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'memberprice',
+ 'title' => '会员价',
+ 'description' => '会员价',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/memberprice/event/Install.php b/src/addon/memberprice/event/Install.php
index 32999fd27..832e48c36 100644
--- a/src/addon/memberprice/event/Install.php
+++ b/src/addon/memberprice/event/Install.php
@@ -1,25 +1,17 @@
- "会员价", "type" => "memberprice" ];
- }
+ "会员价", "type" => "memberprice" ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberprice/event/UnInstall.php b/src/addon/memberprice/event/UnInstall.php
index 1cbd1e208..ae2c54a02 100644
--- a/src/addon/memberprice/event/UnInstall.php
+++ b/src/addon/memberprice/event/UnInstall.php
@@ -1,25 +1,17 @@
-startTrans();
- try {
-
- model('goods')->update($data, $condition);
- if ($data[ 'discount_config' ] == 1) {
- foreach ($member_price as $k => $v) {
- $sku_condition = $condition;
- $data[ 'member_price' ] = json_encode($v);
- $sku_condition[] = [ 'sku_id', '=', $k ];
- model('goods_sku')->update($data, $sku_condition);
- }
-
- } else {
- $data[ 'member_price' ] = '';
- model('goods_sku')->update($data, $condition);
- }
- model('goods')->commit();
- return $this->success();
- } catch (\Exception $e) {
- model('goods')->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
+startTrans();
+ try {
+
+ model('goods')->update($data, $condition);
+ if ($data[ 'discount_config' ] == 1) {
+ foreach ($member_price as $k => $v) {
+ $sku_condition = $condition;
+ $data[ 'member_price' ] = json_encode($v);
+ $sku_condition[] = [ 'sku_id', '=', $k ];
+ model('goods_sku')->update($data, $sku_condition);
+ }
+
+ } else {
+ $data[ 'member_price' ] = '';
+ model('goods_sku')->update($data, $condition);
+ }
+ model('goods')->commit();
+ return $this->success();
+ } catch (\Exception $e) {
+ model('goods')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberprice/shop/controller/Goods.php b/src/addon/memberprice/shop/controller/Goods.php
index 8d07407b1..c203b486a 100644
--- a/src/addon/memberprice/shop/controller/Goods.php
+++ b/src/addon/memberprice/shop/controller/Goods.php
@@ -1,62 +1,54 @@
-getGoodsDetail($goods_id);
- $this->assign('goods_info', $goods_info[ 'data' ]);
-
- //会员等级
- $member_level_model = new MemberLevel();
- $condition = [ [ 'site_id', '=', $this->site_id ] ];
- $order = 'level_type asc,growth asc';
- $field = '*';
- $level_list = $member_level_model->getMemberLevelList($condition, $field, $order);
- $this->assign('level_list', $level_list[ 'data' ]);
-
- if (request()->isJson()) {
-
- $goods_sku_model = new MemberPrice();
- $data = [
- 'is_consume_discount' => input('is_consume_discount', 0),
- 'discount_config' => input('discount_config', 0),
- 'discount_method' => input('discount_method', ''),
- ];
- $member_price = input('member_price', '');
- $goods_id = input('goods_id');
- $condition[] = [ 'goods_id', '=', $goods_id ];
- $condition[] = [ 'site_id', '=', $this->site_id ];
-
- return $goods_sku_model->editGoodsMemberPrice($condition, $data, $member_price);
- }
-
- return $this->fetch('goods/config');
- }
-
+getGoodsDetail($goods_id);
+ $this->assign('goods_info', $goods_info[ 'data' ]);
+
+ //会员等级
+ $member_level_model = new MemberLevel();
+ $condition = [ [ 'site_id', '=', $this->site_id ] ];
+ $order = 'level_type asc,growth asc';
+ $field = '*';
+ $level_list = $member_level_model->getMemberLevelList($condition, $field, $order);
+ $this->assign('level_list', $level_list[ 'data' ]);
+
+ if (request()->isJson()) {
+
+ $goods_sku_model = new MemberPrice();
+ $data = [
+ 'is_consume_discount' => input('is_consume_discount', 0),
+ 'discount_config' => input('discount_config', 0),
+ 'discount_method' => input('discount_method', ''),
+ ];
+ $member_price = input('member_price', '');
+ $goods_id = input('goods_id');
+ $condition[] = [ 'goods_id', '=', $goods_id ];
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+
+ return $goods_sku_model->editGoodsMemberPrice($condition, $data, $member_price);
+ }
+
+ return $this->fetch('goods/config');
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/api/controller/Memberrecharge.php b/src/addon/memberrecharge/api/controller/Memberrecharge.php
index ec28f2633..b49e678bd 100644
--- a/src/addon/memberrecharge/api/controller/Memberrecharge.php
+++ b/src/addon/memberrecharge/api/controller/Memberrecharge.php
@@ -1,59 +1,51 @@
-params['recharge_id'] ?? 0;
- if (empty($recharge_id)) {
- return $this->response($this->error('', 'REQUEST_RECHARGE_ID'));
- }
- $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id,sale_num,status';
- $member_recharge_model = new MemberRechargeModel();
- $info = $member_recharge_model->getMemberRechargeInfo([ [ 'recharge_id', '=', $recharge_id ], [ 'site_id', '=', $this->site_id ] ], $field);
- return $this->response($info);
- }
-
- /**
- * 会员充值配置
- */
- public function config()
- {
- $member_recharge_model = new MemberRechargeModel();
- $res = $member_recharge_model->getConfig($this->site_id);
- return $this->response($res);
- }
-
- /**
- * 计算信息
- */
- public function page()
- {
- $page = $this->params['page'] ?? 1;
- $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
- $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id,sale_num';
- $member_recharge_model = new MemberRechargeModel();
- $list = $member_recharge_model->getMemberRechargePageList([ [ 'status', '=', 1 ], [ 'site_id', '=', $this->site_id ] ], $page, $page_size, 'create_time desc', $field);
- return $this->response($list);
- }
+params['recharge_id'] ?? 0;
+ if (empty($recharge_id)) {
+ return $this->response($this->error('', 'REQUEST_RECHARGE_ID'));
+ }
+ $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id,sale_num,status';
+ $member_recharge_model = new MemberRechargeModel();
+ $info = $member_recharge_model->getMemberRechargeInfo([ [ 'recharge_id', '=', $recharge_id ], [ 'site_id', '=', $this->site_id ] ], $field);
+ return $this->response($info);
+ }
+
+ /**
+ * 会员充值配置
+ */
+ public function config()
+ {
+ $member_recharge_model = new MemberRechargeModel();
+ $res = $member_recharge_model->getConfig($this->site_id);
+ return $this->response($res);
+ }
+
+ /**
+ * 计算信息
+ */
+ public function page()
+ {
+ $page = $this->params['page'] ?? 1;
+ $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
+ $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id,sale_num';
+ $member_recharge_model = new MemberRechargeModel();
+ $list = $member_recharge_model->getMemberRechargePageList([ [ 'status', '=', 1 ], [ 'site_id', '=', $this->site_id ] ], $page, $page_size, 'create_time desc', $field);
+ return $this->response($list);
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/api/controller/Order.php b/src/addon/memberrecharge/api/controller/Order.php
index b12c7d46d..05dcec3ff 100644
--- a/src/addon/memberrecharge/api/controller/Order.php
+++ b/src/addon/memberrecharge/api/controller/Order.php
@@ -1,41 +1,33 @@
-checkToken();
- if ($token[ 'code' ] < 0) return $this->response($token);
- $page = $this->params['page'] ?? 1;
- $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
- $field = 'order_id,recharge_id,recharge_name,order_no,cover_img,buy_price,create_time,out_trade_no,face_value,point,growth,coupon_id';
- $member_recharge_order_model = new MemberRechargeOrderModel();
- $condition = array (
- [ 'status', '=', 2 ],
- [ 'member_id', '=', $this->member_id ],
- [ 'site_id', '=', $this->site_id ]
- );
- $list = $member_recharge_order_model->getMemberRechargeOrderPageList($condition, $page, $page_size, 'create_time desc', $field);
- return $this->response($list);
- }
+checkToken();
+ if ($token[ 'code' ] < 0) return $this->response($token);
+ $page = $this->params['page'] ?? 1;
+ $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
+ $field = 'order_id,recharge_id,recharge_name,order_no,cover_img,buy_price,create_time,out_trade_no,face_value,point,growth,coupon_id';
+ $member_recharge_order_model = new MemberRechargeOrderModel();
+ $condition = array (
+ [ 'status', '=', 2 ],
+ [ 'member_id', '=', $this->member_id ],
+ [ 'site_id', '=', $this->site_id ]
+ );
+ $list = $member_recharge_order_model->getMemberRechargeOrderPageList($condition, $page, $page_size, 'create_time desc', $field);
+ return $this->response($list);
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/config/diy_view.php b/src/addon/memberrecharge/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/memberrecharge/config/diy_view.php
+++ b/src/addon/memberrecharge/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/memberrecharge/config/info.php b/src/addon/memberrecharge/config/info.php
index 1cb5254e4..559215f50 100644
--- a/src/addon/memberrecharge/config/info.php
+++ b/src/addon/memberrecharge/config/info.php
@@ -1,21 +1,12 @@
- 'memberrecharge',
- 'title' => '充值礼包',
- 'description' => '会员充值设置',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'memberrecharge',
+ 'title' => '充值礼包',
+ 'description' => '会员充值设置',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/IncomeStatistics.php b/src/addon/memberrecharge/event/IncomeStatistics.php
index 2d0e52a46..e5140f695 100644
--- a/src/addon/memberrecharge/event/IncomeStatistics.php
+++ b/src/addon/memberrecharge/event/IncomeStatistics.php
@@ -1,33 +1,24 @@
-getOrderSum([ ['site_id', '=', $param['site_id'] ], ['pay_time', 'between', [$param['start_time'], $param['end_time']] ] ], 'buy_price')['data'];
- return [
- [
- 'title' => '会员充值',
- 'value' => $money,
- 'desc' => '统计时间内,所有会员充值金额之和',
- 'url' => 'memberrecharge://shop/memberrecharge/orderlists'
- ]
- ];
- }
+getOrderSum([ ['site_id', '=', $param['site_id'] ], ['pay_time', 'between', [$param['start_time'], $param['end_time']] ] ], 'buy_price')['data'];
+ return [
+ [
+ 'title' => '会员充值',
+ 'value' => $money,
+ 'desc' => '统计时间内,所有会员充值金额之和',
+ 'url' => 'memberrecharge://shop/memberrecharge/orderlists'
+ ]
+ ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/Install.php b/src/addon/memberrecharge/event/Install.php
index 7151d0b2d..1f9ff60b0 100644
--- a/src/addon/memberrecharge/event/Install.php
+++ b/src/addon/memberrecharge/event/Install.php
@@ -1,26 +1,17 @@
- [
- 'memberrecharge' => [
- 'type_name' => '会员充值',
- 'admin_url' => 'admin/order/detail',
- 'tag_name' => 'order_id'
- ],
- ],
- 'point' => [
- 'memberrecharge' => [
- 'type_name' => '会员充值',
- 'type_url' => '',
- ],
-
- ],
- 'growth' => [
- 'memberrecharge' => [
- 'type_name' => '会员充值',
- 'type_url' => '',
- ],
- ],
- ];
- if ($data == '') {
- return $from_type;
- } else {
- return $from_type[$data] ?? [];
- }
-
- }
+ [
+ 'memberrecharge' => [
+ 'type_name' => '会员充值',
+ 'admin_url' => 'admin/order/detail',
+ 'tag_name' => 'order_id'
+ ],
+ ],
+ 'point' => [
+ 'memberrecharge' => [
+ 'type_name' => '会员充值',
+ 'type_url' => '',
+ ],
+
+ ],
+ 'growth' => [
+ 'memberrecharge' => [
+ 'type_name' => '会员充值',
+ 'type_url' => '',
+ ],
+ ],
+ ];
+ if ($data == '') {
+ return $from_type;
+ } else {
+ return $from_type[$data] ?? [];
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/MemberrechargeOrderClose.php b/src/addon/memberrecharge/event/MemberrechargeOrderClose.php
index 07765a4b7..65f4fdd9d 100644
--- a/src/addon/memberrecharge/event/MemberrechargeOrderClose.php
+++ b/src/addon/memberrecharge/event/MemberrechargeOrderClose.php
@@ -1,28 +1,19 @@
-cronMemberRechargeOrderClose($params['relate_id']);
- return $res;
- }
+cronMemberRechargeOrderClose($params['relate_id']);
+ return $res;
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/MemberrechargeOrderPayNotify.php b/src/addon/memberrecharge/event/MemberrechargeOrderPayNotify.php
index dbf151719..6974b3014 100644
--- a/src/addon/memberrecharge/event/MemberrechargeOrderPayNotify.php
+++ b/src/addon/memberrecharge/event/MemberrechargeOrderPayNotify.php
@@ -1,28 +1,20 @@
-orderPay($data);
- return $res;
- }
-
+orderPay($data);
+ return $res;
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/PrinterContent.php b/src/addon/memberrecharge/event/PrinterContent.php
index df34bef60..30fc26084 100644
--- a/src/addon/memberrecharge/event/PrinterContent.php
+++ b/src/addon/memberrecharge/event/PrinterContent.php
@@ -1,125 +1,117 @@
-getMemberRechargeOrderInfo([ [ 'order_id', '=', $order_id ] ])[ 'data' ];
- $params[ 'site_id' ] = $order_info[ 'site_id' ] ?? 0;
-
- $member = new Member();
- $member_info = $member->getMemberInfo([ [ 'member_id', '=', $order_info[ 'member_id' ] ] ], 'balance, balance_money')[ 'data' ] ?? [];
- $account = number_format($member_info[ 'balance' ] + $member_info[ 'balance_money' ], 2, '.', '');
-
- //获取店铺信息
- $shop_model = new Shop();
- $shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $params[ 'site_id' ] ] ])[ 'data' ];
-
- $site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $params[ 'site_id' ] ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
-
- //获取打印机列表
- $print_model = new Printer();
- $printer_data = $print_model->getPrinterList([ [ 'site_id', '=', $params[ 'site_id' ] ], [ 'store_id', '=', $order_info[ 'store_id' ] ], [ 'recharge_open', '=', 1 ] ])[ 'data' ] ?? [];
-
- $res_data = [];
-
- foreach ($printer_data as $k => $v) {
- //此处应该根据打印机不同分别设置返回不同的数据。当前为易联云
- $array = [];
- $array[ 'printer_info' ] = $v;
- $print_template_model = new PrinterTemplate();
-
- $template_id = $v[ 'recharge_template_id' ];
-
- $print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ] ])[ 'data' ];
-
- $array[ 'printer_code' ] = $v[ 'printer_code' ]; //商户授权机器码
- $array[ 'origin_id' ] = $order_info[ 'order_no' ]; //内部订单号(32位以内)
- /**文本接口开始**/
- $content = "" . $v[ 'recharge_print_num' ] . "";
- //小票名称
- if ($print_template[ 'title' ] != '') {
- $content .= "
" . $print_template[ 'title' ] . "";
- $content .= str_repeat('.', 32);
- }
- //商城名称
- if ($print_template[ 'head' ] == 1) {
- $content .= "" . $site_name . "";
- $content .= str_repeat('.', 32);
- }
- $content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
- $content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
- $content .= "支付方式:" . $order_info[ 'pay_type_name' ] . "\n";
- $content .= str_repeat('.', 32);
-
- $content .= "充值金额:¥" . $order_info[ "face_value" ] . "\n";
- $content .= "实付金额:¥" . $order_info[ "price" ] . "\n";
- $content .= "会员余额:¥" . $account . "\n";
-
- /******************** 买家信息 **************************/
- //买家姓名
- if ($print_template[ 'buy_name' ] == 1) {
- $content .= "会员:" . $order_info[ "nickname" ] . "\n";
- $content .= str_repeat('.', 32);
- }
-
- /******************** 商城信息 **************************/
- //联系方式
- if ($print_template[ 'shop_mobile' ] == 1) {
- $content .= "" . $shop_info[ "mobile" ] . "\n";
- }
- //地址
- if ($print_template[ 'shop_address' ] == 1) {
- $content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
- }
-
- if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
- $content .= str_repeat('.', 32);
- }
- //二维码
- if ($print_template[ 'shop_qrcode' ] == 1) {
- $content .= "" . $print_template[ 'qrcode_url' ] . "";
- $content .= str_repeat('.', 32);
- }
-
- //底部内容
- if (!empty($print_template[ 'bottom' ])) {
-
- $content .= "" . $print_template[ 'bottom' ] . "";
- }
- $array[ 'content' ] = $content;
-
- $res_data[] = $array;
- }
-
- return $res_data;
-
- }
- }
+getMemberRechargeOrderInfo([ [ 'order_id', '=', $order_id ] ])[ 'data' ];
+ $params[ 'site_id' ] = $order_info[ 'site_id' ] ?? 0;
+
+ $member = new Member();
+ $member_info = $member->getMemberInfo([ [ 'member_id', '=', $order_info[ 'member_id' ] ] ], 'balance, balance_money')[ 'data' ] ?? [];
+ $account = number_format($member_info[ 'balance' ] + $member_info[ 'balance_money' ], 2, '.', '');
+
+ //获取店铺信息
+ $shop_model = new Shop();
+ $shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $params[ 'site_id' ] ] ])[ 'data' ];
+
+ $site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $params[ 'site_id' ] ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
+
+ //获取打印机列表
+ $print_model = new Printer();
+ $printer_data = $print_model->getPrinterList([ [ 'site_id', '=', $params[ 'site_id' ] ], [ 'store_id', '=', $order_info[ 'store_id' ] ], [ 'recharge_open', '=', 1 ] ])[ 'data' ] ?? [];
+
+ $res_data = [];
+
+ foreach ($printer_data as $k => $v) {
+ //此处应该根据打印机不同分别设置返回不同的数据。当前为易联云
+ $array = [];
+ $array[ 'printer_info' ] = $v;
+ $print_template_model = new PrinterTemplate();
+
+ $template_id = $v[ 'recharge_template_id' ];
+
+ $print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ] ])[ 'data' ];
+
+ $array[ 'printer_code' ] = $v[ 'printer_code' ]; //商户授权机器码
+ $array[ 'origin_id' ] = $order_info[ 'order_no' ]; //内部订单号(32位以内)
+ /**文本接口开始**/
+ $content = "" . $v[ 'recharge_print_num' ] . "";
+ //小票名称
+ if ($print_template[ 'title' ] != '') {
+ $content .= "" . $print_template[ 'title' ] . "";
+ $content .= str_repeat('.', 32);
+ }
+ //商城名称
+ if ($print_template[ 'head' ] == 1) {
+ $content .= "" . $site_name . "";
+ $content .= str_repeat('.', 32);
+ }
+ $content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
+ $content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
+ $content .= "支付方式:" . $order_info[ 'pay_type_name' ] . "\n";
+ $content .= str_repeat('.', 32);
+
+ $content .= "充值金额:¥" . $order_info[ "face_value" ] . "\n";
+ $content .= "实付金额:¥" . $order_info[ "price" ] . "\n";
+ $content .= "会员余额:¥" . $account . "\n";
+
+ /******************** 买家信息 **************************/
+ //买家姓名
+ if ($print_template[ 'buy_name' ] == 1) {
+ $content .= "会员:" . $order_info[ "nickname" ] . "\n";
+ $content .= str_repeat('.', 32);
+ }
+
+ /******************** 商城信息 **************************/
+ //联系方式
+ if ($print_template[ 'shop_mobile' ] == 1) {
+ $content .= "" . $shop_info[ "mobile" ] . "\n";
+ }
+ //地址
+ if ($print_template[ 'shop_address' ] == 1) {
+ $content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
+ }
+
+ if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
+ $content .= str_repeat('.', 32);
+ }
+ //二维码
+ if ($print_template[ 'shop_qrcode' ] == 1) {
+ $content .= "" . $print_template[ 'qrcode_url' ] . "";
+ $content .= str_repeat('.', 32);
+ }
+
+ //底部内容
+ if (!empty($print_template[ 'bottom' ])) {
+
+ $content .= "" . $print_template[ 'bottom' ] . "";
+ }
+ $array[ 'content' ] = $content;
+
+ $res_data[] = $array;
+ }
+
+ return $res_data;
+
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/PrinterHtml.php b/src/addon/memberrecharge/event/PrinterHtml.php
index 592ef93c0..b299e98e0 100644
--- a/src/addon/memberrecharge/event/PrinterHtml.php
+++ b/src/addon/memberrecharge/event/PrinterHtml.php
@@ -1,26 +1,17 @@
-fetch('addon/memberrecharge/shop/view/template/printer_template.html');
- }
+fetch('addon/memberrecharge/shop/view/template/printer_template.html');
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/PrinterTemplateType.php b/src/addon/memberrecharge/event/PrinterTemplateType.php
index 09460c225..915be37a3 100644
--- a/src/addon/memberrecharge/event/PrinterTemplateType.php
+++ b/src/addon/memberrecharge/event/PrinterTemplateType.php
@@ -1,31 +1,22 @@
- 'recharge',
- 'type_name' => '会员充值',
- 'edit' => 'addon/memberrecharge/shop/view/template/recharge_template.html',
- 'add' => 'addon/memberrecharge/shop/view/template/recharge_template.html',
- ]
- ];
- }
+ 'recharge',
+ 'type_name' => '会员充值',
+ 'edit' => 'addon/memberrecharge/shop/view/template/recharge_template.html',
+ 'add' => 'addon/memberrecharge/shop/view/template/recharge_template.html',
+ ]
+ ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/PromotionType.php b/src/addon/memberrecharge/event/PromotionType.php
index 183225128..5d48cf576 100644
--- a/src/addon/memberrecharge/event/PromotionType.php
+++ b/src/addon/memberrecharge/event/PromotionType.php
@@ -1,27 +1,19 @@
- "充值礼包", "type" => "memberrecharge" ];
- }
+ "充值礼包", "type" => "memberrecharge" ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/ShowPromotion.php b/src/addon/memberrecharge/event/ShowPromotion.php
index 408f610e1..a661307ea 100644
--- a/src/addon/memberrecharge/event/ShowPromotion.php
+++ b/src/addon/memberrecharge/event/ShowPromotion.php
@@ -1,84 +1,76 @@
- [
- [
- //插件名称
- 'name' => 'memberrecharge',
- //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
- 'show_type' => 'member',
- //展示主题
- 'title' => '充值礼包',
- //展示介绍
- 'description' => '提高客户充值金额',
- //展示图标
- 'icon' => 'addon/memberrecharge/icon.png',
- //跳转链接
- 'url' => 'memberrecharge://shop/memberrecharge/lists',
- 'summary' => $this->summary($params)
- ]
- ]
-
- ];
- return $data;
- }
-
- private function summary($params)
- {
- if (empty($params)) {
- return [];
- }
-
- if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
- return [];
- }
-
- if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Memberrecharge() )->getConfig($params[ 'site_id' ])[ 'data' ];
- //获取活动数量
- if (isset($params[ 'count' ])) {
- $count = model("member_recharge")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
- return [
- 'count' => $count
- ];
- }
- //获取活动概况,需要获取开始时间与结束时间
- if (isset($params[ 'summary' ])) {
- $count = model("member_recharge")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ], [ 'status', '=', 1 ] ]);
-
- return [
- 'unlimited_time' => [
- 'status' => $config[ 'is_use' ],
- 'detail' => $count ? '已配置' . $count . '个充值套餐' : '未配置充值套餐',
- 'switch_type' => 'switch',
- 'config_key' => 'MEMBER_RECHARGE_CONFIG'
- ]
- ];
- }
- }
+ [
+ [
+ //插件名称
+ 'name' => 'memberrecharge',
+ //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
+ 'show_type' => 'member',
+ //展示主题
+ 'title' => '充值礼包',
+ //展示介绍
+ 'description' => '提高客户充值金额',
+ //展示图标
+ 'icon' => 'addon/memberrecharge/icon.png',
+ //跳转链接
+ 'url' => 'memberrecharge://shop/memberrecharge/lists',
+ 'summary' => $this->summary($params)
+ ]
+ ]
+
+ ];
+ return $data;
+ }
+
+ private function summary($params)
+ {
+ if (empty($params)) {
+ return [];
+ }
+
+ if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
+ return [];
+ }
+
+ if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Memberrecharge() )->getConfig($params[ 'site_id' ])[ 'data' ];
+ //获取活动数量
+ if (isset($params[ 'count' ])) {
+ $count = model("member_recharge")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
+ return [
+ 'count' => $count
+ ];
+ }
+ //获取活动概况,需要获取开始时间与结束时间
+ if (isset($params[ 'summary' ])) {
+ $count = model("member_recharge")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ], [ 'status', '=', 1 ] ]);
+
+ return [
+ 'unlimited_time' => [
+ 'status' => $config[ 'is_use' ],
+ 'detail' => $count ? '已配置' . $count . '个充值套餐' : '未配置充值套餐',
+ 'switch_type' => 'switch',
+ 'config_key' => 'MEMBER_RECHARGE_CONFIG'
+ ]
+ ];
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/event/UnInstall.php b/src/addon/memberrecharge/event/UnInstall.php
index 3f63fceb9..c26d794c7 100644
--- a/src/addon/memberrecharge/event/UnInstall.php
+++ b/src/addon/memberrecharge/event/UnInstall.php
@@ -1,26 +1,17 @@
-getSiteInfo([ [ 'site_id', '=', $data[ 'site_id' ] ] ]);
- $card_account = substr(md5(date('YmdHis') . mt_rand(100, 999)), 8, 16);
- $card_data = [
- 'recharge_id' => $data[ 'recharge_id' ],
- 'site_id' => $data[ 'site_id' ],
- 'site_name' => $site_info[ 'data' ][ 'site_name' ],
- 'recharge_name' => $data[ 'recharge_name' ],
- 'card_account' => $card_account,
- 'cover_img' => $data[ 'cover_img' ],
- 'face_value' => $data[ 'face_value' ],
- 'point' => $data[ 'point' ],
- 'growth' => $data[ 'growth' ],
- 'coupon_id' => $data[ 'coupon_id' ],
- 'buy_price' => $data[ 'buy_price' ],
- 'member_id' => $data[ 'member_id' ],
- 'member_img' => $data[ 'member_img' ],
- 'nickname' => $data[ 'nickname' ],
- 'order_id' => $data[ 'order_id' ],
- 'order_no' => $data[ 'order_no' ],
- 'use_status' => $data[ 'use_status' ],
- 'create_time' => time(),
- 'use_time' => $data[ 'use_time' ]
- ];
- $res = model('member_recharge_card')->add($card_data);
- Cache::tag("member_recharge_card")->clear();
- return $this->success($res);
- }
-
- /**
- * 开卡发放礼包
- * @param $order_info
- */
- public function addMemberAccount($order_info)
- {
- $member_account = new MemberAccount();
- //修改用户的余额
- $member_account->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], AccountDict::balance, $order_info[ 'face_value' ], 'memberrecharge', '0', '会员充值');
-
- //积分
- if ($order_info[ 'point' ] > 0) {
- $member_account->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], 'point', $order_info[ 'point' ], 'memberrecharge', '0', '会员充值奖励');
- }
-
- //成长值
- if ($order_info[ 'growth' ] > 0) {
- $member_account->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], 'growth', $order_info[ 'growth' ], 'memberrecharge', '0', '会员充值奖励');
- }
- //添加优惠券
- if (!empty($order_info[ 'coupon_id' ])) {
- $coupon_model = new Coupon();
- $coupon_id = explode(',', $order_info[ 'coupon_id' ]);
- $coupon_list = array_map(function($value) {
- return [ 'coupon_type_id' => $value, 'num' => 1 ];
- }, $coupon_id);
- $coupon_model->giveCoupon($coupon_list, $order_info[ 'site_id' ], $order_info[ 'member_id' ], 6);
- }
- }
-
- /**
- * 套餐详情
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getMemberRechargeCardInfo($condition = [], $field = '*')
- {
- $info = model('member_recharge_card')->getInfo($condition, $field);
- if ($info) {
- //获取优惠券信息
- if ($info[ 'coupon_id' ]) {
- //优惠券字段
- $coupon_field = '*';
- $model = new CouponType();
- $coupon_list = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $info[ 'coupon_id' ] ] ], $coupon_field);
- $info[ 'coupon_list' ] = $coupon_list[ 'data' ];
- }
- }
- Cache::tag("member_recharge_card")->clear();
- return $this->success($info);
- }
-
- /**
- * 开卡列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getMemberRechargeCardPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
- {
- $list = model('member_recharge_card')->pageList($condition, $field, $order, $page, $page_size);
-
- Cache::tag("member_recharge_card")->clear();
- return $this->success($list);
- }
-
+getSiteInfo([ [ 'site_id', '=', $data[ 'site_id' ] ] ]);
+ $card_account = substr(md5(date('YmdHis') . mt_rand(100, 999)), 8, 16);
+ $card_data = [
+ 'recharge_id' => $data[ 'recharge_id' ],
+ 'site_id' => $data[ 'site_id' ],
+ 'site_name' => $site_info[ 'data' ][ 'site_name' ],
+ 'recharge_name' => $data[ 'recharge_name' ],
+ 'card_account' => $card_account,
+ 'cover_img' => $data[ 'cover_img' ],
+ 'face_value' => $data[ 'face_value' ],
+ 'point' => $data[ 'point' ],
+ 'growth' => $data[ 'growth' ],
+ 'coupon_id' => $data[ 'coupon_id' ],
+ 'buy_price' => $data[ 'buy_price' ],
+ 'member_id' => $data[ 'member_id' ],
+ 'member_img' => $data[ 'member_img' ],
+ 'nickname' => $data[ 'nickname' ],
+ 'order_id' => $data[ 'order_id' ],
+ 'order_no' => $data[ 'order_no' ],
+ 'use_status' => $data[ 'use_status' ],
+ 'create_time' => time(),
+ 'use_time' => $data[ 'use_time' ]
+ ];
+ $res = model('member_recharge_card')->add($card_data);
+ Cache::tag("member_recharge_card")->clear();
+ return $this->success($res);
+ }
+
+ /**
+ * 开卡发放礼包
+ * @param $order_info
+ */
+ public function addMemberAccount($order_info)
+ {
+ $member_account = new MemberAccount();
+ //修改用户的余额
+ $member_account->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], AccountDict::balance, $order_info[ 'face_value' ], 'memberrecharge', '0', '会员充值');
+
+ //积分
+ if ($order_info[ 'point' ] > 0) {
+ $member_account->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], 'point', $order_info[ 'point' ], 'memberrecharge', '0', '会员充值奖励');
+ }
+
+ //成长值
+ if ($order_info[ 'growth' ] > 0) {
+ $member_account->addMemberAccount($order_info[ 'site_id' ], $order_info[ 'member_id' ], 'growth', $order_info[ 'growth' ], 'memberrecharge', '0', '会员充值奖励');
+ }
+ //添加优惠券
+ if (!empty($order_info[ 'coupon_id' ])) {
+ $coupon_model = new Coupon();
+ $coupon_id = explode(',', $order_info[ 'coupon_id' ]);
+ $coupon_list = array_map(function($value) {
+ return [ 'coupon_type_id' => $value, 'num' => 1 ];
+ }, $coupon_id);
+ $coupon_model->giveCoupon($coupon_list, $order_info[ 'site_id' ], $order_info[ 'member_id' ], 6);
+ }
+ }
+
+ /**
+ * 套餐详情
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getMemberRechargeCardInfo($condition = [], $field = '*')
+ {
+ $info = model('member_recharge_card')->getInfo($condition, $field);
+ if ($info) {
+ //获取优惠券信息
+ if ($info[ 'coupon_id' ]) {
+ //优惠券字段
+ $coupon_field = '*';
+ $model = new CouponType();
+ $coupon_list = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $info[ 'coupon_id' ] ] ], $coupon_field);
+ $info[ 'coupon_list' ] = $coupon_list[ 'data' ];
+ }
+ }
+ Cache::tag("member_recharge_card")->clear();
+ return $this->success($info);
+ }
+
+ /**
+ * 开卡列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @return array
+ */
+ public function getMemberRechargeCardPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
+ {
+ $list = model('member_recharge_card')->pageList($condition, $field, $order, $page, $page_size);
+
+ Cache::tag("member_recharge_card")->clear();
+ return $this->success($list);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/model/Memberrecharge.php b/src/addon/memberrecharge/model/Memberrecharge.php
index 7db04fe28..25267a6f8 100644
--- a/src/addon/memberrecharge/model/Memberrecharge.php
+++ b/src/addon/memberrecharge/model/Memberrecharge.php
@@ -1,157 +1,149 @@
-add($data);
- Cache::tag("member_recharge")->clear();
- return $this->success($res);
- }
-
- /**
- * 编辑套餐
- * @param array $condition
- * @param $data
- * @return array
- */
- public function editMemberRecharge($condition, $data)
- {
- $data[ 'update_time' ] = time();
- $recharge_info = model('member_recharge')->getInfo($condition);
- if (!empty($recharge_info[ 'cover_img' ]) && !empty($data[ 'cover_img' ]) && $recharge_info[ 'cover_img' ] != $data[ 'cover_img' ]) {
- $upload_model = new Upload();
- $upload_model->deletePic($recharge_info[ 'cover_img' ], $recharge_info[ 'site_id' ]);
- }
-
- $res = model('member_recharge')->update($data, $condition);
- Cache::tag("member_recharge")->clear();
- return $this->success($res);
- }
-
- /**
- * 删除套餐详情
- * @param array $condition
- * @return mixed
- */
- public function deleteMemberRecharge($condition = [])
- {
- $recharge_info = model('member_recharge')->getInfo($condition);
- if (!empty($recharge_info[ 'cover_img' ])) {
- $upload_model = new Upload();
- $upload_model->deletePic($recharge_info[ 'cover_img' ], $recharge_info[ 'site_id' ]);
- }
- $res = model('member_recharge')->delete($condition);
- Cache::tag("member_recharge")->clear();
- return $this->success($res);
- }
-
- /**
- * 套餐详情
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getMemberRechargeInfo($condition = [], $field = '*')
- {
- $recharge = model('member_recharge')->getInfo($condition, $field);
- if ($recharge) {
- //获取优惠券信息
- if ($recharge[ 'coupon_id' ]) {
- //优惠券字段
- $coupon_field = 'coupon_type_id,coupon_name,money,count,lead_count,max_fetch,at_least,end_time,image,validity_type,fixed_term,type,discount';
-
- $model = new CouponType();
- $coupon = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $recharge[ 'coupon_id' ] ] ], $coupon_field);
- $recharge[ 'coupon_list' ] = $coupon[ 'data' ];
- }
- }
- Cache::tag("member_recharge")->clear();
- return $this->success($recharge);
- }
-
- /**
- * 套餐分页列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getMemberRechargePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
- {
- $list = model('member_recharge')->pageList($condition, $field, $order, $page, $page_size);
-
- Cache::tag("member_recharge")->clear();
- return $this->success($list);
- }
-
- /**
- * 套餐列表
- * @param array $condition
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getMemberRechargeList($condition = [], $order = '', $field = '*')
- {
- $list = model('member_recharge')->getList($condition, $field, $order);
- return $this->success($list);
- }
-
- /**
- * 设置会员充值配置
- * @param $data
- * @param $is_use
- * @param $site_id
- * @return array
- */
- public function setConfig($data, $is_use, $site_id)
- {
- $config = new ConfigModel();
- $res = $config->setConfig($data, '会员充值配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'MEMBER_RECHARGE_CONFIG' ] ]);
- return $res;
- }
-
- /**
- * 获取会员充值配置
- * @param $site_id
- * @return array
- */
- public function getConfig($site_id)
- {
- $config = new ConfigModel();
- $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'MEMBER_RECHARGE_CONFIG' ] ]);
- return $res;
- }
-
+add($data);
+ Cache::tag("member_recharge")->clear();
+ return $this->success($res);
+ }
+
+ /**
+ * 编辑套餐
+ * @param array $condition
+ * @param $data
+ * @return array
+ */
+ public function editMemberRecharge($condition, $data)
+ {
+ $data[ 'update_time' ] = time();
+ $recharge_info = model('member_recharge')->getInfo($condition);
+ if (!empty($recharge_info[ 'cover_img' ]) && !empty($data[ 'cover_img' ]) && $recharge_info[ 'cover_img' ] != $data[ 'cover_img' ]) {
+ $upload_model = new Upload();
+ $upload_model->deletePic($recharge_info[ 'cover_img' ], $recharge_info[ 'site_id' ]);
+ }
+
+ $res = model('member_recharge')->update($data, $condition);
+ Cache::tag("member_recharge")->clear();
+ return $this->success($res);
+ }
+
+ /**
+ * 删除套餐详情
+ * @param array $condition
+ * @return mixed
+ */
+ public function deleteMemberRecharge($condition = [])
+ {
+ $recharge_info = model('member_recharge')->getInfo($condition);
+ if (!empty($recharge_info[ 'cover_img' ])) {
+ $upload_model = new Upload();
+ $upload_model->deletePic($recharge_info[ 'cover_img' ], $recharge_info[ 'site_id' ]);
+ }
+ $res = model('member_recharge')->delete($condition);
+ Cache::tag("member_recharge")->clear();
+ return $this->success($res);
+ }
+
+ /**
+ * 套餐详情
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getMemberRechargeInfo($condition = [], $field = '*')
+ {
+ $recharge = model('member_recharge')->getInfo($condition, $field);
+ if ($recharge) {
+ //获取优惠券信息
+ if ($recharge[ 'coupon_id' ]) {
+ //优惠券字段
+ $coupon_field = 'coupon_type_id,coupon_name,money,count,lead_count,max_fetch,at_least,end_time,image,validity_type,fixed_term,type,discount';
+
+ $model = new CouponType();
+ $coupon = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $recharge[ 'coupon_id' ] ] ], $coupon_field);
+ $recharge[ 'coupon_list' ] = $coupon[ 'data' ];
+ }
+ }
+ Cache::tag("member_recharge")->clear();
+ return $this->success($recharge);
+ }
+
+ /**
+ * 套餐分页列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @return array
+ */
+ public function getMemberRechargePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
+ {
+ $list = model('member_recharge')->pageList($condition, $field, $order, $page, $page_size);
+
+ Cache::tag("member_recharge")->clear();
+ return $this->success($list);
+ }
+
+ /**
+ * 套餐列表
+ * @param array $condition
+ * @param string $order
+ * @param string $field
+ * @return array
+ */
+ public function getMemberRechargeList($condition = [], $order = '', $field = '*')
+ {
+ $list = model('member_recharge')->getList($condition, $field, $order);
+ return $this->success($list);
+ }
+
+ /**
+ * 设置会员充值配置
+ * @param $data
+ * @param $is_use
+ * @param $site_id
+ * @return array
+ */
+ public function setConfig($data, $is_use, $site_id)
+ {
+ $config = new ConfigModel();
+ $res = $config->setConfig($data, '会员充值配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'MEMBER_RECHARGE_CONFIG' ] ]);
+ return $res;
+ }
+
+ /**
+ * 获取会员充值配置
+ * @param $site_id
+ * @return array
+ */
+ public function getConfig($site_id)
+ {
+ $config = new ConfigModel();
+ $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'MEMBER_RECHARGE_CONFIG' ] ]);
+ return $res;
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/model/MemberrechargeOrder.php b/src/addon/memberrecharge/model/MemberrechargeOrder.php
index b922b46db..7c79386fb 100644
--- a/src/addon/memberrecharge/model/MemberrechargeOrder.php
+++ b/src/addon/memberrecharge/model/MemberrechargeOrder.php
@@ -1,307 +1,299 @@
-pay_type;
- //获取当前所有在线支付方式
- $onlinepay = event('PayType');
- if (!empty($onlinepay)) {
- foreach ($onlinepay as $k => $v) {
- $pay_type[ $v[ 'pay_type' ] ] = $v[ 'pay_type_name' ];
- }
- }
- $trade_pay_type_list = event('TradePayType', []);
- if (!empty($trade_pay_type_list)) {
- foreach ($trade_pay_type_list as $k => $v) {
- if (!empty($v)) {
- $pay_type = array_merge($pay_type, $v);
- }
- }
- }
- return $pay_type;
- }
-
- /**
- * 订单详情
- * @param array $condition
- * @param string $field
- * @param string $alias
- * @param array $join
- * @return array
- */
- public function getMemberRechargeOrderInfo($condition = [], $field = '*', $alias = 'a', $join = [])
- {
- $order = model('member_recharge_order')->getInfo($condition, $field, $alias, $join);
- if ($order) {
- //获取优惠券信息
- $coupon_id = $order[ 'coupon_id' ] ?? 0;
- if ($coupon_id > 0) {
- //优惠券字段
- $coupon_field = 'coupon_type_id,coupon_name,money,count,lead_count,max_fetch,at_least,end_time,image,validity_type,fixed_term,type';
-
- $model = new CouponType();
- $coupon = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $order[ 'coupon_id' ] ] ], $coupon_field);
- $order[ 'coupon_list' ] = $coupon;
- }
-
- }
-
- return $this->success($order);
- }
-
- /**
- * 订单列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @param string $alias
- * @param array $join
- * @return array
- */
- public function getMemberRechargeOrderPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [])
- {
- $list = model('member_recharge_order')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- if (!empty($list[ 'list' ])) {
- $coupon_ids = '';
- foreach ($list[ 'list' ] as $k => $v) {
- if (!empty($v[ 'coupon_id' ])) {
- $coupon_ids = empty($coupon_ids) ? $v[ 'coupon_id' ] : $coupon_ids . ',' . $v[ 'coupon_id' ];
- }
- }
- $coupon_list = [];
- if (!empty($coupon_ids)) {
- $coupon_list = model('promotion_coupon_type')->getList([ [ 'coupon_type_id', 'in', $coupon_ids ] ], 'coupon_type_id,coupon_name');
-
- }
- if (!empty($coupon_list)) {
- $key = array_column($coupon_list, 'coupon_type_id');
- $coupon_list = array_combine($key, $coupon_list);
- }
-
- foreach ($list[ 'list' ] as $k => $v) {
- $list[ 'list' ][ $k ][ 'coupon_name' ] = '';
- $coupon_name = '';
- if (!empty($v[ 'coupon_id' ])) {
- $coupon_array = explode(',', $v[ 'coupon_id' ]);
- foreach ($coupon_array as $value) {
- $coupon_name_value = $coupon_list[ $value ][ 'name' ] ?? '';
- $coupon_name .= ',' . $coupon_name_value;
- }
- $coupon_name = ltrim($coupon_name, ',');
- }
- $list[ 'list' ][ $k ][ 'coupon_name' ] = $coupon_name;
- }
- }
- return $this->success($list);
- }
-
- /**
- * 支付回调
- * @param $data
- * @return array|\multitype
- */
- public function orderPay($data)
- {
- $order_field = 'order_id,recharge_id,recharge_name,order_no,cover_img,face_value,buy_price,point,growth,coupon_id,price,pay_type,status,create_time,pay_time,member_id,member_img,nickname,site_id,out_trade_no,order_from';
- $order_info = $this->getMemberRechargeOrderInfo([ [ 'out_trade_no', '=', $data[ 'out_trade_no' ] ] ], $order_field)[ 'data' ];
- if ($order_info[ 'status' ] == 1) {
- model('member_recharge_order')->startTrans();
- try {
-
- $pay_list = $this->getPayType();
- $pay_type_name = '';
- if (!empty($data[ 'pay_type' ])) {
- $pay_type_name = $pay_list[ $data[ 'pay_type' ] ];
- }
-
- //修改订单状态
- $order_data = [
- 'pay_type' => $data[ 'pay_type' ],
- 'pay_type_name' => $pay_type_name,
- 'pay_time' => time(),
- 'price' => $order_info[ 'buy_price' ],
- 'status' => 2
- ];
- $res = model('member_recharge_order')->update($order_data, [ [ 'out_trade_no', '=', $data[ 'out_trade_no' ] ] ]);
-
- //添加开卡记录
- $card_model = new MemberRechargeCard();
- $order_info[ 'use_status' ] = 2;
- $order_info[ 'use_time' ] = time();
- $card_model->addMemberRechargeCard($order_info);
-
- //发放礼包
- $card_model->addMemberAccount($order_info);
-
- //获取套餐信息
- $recharge_model = new Memberrecharge();
- $recharge_info = $recharge_model->getMemberRechargeInfo([ [ 'recharge_id', '=', $order_info[ 'recharge_id' ] ] ], 'sale_num,coupon_id');
- //增加发放数
- if (!empty($recharge_info[ 'data' ])) {
- $sale_num = $recharge_info[ 'data' ][ 'sale_num' ] + 1;
- $recharge_model->editMemberRecharge([ [ 'recharge_id', '=', $order_info[ 'recharge_id' ] ] ], [ 'sale_num' => $sale_num ]);
- }
- $is_stat = $data[ 'is_stat' ] ?? true;
- if ($is_stat) {
- event('MemberRechargeOrderPay', [ 'order_id' => $order_info[ 'order_id' ], 'order_from' => $order_info[ 'order_from' ] ]);
- $stat_model = new Stat();
- $stat_res = $stat_model->switchStat([
- 'type' => 'recharge',
- 'data' => [
- 'order_id' => $order_info[ 'order_id' ],
- 'site_id' => $order_info[ 'site_id' ]
- ]
- ]);
- }
-
- // 小程序录入发货信息
- $member_service = new Member();
- $order_info[ 'member_info' ] = $member_service->getMemberInfo([
- [ 'site_id', '=', $order_info[ 'site_id' ] ],
- [ 'member_id', '=', $order_info[ 'member_id' ] ]
- ], 'weapp_openid')[ 'data' ];
-
- $this->uploadShippingInfo($order_info);
-
- model('member_recharge_order')->commit();
- return $this->success($res);
- } catch (\Exception $e) {
- model('member_recharge_order')->rollback();
- Log::write('memberrechargeerr' . json_encode($e->getMessage() . $e->getFile() . $e->getLine()));
- return $this->error('', $e->getMessage());
- }
- } else {
- return $this->success(true);
- }
-
- }
-
- /**
- * 定时关闭订单
- * @param $order_id
- * @return array
- */
- public function cronMemberRechargeOrderClose($order_id)
- {
- //获取订单信息
- $order_info = $this->getMemberRechargeOrderInfo([ [ 'order_id', '=', $order_id ] ], 'status')[ 'data' ];
- if (empty($order_info)) {
- $res = true;
- } else {
- if ($order_info[ 'status' ] == 1) {
- //删除订单
- $res = model('member_recharge_order')->delete([ [ 'order_id', '=', $order_id ] ]);
- Cache::tag("member_recharge_order")->clear();
- } else {
- $res = true;
- }
- }
- return $this->success($res);
- }
-
- /**
- * 获取总数
- * @param array $where
- * @param string $field
- * @param string $alias
- * @param null $join
- * @param null $group
- * @return array
- */
- public function getOrderCount($where = [], $field = '*', $alias = 'a', $join = null, $group = null)
- {
- $res = model('member_recharge_order')->getCount($where, $field, $alias, $join, $group);
- return $this->success($res);
- }
-
- /**
- * 获取总和
- * @param array $where
- * @param string $field
- * @param string $alias
- * @param null $join
- * @return array
- */
- public function getOrderSum($where = [], $field = '*', $alias = 'a', $join = null)
- {
- $res = model('member_recharge_order')->getSum($where, $field, $alias, $join);
- return $this->success($res);
- }
-
- /**
- * 小程序录入发货信息
- * @param $order_info
- * @return array
- * @throws \GuzzleHttp\Exception\GuzzleException
- */
- public function uploadShippingInfo($order_info)
- {
- $shipping_list = [
- [
- 'tracking_no' => '', // 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128]
- 'express_company' => '', // 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128]
- 'item_desc' => str_sub($order_info[ 'recharge_name' ], 100), // 商品信息,例如:微信红包抱枕*1个,限120个字以内
- 'contact' => [
- 'consignor_contact' => '',
- 'receiver_contact' => ''
- ]
- ]
- ];
-
- $data = [
- 'site_id' => $order_info[ 'site_id' ],
- 'out_trade_no' => $order_info[ 'out_trade_no' ],
- 'logistics_type' => 3, // 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式
- 'delivery_mode' => 1, // 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)
- 'shipping_list' => $shipping_list,
- 'weapp_openid' => $order_info[ 'member_info' ][ 'weapp_openid' ], // 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128]
- 'is_all_delivered' => false
- ];
-
- $weapp_model = new Weapp($order_info[ 'site_id' ]);
- $res = $weapp_model->orderShippingUploadShippingInfoByData($data);
- return $res;
-
- }
-
+pay_type;
+ //获取当前所有在线支付方式
+ $onlinepay = event('PayType');
+ if (!empty($onlinepay)) {
+ foreach ($onlinepay as $k => $v) {
+ $pay_type[ $v[ 'pay_type' ] ] = $v[ 'pay_type_name' ];
+ }
+ }
+ $trade_pay_type_list = event('TradePayType', []);
+ if (!empty($trade_pay_type_list)) {
+ foreach ($trade_pay_type_list as $k => $v) {
+ if (!empty($v)) {
+ $pay_type = array_merge($pay_type, $v);
+ }
+ }
+ }
+ return $pay_type;
+ }
+
+ /**
+ * 订单详情
+ * @param array $condition
+ * @param string $field
+ * @param string $alias
+ * @param array $join
+ * @return array
+ */
+ public function getMemberRechargeOrderInfo($condition = [], $field = '*', $alias = 'a', $join = [])
+ {
+ $order = model('member_recharge_order')->getInfo($condition, $field, $alias, $join);
+ if ($order) {
+ //获取优惠券信息
+ $coupon_id = $order[ 'coupon_id' ] ?? 0;
+ if ($coupon_id > 0) {
+ //优惠券字段
+ $coupon_field = 'coupon_type_id,coupon_name,money,count,lead_count,max_fetch,at_least,end_time,image,validity_type,fixed_term,type';
+
+ $model = new CouponType();
+ $coupon = $model->getCouponTypeList([ [ 'coupon_type_id', 'in', $order[ 'coupon_id' ] ] ], $coupon_field);
+ $order[ 'coupon_list' ] = $coupon;
+ }
+
+ }
+
+ return $this->success($order);
+ }
+
+ /**
+ * 订单列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @param string $alias
+ * @param array $join
+ * @return array
+ */
+ public function getMemberRechargeOrderPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = 'a', $join = [])
+ {
+ $list = model('member_recharge_order')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
+ if (!empty($list[ 'list' ])) {
+ $coupon_ids = '';
+ foreach ($list[ 'list' ] as $k => $v) {
+ if (!empty($v[ 'coupon_id' ])) {
+ $coupon_ids = empty($coupon_ids) ? $v[ 'coupon_id' ] : $coupon_ids . ',' . $v[ 'coupon_id' ];
+ }
+ }
+ $coupon_list = [];
+ if (!empty($coupon_ids)) {
+ $coupon_list = model('promotion_coupon_type')->getList([ [ 'coupon_type_id', 'in', $coupon_ids ] ], 'coupon_type_id,coupon_name');
+
+ }
+ if (!empty($coupon_list)) {
+ $key = array_column($coupon_list, 'coupon_type_id');
+ $coupon_list = array_combine($key, $coupon_list);
+ }
+
+ foreach ($list[ 'list' ] as $k => $v) {
+ $list[ 'list' ][ $k ][ 'coupon_name' ] = '';
+ $coupon_name = '';
+ if (!empty($v[ 'coupon_id' ])) {
+ $coupon_array = explode(',', $v[ 'coupon_id' ]);
+ foreach ($coupon_array as $value) {
+ $coupon_name_value = $coupon_list[ $value ][ 'name' ] ?? '';
+ $coupon_name .= ',' . $coupon_name_value;
+ }
+ $coupon_name = ltrim($coupon_name, ',');
+ }
+ $list[ 'list' ][ $k ][ 'coupon_name' ] = $coupon_name;
+ }
+ }
+ return $this->success($list);
+ }
+
+ /**
+ * 支付回调
+ * @param $data
+ * @return array|\multitype
+ */
+ public function orderPay($data)
+ {
+ $order_field = 'order_id,recharge_id,recharge_name,order_no,cover_img,face_value,buy_price,point,growth,coupon_id,price,pay_type,status,create_time,pay_time,member_id,member_img,nickname,site_id,out_trade_no,order_from';
+ $order_info = $this->getMemberRechargeOrderInfo([ [ 'out_trade_no', '=', $data[ 'out_trade_no' ] ] ], $order_field)[ 'data' ];
+ if ($order_info[ 'status' ] == 1) {
+ model('member_recharge_order')->startTrans();
+ try {
+
+ $pay_list = $this->getPayType();
+ $pay_type_name = '';
+ if (!empty($data[ 'pay_type' ])) {
+ $pay_type_name = $pay_list[ $data[ 'pay_type' ] ];
+ }
+
+ //修改订单状态
+ $order_data = [
+ 'pay_type' => $data[ 'pay_type' ],
+ 'pay_type_name' => $pay_type_name,
+ 'pay_time' => time(),
+ 'price' => $order_info[ 'buy_price' ],
+ 'status' => 2
+ ];
+ $res = model('member_recharge_order')->update($order_data, [ [ 'out_trade_no', '=', $data[ 'out_trade_no' ] ] ]);
+
+ //添加开卡记录
+ $card_model = new MemberRechargeCard();
+ $order_info[ 'use_status' ] = 2;
+ $order_info[ 'use_time' ] = time();
+ $card_model->addMemberRechargeCard($order_info);
+
+ //发放礼包
+ $card_model->addMemberAccount($order_info);
+
+ //获取套餐信息
+ $recharge_model = new Memberrecharge();
+ $recharge_info = $recharge_model->getMemberRechargeInfo([ [ 'recharge_id', '=', $order_info[ 'recharge_id' ] ] ], 'sale_num,coupon_id');
+ //增加发放数
+ if (!empty($recharge_info[ 'data' ])) {
+ $sale_num = $recharge_info[ 'data' ][ 'sale_num' ] + 1;
+ $recharge_model->editMemberRecharge([ [ 'recharge_id', '=', $order_info[ 'recharge_id' ] ] ], [ 'sale_num' => $sale_num ]);
+ }
+ $is_stat = $data[ 'is_stat' ] ?? true;
+ if ($is_stat) {
+ event('MemberRechargeOrderPay', [ 'order_id' => $order_info[ 'order_id' ], 'order_from' => $order_info[ 'order_from' ] ]);
+ $stat_model = new Stat();
+ $stat_res = $stat_model->switchStat([
+ 'type' => 'recharge',
+ 'data' => [
+ 'order_id' => $order_info[ 'order_id' ],
+ 'site_id' => $order_info[ 'site_id' ]
+ ]
+ ]);
+ }
+
+ // 小程序录入发货信息
+ $member_service = new Member();
+ $order_info[ 'member_info' ] = $member_service->getMemberInfo([
+ [ 'site_id', '=', $order_info[ 'site_id' ] ],
+ [ 'member_id', '=', $order_info[ 'member_id' ] ]
+ ], 'weapp_openid')[ 'data' ];
+
+ $this->uploadShippingInfo($order_info);
+
+ model('member_recharge_order')->commit();
+ return $this->success($res);
+ } catch (\Exception $e) {
+ model('member_recharge_order')->rollback();
+ Log::write('memberrechargeerr' . json_encode($e->getMessage() . $e->getFile() . $e->getLine()));
+ return $this->error('', $e->getMessage());
+ }
+ } else {
+ return $this->success(true);
+ }
+
+ }
+
+ /**
+ * 定时关闭订单
+ * @param $order_id
+ * @return array
+ */
+ public function cronMemberRechargeOrderClose($order_id)
+ {
+ //获取订单信息
+ $order_info = $this->getMemberRechargeOrderInfo([ [ 'order_id', '=', $order_id ] ], 'status')[ 'data' ];
+ if (empty($order_info)) {
+ $res = true;
+ } else {
+ if ($order_info[ 'status' ] == 1) {
+ //删除订单
+ $res = model('member_recharge_order')->delete([ [ 'order_id', '=', $order_id ] ]);
+ Cache::tag("member_recharge_order")->clear();
+ } else {
+ $res = true;
+ }
+ }
+ return $this->success($res);
+ }
+
+ /**
+ * 获取总数
+ * @param array $where
+ * @param string $field
+ * @param string $alias
+ * @param null $join
+ * @param null $group
+ * @return array
+ */
+ public function getOrderCount($where = [], $field = '*', $alias = 'a', $join = null, $group = null)
+ {
+ $res = model('member_recharge_order')->getCount($where, $field, $alias, $join, $group);
+ return $this->success($res);
+ }
+
+ /**
+ * 获取总和
+ * @param array $where
+ * @param string $field
+ * @param string $alias
+ * @param null $join
+ * @return array
+ */
+ public function getOrderSum($where = [], $field = '*', $alias = 'a', $join = null)
+ {
+ $res = model('member_recharge_order')->getSum($where, $field, $alias, $join);
+ return $this->success($res);
+ }
+
+ /**
+ * 小程序录入发货信息
+ * @param $order_info
+ * @return array
+ * @throws \GuzzleHttp\Exception\GuzzleException
+ */
+ public function uploadShippingInfo($order_info)
+ {
+ $shipping_list = [
+ [
+ 'tracking_no' => '', // 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128]
+ 'express_company' => '', // 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128]
+ 'item_desc' => str_sub($order_info[ 'recharge_name' ], 100), // 商品信息,例如:微信红包抱枕*1个,限120个字以内
+ 'contact' => [
+ 'consignor_contact' => '',
+ 'receiver_contact' => ''
+ ]
+ ]
+ ];
+
+ $data = [
+ 'site_id' => $order_info[ 'site_id' ],
+ 'out_trade_no' => $order_info[ 'out_trade_no' ],
+ 'logistics_type' => 3, // 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式
+ 'delivery_mode' => 1, // 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)
+ 'shipping_list' => $shipping_list,
+ 'weapp_openid' => $order_info[ 'member_info' ][ 'weapp_openid' ], // 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128]
+ 'is_all_delivered' => false
+ ];
+
+ $weapp_model = new Weapp($order_info[ 'site_id' ]);
+ $res = $weapp_model->orderShippingUploadShippingInfoByData($data);
+ return $res;
+
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/model/MemberrechargeOrderCreate.php b/src/addon/memberrecharge/model/MemberrechargeOrderCreate.php
index ac36e2150..76d5cfcf6 100644
--- a/src/addon/memberrecharge/model/MemberrechargeOrderCreate.php
+++ b/src/addon/memberrecharge/model/MemberrechargeOrderCreate.php
@@ -1,125 +1,117 @@
-getMemberInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'headimg,nickname');
- $member_info = $member[ 'data' ];
- //获取套餐信息
- $recharge_model = new Memberrecharge();
-
- if ($data[ 'recharge_id' ] > 0) {
- //套餐字段
- $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id';
- $recharge_info = $recharge_model->getMemberRechargeInfo([ [ 'recharge_id', '=', $data[ 'recharge_id' ] ] ], $field)['data'];
- if (empty($recharge_info)) {
- return $this->error('', '无效的充值套餐');
- }
- } else {
- $recharge_info = array (
- "recharge_id" => 0,
- "recharge_name" => '自定义面额充值',
- "cover_img" => '',
- "face_value" => $data[ 'face_value' ],
- "buy_price" => $data[ 'face_value' ],
- "point" => 0,
- "growth" => 0,
- "coupon_id" => 0,
- );
- }
-
- //创建或加入
- $pay = new Pay();
- $out_trade_no = $pay->createOutTradeNo($data[ 'member_id' ]);
- $order_no = (new OrderCreate())->createOrderNo();
-
- $order_data = [
- 'recharge_id' => $data[ 'recharge_id' ],
- 'order_no' => $order_no,
- 'out_trade_no' => $out_trade_no,
- 'recharge_name' => $recharge_info[ 'recharge_name' ],
- 'cover_img' => $recharge_info[ 'cover_img' ],
- 'face_value' => $recharge_info[ 'face_value' ],
- 'buy_price' => $recharge_info[ 'buy_price' ],
- 'pay_money' => $recharge_info[ 'buy_price' ],
- 'point' => $recharge_info[ 'point' ],
- 'growth' => $recharge_info[ 'growth' ],
- 'coupon_id' => $recharge_info[ 'coupon_id' ],
- 'status' => 1,
- 'create_time' => time(),
- 'member_id' => $data[ 'member_id' ],
- 'member_img' => $member_info[ 'headimg' ],
- 'nickname' => $member_info[ 'nickname' ],
- 'order_from' => $data[ 'order_from' ],
- 'order_from_name' => $data[ 'order_from_name' ],
- 'site_id' => $data[ 'site_id' ],
- 'store_id' => $data[ 'store_id' ] ?? 0,
- 'remark' => $data[ 'remark' ] ?? '',
- 'relate_id' => $data[ 'relate_id' ] ?? 0,
- 'relate_type' => $data[ 'relate_type' ] ?? '',
- ];
-
- model("member_recharge_order")->startTrans();
- //循环生成多个订单
- try {
-
- $order_id = model("member_recharge_order")->add($order_data);
- //生成整体支付单据
- $pay->addPay($data[ 'site_id' ], $out_trade_no, "", "会员充值套餐,面额:" . $recharge_info[ 'face_value' ], "会员充值套餐,面额:" . $recharge_info[ 'face_value' ], $recharge_info[ 'buy_price' ], '', 'MemberrechargeOrderPayNotify', '');
-
- //计算订单自动关闭时间
- $config_model = new Config();
- $order_config = $config_model->getOrderEventTimeConfig($data[ 'site_id' ])[ "data" ];
- $now_time = time();
- if (!empty($order_config)) {
- $execute_time = $now_time + $order_config[ "value" ][ "auto_close" ] * 60;//自动关闭时间
- } else {
- $execute_time = $now_time + 3600;//尚未配置 默认一天
- }
- $cron_model = new Cron();
- $cron_model->addCron(1, 0, "订单自动关闭", "MemberrechargeOrderClose", $execute_time, $order_id);
-
- event("MemberRechargeOrderCreate", [ 'order_id' => $order_id ]);
- model("member_recharge_order")->commit();
- return $this->success($out_trade_no);
-
- } catch (\Exception $e) {
- model("member_recharge_order")->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
+getMemberInfo([ [ 'member_id', '=', $data[ 'member_id' ] ] ], 'headimg,nickname');
+ $member_info = $member[ 'data' ];
+ //获取套餐信息
+ $recharge_model = new Memberrecharge();
+
+ if ($data[ 'recharge_id' ] > 0) {
+ //套餐字段
+ $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id';
+ $recharge_info = $recharge_model->getMemberRechargeInfo([ [ 'recharge_id', '=', $data[ 'recharge_id' ] ] ], $field)['data'];
+ if (empty($recharge_info)) {
+ return $this->error('', '无效的充值套餐');
+ }
+ } else {
+ $recharge_info = array (
+ "recharge_id" => 0,
+ "recharge_name" => '自定义面额充值',
+ "cover_img" => '',
+ "face_value" => $data[ 'face_value' ],
+ "buy_price" => $data[ 'face_value' ],
+ "point" => 0,
+ "growth" => 0,
+ "coupon_id" => 0,
+ );
+ }
+
+ //创建或加入
+ $pay = new Pay();
+ $out_trade_no = $pay->createOutTradeNo($data[ 'member_id' ]);
+ $order_no = (new OrderCreate())->createOrderNo();
+
+ $order_data = [
+ 'recharge_id' => $data[ 'recharge_id' ],
+ 'order_no' => $order_no,
+ 'out_trade_no' => $out_trade_no,
+ 'recharge_name' => $recharge_info[ 'recharge_name' ],
+ 'cover_img' => $recharge_info[ 'cover_img' ],
+ 'face_value' => $recharge_info[ 'face_value' ],
+ 'buy_price' => $recharge_info[ 'buy_price' ],
+ 'pay_money' => $recharge_info[ 'buy_price' ],
+ 'point' => $recharge_info[ 'point' ],
+ 'growth' => $recharge_info[ 'growth' ],
+ 'coupon_id' => $recharge_info[ 'coupon_id' ],
+ 'status' => 1,
+ 'create_time' => time(),
+ 'member_id' => $data[ 'member_id' ],
+ 'member_img' => $member_info[ 'headimg' ],
+ 'nickname' => $member_info[ 'nickname' ],
+ 'order_from' => $data[ 'order_from' ],
+ 'order_from_name' => $data[ 'order_from_name' ],
+ 'site_id' => $data[ 'site_id' ],
+ 'store_id' => $data[ 'store_id' ] ?? 0,
+ 'remark' => $data[ 'remark' ] ?? '',
+ 'relate_id' => $data[ 'relate_id' ] ?? 0,
+ 'relate_type' => $data[ 'relate_type' ] ?? '',
+ ];
+
+ model("member_recharge_order")->startTrans();
+ //循环生成多个订单
+ try {
+
+ $order_id = model("member_recharge_order")->add($order_data);
+ //生成整体支付单据
+ $pay->addPay($data[ 'site_id' ], $out_trade_no, "", "会员充值套餐,面额:" . $recharge_info[ 'face_value' ], "会员充值套餐,面额:" . $recharge_info[ 'face_value' ], $recharge_info[ 'buy_price' ], '', 'MemberrechargeOrderPayNotify', '');
+
+ //计算订单自动关闭时间
+ $config_model = new Config();
+ $order_config = $config_model->getOrderEventTimeConfig($data[ 'site_id' ])[ "data" ];
+ $now_time = time();
+ if (!empty($order_config)) {
+ $execute_time = $now_time + $order_config[ "value" ][ "auto_close" ] * 60;//自动关闭时间
+ } else {
+ $execute_time = $now_time + 3600;//尚未配置 默认一天
+ }
+ $cron_model = new Cron();
+ $cron_model->addCron(1, 0, "订单自动关闭", "MemberrechargeOrderClose", $execute_time, $order_id);
+
+ event("MemberRechargeOrderCreate", [ 'order_id' => $order_id ]);
+ model("member_recharge_order")->commit();
+ return $this->success($out_trade_no);
+
+ } catch (\Exception $e) {
+ model("member_recharge_order")->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberrecharge/shop/controller/Memberrecharge.php b/src/addon/memberrecharge/shop/controller/Memberrecharge.php
index 82ffd31a1..23397271a 100644
--- a/src/addon/memberrecharge/shop/controller/Memberrecharge.php
+++ b/src/addon/memberrecharge/shop/controller/Memberrecharge.php
@@ -1,497 +1,489 @@
-replace = [
- 'MEMBERRECHARGE_CSS' => __ROOT__ . '/addon/memberrecharge/shop/view/public/css',
- 'MEMBERRECHARGE_JS' => __ROOT__ . '/addon/memberrecharge/shop/view/public/js',
- 'MEMBERRECHARGE_IMG' => __ROOT__ . '/addon/memberrecharge/shop/view/public/img',
- ];
- parent::__construct($app);
- }
-
- //套餐字段
- protected $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id,sale_num,create_time,status';
-
- //开卡字段
- protected $card_field = 'card_id,recharge_id,card_account,cover_img,face_value,point,growth,coupon_id,buy_price,member_img,nickname,order_id,order_no,from_type,use_status,create_time,use_time';
-
- //订单字段
- protected $order_field = 'a.order_id,a.recharge_name,a.recharge_id,a.order_no,a.out_trade_no,a.member_id,a.cover_img,a.face_value,a.buy_price,a.point,a.growth,a.coupon_id,a.price,a.pay_type,a.pay_type_name,a.status,a.create_time,a.pay_time,a.member_img,a.nickname,a.order_from_name,a.order_from,IFNULL(s.store_name,"") as store_name';
-
- //优惠券字段
- protected $coupon_field = 'coupon_type_id,coupon_name,money,count,lead_count,max_fetch,at_least,end_time,image,validity_type,fixed_term';
-
- /**
- * 充值会员套餐列表
- * @return array|mixed
- */
- public function lists()
- {
- $model = new MemberRechargeModel();
- //获取续签信息
- if (request()->isJson()) {
- $status = input('status', '');//套餐状态
- $condition = [];
- if ($status) {
- $condition[] = [ 'status', '=', $status ];
- }
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $list = $model->getMemberRechargePageList($condition, $page, $page_size, 'recharge_id desc', $this->field);
- return $list;
- } else {
- $config = $model->getConfig($this->site_id);
- $config = $config[ 'data' ];
- $this->assign("config", $config);
- return $this->fetch('memberrecharge/lists');
- }
-
- }
-
- /**
- * 添加充值套餐
- * @return array|mixed
- */
- public function add()
- {
- if (request()->isJson()) {
-
- $data = [
- 'site_id' => $this->site_id,
- 'recharge_name' => input('recharge_name', ''),//套餐名称
- 'cover_img' => input('cover_img', ''),//封面
- 'face_value' => input('face_value', ''),//面值
- 'buy_price' => input('buy_price', ''),//价格
- 'point' => input('point', ''),//赠送积分
- 'growth' => input('growth', ''),//赠送成长值
- 'coupon_id' => input('coupon_id', '')//优惠券id
- ];
-
- $model = new MemberRechargeModel();
- return $model->addMemberRecharge($data);
-
- } else {
- return $this->fetch('memberrecharge/add');
- }
- }
-
- /**
- * 编辑充值套餐
- * @return array|mixed
- */
- public function edit()
- {
- $rechargeModel = new MemberRechargeModel();
-
- $recharge_id = input('recharge_id', '');
- if (request()->isJson()) {
-
- $data = [
- 'recharge_name' => input('recharge_name', ''),//套餐名称
- 'cover_img' => input('cover_img', ''),//封面
- 'face_value' => input('face_value', ''),//面值
- 'buy_price' => input('buy_price', ''),//价格
- 'point' => input('point', ''),//赠送积分
- 'growth' => input('growth', ''),//赠送成长值
- 'coupon_id' => input('coupon_id', '')//优惠券id
- ];
-
- return $rechargeModel->editMemberRecharge(
- [
- [ 'recharge_id', '=', $recharge_id ],
- [ 'site_id', '=', $this->site_id ]
- ], $data);
-
- } else {
- //获取套餐详情
- $recharge = $rechargeModel->getMemberRechargeInfo(
- [
- [ 'recharge_id', '=', $recharge_id ],
- [ 'site_id', '=', $this->site_id ]
- ],
- $this->field
- );
- if (empty($recharge[ 'data' ])) $this->error('未获取到套餐数据', href_url('memberrecharge://shop/memberrecharge/lists'));
- $this->assign('recharge', $recharge);
- return $this->fetch('memberrecharge/edit');
- }
-
- }
-
- /**
- * 充值套餐详情
- * @return mixed
- */
- public function detail()
- {
- $recharge_model = new MemberRechargeModel();
-
- $recharge_id = input('recharge_id', '');
-
- //获取套餐详情
- $info = $recharge_model->getMemberRechargeInfo(
- [
- [ 'recharge_id', '=', $recharge_id ],
- [ 'site_id', '=', $this->site_id ]
- ],
- $this->field
- )[ 'data' ] ?? [];
- if (empty($info)) $this->error('未获取到套餐数据', href_url('memberrecharge://shop/memberrecharge/lists'));
- $this->assign('info', $info);
-
- return $this->fetch('memberrecharge/detail');
- }
-
- /**
- * 停用充值套餐
- * @return array
- */
- public function invalid()
- {
- $model = new MemberRechargeModel();
-
- $recharge_id = input('recharge_id', '');
-
- $data = [ 'status' => 2 ];
- $condition = [ [ 'recharge_id', '=', $recharge_id ] ];
-
- $res = $model->editMemberRecharge($condition, $data);
- return $res;
- }
-
- /**
- * 开启充值套餐
- * @return array
- */
- public function open()
- {
- $model = new MemberRechargeModel();
-
- $recharge_id = input('recharge_id', '');
-
- $data = [ 'status' => 1 ];
- $condition = [ [ 'recharge_id', '=', $recharge_id ] ];
-
- $res = $model->editMemberRecharge($condition, $data);
- return $res;
- }
-
- /**
- * 删除充值套餐
- * @return mixed
- */
- public function delete()
- {
- $model = new MemberRechargeModel();
-
- $recharge_id = input('recharge_id', '');
-
- return $model->deleteMemberRecharge([ [ 'recharge_id', '=', $recharge_id ] ]);
- }
-
- /**
- * 开卡列表
- * @return array|mixed
- */
- public function cardLists()
- {
- $recharge_id = input('recharge_id', '');
- $page_size = input('page_size', PAGE_LIST_ROWS);
-
- $model = new MemberRechargeCardModel();
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $condition[] = [ 'recharge_id', '=', $recharge_id ];
- //获取续签信息
- if (request()->isJson()) {
- $status = input('use_status', '');//使用状态
- if ($status) {
- $condition[] = [ 'use_status', '=', $status ];
- }
-
- $page = input('page', 1);
- $list = $model->getMemberRechargeCardPageList($condition, $page, $page_size, 'card_id desc', $this->card_field);
- return $list;
- } else {
-
- $page_size = input('page_size', PAGE_LIST_ROWS);
-
- $list = $model->getMemberRechargeCardPageList($condition, 1, $page_size, 'card_id desc', $this->card_field);
- $this->assign('list', $list);
-
- $this->assign('recharge_id', $recharge_id);
- return $this->fetch('memberrecharge/card_lists');
- }
-
- }
-
- /**
- * 开卡详情
- * @return mixed
- */
- public function cardDetail()
- {
- $model = new MemberRechargeCardModel();
-
- $card_id = input('card_id', '');
-
- //获取详情
- $info = $model->getMemberRechargeCardInfo(
- [ [ 'card_id', '=', $card_id ] ],
- $this->card_field
- )[ 'data' ] ?? [];
- $this->assign('info', $info);
-
- return $this->fetch('memberrecharge/card_detail');
- }
-
- /**
- * 订单列表
- * @return array|mixed
- */
- public function orderLists()
- {
- $recharge_id = input('recharge_id', 0);
- $model = new MemberRechargeOrderModel();
- //获取续签信息
- if (request()->isJson()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $nickname = input('nickname', '');
- $start_time = input('start_time', '');
- $end_time = input('end_time', '');
- $order_no = input('order_no', '');
- $store_id = input('store_id', '');
-
- $condition = [
- // [ 'a.status', '=', 2 ],
- [ 'a.site_id', '=', $this->site_id ]
- ];
-
- if ($recharge_id > 0) {
- $condition[] = [ 'recharge_id', '=', $recharge_id ];
- }
-
- if ($nickname) {
- $condition[] = [ 'a.nickname', 'like', '%' . $nickname . '%' ];
- }
- if ($order_no) {
- $condition[] = [ 'a.order_no', '=', $order_no ];
- }
- if ($store_id != '') {
- $condition[] = [ 'a.store_id', '=', $store_id ];
- }
- //支付时间
- if (!empty($start_time) && empty($end_time)) {
- $condition[] = [ "a.pay_time", ">=", date_to_time($start_time) ];
- } elseif (empty($start_time) && !empty($end_time)) {
- $condition[] = [ "a.pay_time", "<=", date_to_time($end_time) ];
- } elseif (!empty($start_time) && !empty($end_time)) {
- $condition[] = [ 'a.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
- }
- $alias = 'a';
- $join[] = [
- 'store s',
- 's.store_id = a.store_id',
- 'left'
- ];
- $order = 'a.create_time desc';
- $list = $model->getMemberRechargeOrderPageList($condition, $page, $page_size, $order, $this->order_field, $alias, $join);
- return $list;
- } else {
- $this->assign('recharge_id', $recharge_id);
-
- $order_num = $model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 2 ] ], 'order_id')[ 'data' ];
- $this->assign('order_num', $order_num);
-
- $order_money = $model->getOrderSum([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 2 ] ], 'price')[ 'data' ];
- $this->assign('order_money', $order_money);
-
- if (addon_is_exit('store') == 1) {
- $store_model = new StoreModel();
- $store_list = $store_model->getStoreList([
- [ 'site_id', '=', $this->site_id ]
- ], 'store_id,store_name')[ 'data' ];
- $this->assign('store_list', $store_list);
- }
-
- $this->assign('printer_addon_is_exit',addon_is_exit('printer'));
-
- return $this->fetch('memberrecharge/order_lists');
- }
- }
-
- /**
- * 订单详情
- * @return mixed
- */
- public function orderDetail()
- {
- $order_id = input('order_id', '');
-
- $condition = [
- [ 'a.order_id', '=', $order_id ],
- [ 'a.site_id', '=', $this->site_id ]
- ];
-
- $alias = 'a';
- $join[] = [
- 'store s',
- 's.store_id = a.store_id',
- 'left'
- ];
-
- $model = new MemberRechargeOrderModel();
- $info = $model->getMemberRechargeOrderInfo($condition, $this->order_field, $alias, $join)[ 'data' ] ?? [];
- if (empty($info)) $this->error('未获取到订单数据', href_url('memberrecharge://shop/memberrecharge/order_lists'));
- $this->assign('info', $info);
-
- return $this->fetch('memberrecharge/order_detail');
- }
-
- /**
- * 是否开启充值
- * @return mixed
- */
- public function setConfig()
- {
- $model = new MemberRechargeModel();
- $is_use = input('is_use', 0);
- $data = [];
- return $model->setConfig($data, $is_use, $this->site_id);
- }
-
- public function exportRecharge()
- {
- $recharge_id = input("recharge_id", "");//订单状态
-
- $condition[] = [ "recharge_id", "=", $recharge_id ];
- $model = new MemberRechargeCardModel();
-
- $list = $model->getMemberRechargeCardPageList($condition, 1, 0, 'card_id desc', "*");
- if (empty($list[ 'data' ][ 'list' ])) {
- return $this->error("未查询到数据");
- }
-
- // 实例化excel
- $phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
-
- $phpExcel->getProperties()->setTitle("充值记录");
- $phpExcel->getProperties()->setSubject("充值记录");
- // 对单元格设置居中效果
- $phpExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('E')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('G')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('H')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('I')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('J')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('K')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('L')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
- //单独添加列名称
- $phpExcel->setActiveSheetIndex(0);
- $phpExcel->getActiveSheet()->setCellValue('A1', '店铺名称');//可以指定位置
- $phpExcel->getActiveSheet()->setCellValue('B1', '充值卡号');
- $phpExcel->getActiveSheet()->setCellValue('C1', '套餐名称');
- $phpExcel->getActiveSheet()->setCellValue('D1', '面值');
- $phpExcel->getActiveSheet()->setCellValue('E1', '积分');
- $phpExcel->getActiveSheet()->setCellValue('F1', '成长值');
- $phpExcel->getActiveSheet()->setCellValue('G1', '购买金额');
- $phpExcel->getActiveSheet()->setCellValue('H1', '会员昵称');
- $phpExcel->getActiveSheet()->setCellValue('I1', '订单编号');
- $phpExcel->getActiveSheet()->setCellValue('J1', '使用状态');
- $phpExcel->getActiveSheet()->setCellValue('K1', '创建时间');
- $phpExcel->getActiveSheet()->setCellValue('L1', '使用时间');
- //循环添加数据(根据自己的逻辑)
- foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
- $i = $k + 2;
- if ($v[ 'use_status' ] == 1) {
- $status_name = "未使用";
- } else {
- $status_name = "已使用";
- }
-
- $phpExcel->getActiveSheet()->setCellValue('A' . $i, $v[ 'site_name' ]);
- $phpExcel->getActiveSheet()->setCellValue('B' . $i, $v[ 'card_account' ]);
- $phpExcel->getActiveSheet()->setCellValue('C' . $i, $v[ 'recharge_name' ]);
- $phpExcel->getActiveSheet()->setCellValue('D' . $i, $v[ 'face_value' ]);
- $phpExcel->getActiveSheet()->setCellValue('E' . $i, $v[ 'point' ]);
- $phpExcel->getActiveSheet()->setCellValue('F' . $i, $v[ 'growth' ]);
- $phpExcel->getActiveSheet()->setCellValue('G' . $i, $v[ 'buy_price' ]);
- $phpExcel->getActiveSheet()->setCellValue('H' . $i, $v[ 'nickname' ]);
- $phpExcel->getActiveSheet()->setCellValue('I' . $i, ' ' . (string) $v[ 'order_no' ]);
- $phpExcel->getActiveSheet()->setCellValue('J' . $i, $status_name);
- $phpExcel->getActiveSheet()->setCellValue('K' . $i, date('Y-m-d', $v[ 'create_time' ]));
- $phpExcel->getActiveSheet()->setCellValue('L' . $i, date('Y-m-d', $v[ 'use_time' ]));
- }
-
- // 重命名工作sheet
- $phpExcel->getActiveSheet()->setTitle('充值记录');
- // 设置第一个sheet为工作的sheet
- $phpExcel->setActiveSheetIndex(0);
- // 保存Excel 2007格式文件,保存路径为当前路径,名字为export.xlsx
- $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
- $file = date('Y年m月d日-充值记录表', time()) . '.xlsx';
- $objWriter->save($file);
-
- header("Content-type:application/octet-stream");
-
- $filename = basename($file);
- header("Content-Disposition:attachment;filename = " . $filename);
- header("Accept-ranges:bytes");
- header("Accept-length:" . filesize($file));
- readfile($file);
- unlink($file);
- exit;
- }
-
- /**
- * 打印订单小票
- * @return array|mixed|void
- */
- public function printTicket()
- {
- if (addon_is_exit('printer') == 0) return error('', '未安装打印小票插件');
-
- if (request()->isJson()) {
- $order_id = input('order_id', 0);
- $printer_order_model = new PrinterOrder();
- $recharge_order = ( new MemberrechargeOrder() )->getMemberRechargeOrderInfo([ [ 'relate_type', '=', 'order' ], [ 'order_id', '=', $order_id ] ], 'order_id')[ 'data' ];
- if (empty($recharge_order)) return error('', '未获取到充值订单信息');
- $res = $printer_order_model->printer([
- 'order_id' => $recharge_order[ 'order_id' ],
- 'type' => 'recharge',
- ]);
- return $res;
- }
- }
-
+replace = [
+ 'MEMBERRECHARGE_CSS' => __ROOT__ . '/addon/memberrecharge/shop/view/public/css',
+ 'MEMBERRECHARGE_JS' => __ROOT__ . '/addon/memberrecharge/shop/view/public/js',
+ 'MEMBERRECHARGE_IMG' => __ROOT__ . '/addon/memberrecharge/shop/view/public/img',
+ ];
+ parent::__construct($app);
+ }
+
+ //套餐字段
+ protected $field = 'recharge_id,recharge_name,cover_img,face_value,buy_price,point,growth,coupon_id,sale_num,create_time,status';
+
+ //开卡字段
+ protected $card_field = 'card_id,recharge_id,card_account,cover_img,face_value,point,growth,coupon_id,buy_price,member_img,nickname,order_id,order_no,from_type,use_status,create_time,use_time';
+
+ //订单字段
+ protected $order_field = 'a.order_id,a.recharge_name,a.recharge_id,a.order_no,a.out_trade_no,a.member_id,a.cover_img,a.face_value,a.buy_price,a.point,a.growth,a.coupon_id,a.price,a.pay_type,a.pay_type_name,a.status,a.create_time,a.pay_time,a.member_img,a.nickname,a.order_from_name,a.order_from,IFNULL(s.store_name,"") as store_name';
+
+ //优惠券字段
+ protected $coupon_field = 'coupon_type_id,coupon_name,money,count,lead_count,max_fetch,at_least,end_time,image,validity_type,fixed_term';
+
+ /**
+ * 充值会员套餐列表
+ * @return array|mixed
+ */
+ public function lists()
+ {
+ $model = new MemberRechargeModel();
+ //获取续签信息
+ if (request()->isJson()) {
+ $status = input('status', '');//套餐状态
+ $condition = [];
+ if ($status) {
+ $condition[] = [ 'status', '=', $status ];
+ }
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $list = $model->getMemberRechargePageList($condition, $page, $page_size, 'recharge_id desc', $this->field);
+ return $list;
+ } else {
+ $config = $model->getConfig($this->site_id);
+ $config = $config[ 'data' ];
+ $this->assign("config", $config);
+ return $this->fetch('memberrecharge/lists');
+ }
+
+ }
+
+ /**
+ * 添加充值套餐
+ * @return array|mixed
+ */
+ public function add()
+ {
+ if (request()->isJson()) {
+
+ $data = [
+ 'site_id' => $this->site_id,
+ 'recharge_name' => input('recharge_name', ''),//套餐名称
+ 'cover_img' => input('cover_img', ''),//封面
+ 'face_value' => input('face_value', ''),//面值
+ 'buy_price' => input('buy_price', ''),//价格
+ 'point' => input('point', ''),//赠送积分
+ 'growth' => input('growth', ''),//赠送成长值
+ 'coupon_id' => input('coupon_id', '')//优惠券id
+ ];
+
+ $model = new MemberRechargeModel();
+ return $model->addMemberRecharge($data);
+
+ } else {
+ return $this->fetch('memberrecharge/add');
+ }
+ }
+
+ /**
+ * 编辑充值套餐
+ * @return array|mixed
+ */
+ public function edit()
+ {
+ $rechargeModel = new MemberRechargeModel();
+
+ $recharge_id = input('recharge_id', '');
+ if (request()->isJson()) {
+
+ $data = [
+ 'recharge_name' => input('recharge_name', ''),//套餐名称
+ 'cover_img' => input('cover_img', ''),//封面
+ 'face_value' => input('face_value', ''),//面值
+ 'buy_price' => input('buy_price', ''),//价格
+ 'point' => input('point', ''),//赠送积分
+ 'growth' => input('growth', ''),//赠送成长值
+ 'coupon_id' => input('coupon_id', '')//优惠券id
+ ];
+
+ return $rechargeModel->editMemberRecharge(
+ [
+ [ 'recharge_id', '=', $recharge_id ],
+ [ 'site_id', '=', $this->site_id ]
+ ], $data);
+
+ } else {
+ //获取套餐详情
+ $recharge = $rechargeModel->getMemberRechargeInfo(
+ [
+ [ 'recharge_id', '=', $recharge_id ],
+ [ 'site_id', '=', $this->site_id ]
+ ],
+ $this->field
+ );
+ if (empty($recharge[ 'data' ])) $this->error('未获取到套餐数据', href_url('memberrecharge://shop/memberrecharge/lists'));
+ $this->assign('recharge', $recharge);
+ return $this->fetch('memberrecharge/edit');
+ }
+
+ }
+
+ /**
+ * 充值套餐详情
+ * @return mixed
+ */
+ public function detail()
+ {
+ $recharge_model = new MemberRechargeModel();
+
+ $recharge_id = input('recharge_id', '');
+
+ //获取套餐详情
+ $info = $recharge_model->getMemberRechargeInfo(
+ [
+ [ 'recharge_id', '=', $recharge_id ],
+ [ 'site_id', '=', $this->site_id ]
+ ],
+ $this->field
+ )[ 'data' ] ?? [];
+ if (empty($info)) $this->error('未获取到套餐数据', href_url('memberrecharge://shop/memberrecharge/lists'));
+ $this->assign('info', $info);
+
+ return $this->fetch('memberrecharge/detail');
+ }
+
+ /**
+ * 停用充值套餐
+ * @return array
+ */
+ public function invalid()
+ {
+ $model = new MemberRechargeModel();
+
+ $recharge_id = input('recharge_id', '');
+
+ $data = [ 'status' => 2 ];
+ $condition = [ [ 'recharge_id', '=', $recharge_id ] ];
+
+ $res = $model->editMemberRecharge($condition, $data);
+ return $res;
+ }
+
+ /**
+ * 开启充值套餐
+ * @return array
+ */
+ public function open()
+ {
+ $model = new MemberRechargeModel();
+
+ $recharge_id = input('recharge_id', '');
+
+ $data = [ 'status' => 1 ];
+ $condition = [ [ 'recharge_id', '=', $recharge_id ] ];
+
+ $res = $model->editMemberRecharge($condition, $data);
+ return $res;
+ }
+
+ /**
+ * 删除充值套餐
+ * @return mixed
+ */
+ public function delete()
+ {
+ $model = new MemberRechargeModel();
+
+ $recharge_id = input('recharge_id', '');
+
+ return $model->deleteMemberRecharge([ [ 'recharge_id', '=', $recharge_id ] ]);
+ }
+
+ /**
+ * 开卡列表
+ * @return array|mixed
+ */
+ public function cardLists()
+ {
+ $recharge_id = input('recharge_id', '');
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+
+ $model = new MemberRechargeCardModel();
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $condition[] = [ 'recharge_id', '=', $recharge_id ];
+ //获取续签信息
+ if (request()->isJson()) {
+ $status = input('use_status', '');//使用状态
+ if ($status) {
+ $condition[] = [ 'use_status', '=', $status ];
+ }
+
+ $page = input('page', 1);
+ $list = $model->getMemberRechargeCardPageList($condition, $page, $page_size, 'card_id desc', $this->card_field);
+ return $list;
+ } else {
+
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+
+ $list = $model->getMemberRechargeCardPageList($condition, 1, $page_size, 'card_id desc', $this->card_field);
+ $this->assign('list', $list);
+
+ $this->assign('recharge_id', $recharge_id);
+ return $this->fetch('memberrecharge/card_lists');
+ }
+
+ }
+
+ /**
+ * 开卡详情
+ * @return mixed
+ */
+ public function cardDetail()
+ {
+ $model = new MemberRechargeCardModel();
+
+ $card_id = input('card_id', '');
+
+ //获取详情
+ $info = $model->getMemberRechargeCardInfo(
+ [ [ 'card_id', '=', $card_id ] ],
+ $this->card_field
+ )[ 'data' ] ?? [];
+ $this->assign('info', $info);
+
+ return $this->fetch('memberrecharge/card_detail');
+ }
+
+ /**
+ * 订单列表
+ * @return array|mixed
+ */
+ public function orderLists()
+ {
+ $recharge_id = input('recharge_id', 0);
+ $model = new MemberRechargeOrderModel();
+ //获取续签信息
+ if (request()->isJson()) {
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $nickname = input('nickname', '');
+ $start_time = input('start_time', '');
+ $end_time = input('end_time', '');
+ $order_no = input('order_no', '');
+ $store_id = input('store_id', '');
+
+ $condition = [
+ // [ 'a.status', '=', 2 ],
+ [ 'a.site_id', '=', $this->site_id ]
+ ];
+
+ if ($recharge_id > 0) {
+ $condition[] = [ 'recharge_id', '=', $recharge_id ];
+ }
+
+ if ($nickname) {
+ $condition[] = [ 'a.nickname', 'like', '%' . $nickname . '%' ];
+ }
+ if ($order_no) {
+ $condition[] = [ 'a.order_no', '=', $order_no ];
+ }
+ if ($store_id != '') {
+ $condition[] = [ 'a.store_id', '=', $store_id ];
+ }
+ //支付时间
+ if (!empty($start_time) && empty($end_time)) {
+ $condition[] = [ "a.pay_time", ">=", date_to_time($start_time) ];
+ } elseif (empty($start_time) && !empty($end_time)) {
+ $condition[] = [ "a.pay_time", "<=", date_to_time($end_time) ];
+ } elseif (!empty($start_time) && !empty($end_time)) {
+ $condition[] = [ 'a.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
+ }
+ $alias = 'a';
+ $join[] = [
+ 'store s',
+ 's.store_id = a.store_id',
+ 'left'
+ ];
+ $order = 'a.create_time desc';
+ $list = $model->getMemberRechargeOrderPageList($condition, $page, $page_size, $order, $this->order_field, $alias, $join);
+ return $list;
+ } else {
+ $this->assign('recharge_id', $recharge_id);
+
+ $order_num = $model->getOrderCount([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 2 ] ], 'order_id')[ 'data' ];
+ $this->assign('order_num', $order_num);
+
+ $order_money = $model->getOrderSum([ [ 'site_id', '=', $this->site_id ], [ 'status', '=', 2 ] ], 'price')[ 'data' ];
+ $this->assign('order_money', $order_money);
+
+ if (addon_is_exit('store') == 1) {
+ $store_model = new StoreModel();
+ $store_list = $store_model->getStoreList([
+ [ 'site_id', '=', $this->site_id ]
+ ], 'store_id,store_name')[ 'data' ];
+ $this->assign('store_list', $store_list);
+ }
+
+ $this->assign('printer_addon_is_exit',addon_is_exit('printer'));
+
+ return $this->fetch('memberrecharge/order_lists');
+ }
+ }
+
+ /**
+ * 订单详情
+ * @return mixed
+ */
+ public function orderDetail()
+ {
+ $order_id = input('order_id', '');
+
+ $condition = [
+ [ 'a.order_id', '=', $order_id ],
+ [ 'a.site_id', '=', $this->site_id ]
+ ];
+
+ $alias = 'a';
+ $join[] = [
+ 'store s',
+ 's.store_id = a.store_id',
+ 'left'
+ ];
+
+ $model = new MemberRechargeOrderModel();
+ $info = $model->getMemberRechargeOrderInfo($condition, $this->order_field, $alias, $join)[ 'data' ] ?? [];
+ if (empty($info)) $this->error('未获取到订单数据', href_url('memberrecharge://shop/memberrecharge/order_lists'));
+ $this->assign('info', $info);
+
+ return $this->fetch('memberrecharge/order_detail');
+ }
+
+ /**
+ * 是否开启充值
+ * @return mixed
+ */
+ public function setConfig()
+ {
+ $model = new MemberRechargeModel();
+ $is_use = input('is_use', 0);
+ $data = [];
+ return $model->setConfig($data, $is_use, $this->site_id);
+ }
+
+ public function exportRecharge()
+ {
+ $recharge_id = input("recharge_id", "");//订单状态
+
+ $condition[] = [ "recharge_id", "=", $recharge_id ];
+ $model = new MemberRechargeCardModel();
+
+ $list = $model->getMemberRechargeCardPageList($condition, 1, 0, 'card_id desc', "*");
+ if (empty($list[ 'data' ][ 'list' ])) {
+ return $this->error("未查询到数据");
+ }
+
+ // 实例化excel
+ $phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
+
+ $phpExcel->getProperties()->setTitle("充值记录");
+ $phpExcel->getProperties()->setSubject("充值记录");
+ // 对单元格设置居中效果
+ $phpExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('E')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('F')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('G')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('H')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('I')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('J')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('K')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('L')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
+ //单独添加列名称
+ $phpExcel->setActiveSheetIndex(0);
+ $phpExcel->getActiveSheet()->setCellValue('A1', '店铺名称');//可以指定位置
+ $phpExcel->getActiveSheet()->setCellValue('B1', '充值卡号');
+ $phpExcel->getActiveSheet()->setCellValue('C1', '套餐名称');
+ $phpExcel->getActiveSheet()->setCellValue('D1', '面值');
+ $phpExcel->getActiveSheet()->setCellValue('E1', '积分');
+ $phpExcel->getActiveSheet()->setCellValue('F1', '成长值');
+ $phpExcel->getActiveSheet()->setCellValue('G1', '购买金额');
+ $phpExcel->getActiveSheet()->setCellValue('H1', '会员昵称');
+ $phpExcel->getActiveSheet()->setCellValue('I1', '订单编号');
+ $phpExcel->getActiveSheet()->setCellValue('J1', '使用状态');
+ $phpExcel->getActiveSheet()->setCellValue('K1', '创建时间');
+ $phpExcel->getActiveSheet()->setCellValue('L1', '使用时间');
+ //循环添加数据(根据自己的逻辑)
+ foreach ($list[ 'data' ][ 'list' ] as $k => $v) {
+ $i = $k + 2;
+ if ($v[ 'use_status' ] == 1) {
+ $status_name = "未使用";
+ } else {
+ $status_name = "已使用";
+ }
+
+ $phpExcel->getActiveSheet()->setCellValue('A' . $i, $v[ 'site_name' ]);
+ $phpExcel->getActiveSheet()->setCellValue('B' . $i, $v[ 'card_account' ]);
+ $phpExcel->getActiveSheet()->setCellValue('C' . $i, $v[ 'recharge_name' ]);
+ $phpExcel->getActiveSheet()->setCellValue('D' . $i, $v[ 'face_value' ]);
+ $phpExcel->getActiveSheet()->setCellValue('E' . $i, $v[ 'point' ]);
+ $phpExcel->getActiveSheet()->setCellValue('F' . $i, $v[ 'growth' ]);
+ $phpExcel->getActiveSheet()->setCellValue('G' . $i, $v[ 'buy_price' ]);
+ $phpExcel->getActiveSheet()->setCellValue('H' . $i, $v[ 'nickname' ]);
+ $phpExcel->getActiveSheet()->setCellValue('I' . $i, ' ' . (string) $v[ 'order_no' ]);
+ $phpExcel->getActiveSheet()->setCellValue('J' . $i, $status_name);
+ $phpExcel->getActiveSheet()->setCellValue('K' . $i, date('Y-m-d', $v[ 'create_time' ]));
+ $phpExcel->getActiveSheet()->setCellValue('L' . $i, date('Y-m-d', $v[ 'use_time' ]));
+ }
+
+ // 重命名工作sheet
+ $phpExcel->getActiveSheet()->setTitle('充值记录');
+ // 设置第一个sheet为工作的sheet
+ $phpExcel->setActiveSheetIndex(0);
+ // 保存Excel 2007格式文件,保存路径为当前路径,名字为export.xlsx
+ $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
+ $file = date('Y年m月d日-充值记录表', time()) . '.xlsx';
+ $objWriter->save($file);
+
+ header("Content-type:application/octet-stream");
+
+ $filename = basename($file);
+ header("Content-Disposition:attachment;filename = " . $filename);
+ header("Accept-ranges:bytes");
+ header("Accept-length:" . filesize($file));
+ readfile($file);
+ unlink($file);
+ exit;
+ }
+
+ /**
+ * 打印订单小票
+ * @return array|mixed|void
+ */
+ public function printTicket()
+ {
+ if (addon_is_exit('printer') == 0) return error('', '未安装打印小票插件');
+
+ if (request()->isJson()) {
+ $order_id = input('order_id', 0);
+ $printer_order_model = new PrinterOrder();
+ $recharge_order = ( new MemberrechargeOrder() )->getMemberRechargeOrderInfo([ [ 'relate_type', '=', 'order' ], [ 'order_id', '=', $order_id ] ], 'order_id')[ 'data' ];
+ if (empty($recharge_order)) return error('', '未获取到充值订单信息');
+ $res = $printer_order_model->printer([
+ 'order_id' => $recharge_order[ 'order_id' ],
+ 'type' => 'recharge',
+ ]);
+ return $res;
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/memberwithdraw/config/diy_view.php b/src/addon/memberwithdraw/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/memberwithdraw/config/diy_view.php
+++ b/src/addon/memberwithdraw/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/memberwithdraw/config/info.php b/src/addon/memberwithdraw/config/info.php
index bfbb67934..a6fe3ad7d 100644
--- a/src/addon/memberwithdraw/config/info.php
+++ b/src/addon/memberwithdraw/config/info.php
@@ -1,21 +1,12 @@
- 'memberwithdraw',
- 'title' => '会员提现',
- 'description' => '会员提现',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装),promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'memberwithdraw',
+ 'title' => '会员提现',
+ 'description' => '会员提现',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装),promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/memberwithdraw/event/Install.php b/src/addon/memberwithdraw/event/Install.php
index 75dfc002d..c7c85adb7 100644
--- a/src/addon/memberwithdraw/event/Install.php
+++ b/src/addon/memberwithdraw/event/Install.php
@@ -1,26 +1,17 @@
-getMemberWithdrawInfo([ [ "id", "=", $id ] ], "withdraw_no,account_number,realname,money,memo,transfer_type,site_id,applet_type,member_id");
- if (empty($info_result[ "data" ]))
- return $this->error();
-
- $info = $info_result[ "data" ];
- if (!in_array($info[ "transfer_type" ], [ "wechatpay", "alipay" ]))
- return $this->error('', "当前提现方式不支持在线转账");
-
- $pay_data = array (
- "id" => $id,
- "out_trade_no" => $info[ "withdraw_no" ],
- "real_name" => $info[ "realname" ],
- "amount" => $info[ "money" ],
- "desc" => "会员提现" . $info[ "memo" ],
- "transfer_type" => $info[ "transfer_type" ],
- "account_number" => $info[ "account_number" ],
- "site_id" => $info[ "site_id" ],
- "is_weapp" => $info[ "applet_type" ],
- "member_id" => $info[ 'member_id' ]
- );
- //调用在线转账借口
- $pay_result = event("PayTransfer", $pay_data, true);
- if (empty($pay_result)) {
- $pay_result = $this->error();
- }
- if ($pay_result[ "code" ] < 0) {
- return $pay_result;
- }
- //调用完成转账
- $result = $withdraw_model->transferFinish([ "id" => $id, "site_id" => $info[ "site_id" ] ]);
- return $result;
- }
+getMemberWithdrawInfo([ [ "id", "=", $id ] ], "withdraw_no,account_number,realname,money,memo,transfer_type,site_id,applet_type,member_id");
+ if (empty($info_result[ "data" ]))
+ return $this->error();
+
+ $info = $info_result[ "data" ];
+ if (!in_array($info[ "transfer_type" ], [ "wechatpay", "alipay" ]))
+ return $this->error('', "当前提现方式不支持在线转账");
+
+ $pay_data = array (
+ "id" => $id,
+ "out_trade_no" => $info[ "withdraw_no" ],
+ "real_name" => $info[ "realname" ],
+ "amount" => $info[ "money" ],
+ "desc" => "会员提现" . $info[ "memo" ],
+ "transfer_type" => $info[ "transfer_type" ],
+ "account_number" => $info[ "account_number" ],
+ "site_id" => $info[ "site_id" ],
+ "is_weapp" => $info[ "applet_type" ],
+ "member_id" => $info[ 'member_id' ]
+ );
+ //调用在线转账借口
+ $pay_result = event("PayTransfer", $pay_data, true);
+ if (empty($pay_result)) {
+ $pay_result = $this->error();
+ }
+ if ($pay_result[ "code" ] < 0) {
+ return $pay_result;
+ }
+ //调用完成转账
+ $result = $withdraw_model->transferFinish([ "id" => $id, "site_id" => $info[ "site_id" ] ]);
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/src/addon/memberwithdraw/shop/controller/Withdraw.php b/src/addon/memberwithdraw/shop/controller/Withdraw.php
index 02c22c846..60200338d 100644
--- a/src/addon/memberwithdraw/shop/controller/Withdraw.php
+++ b/src/addon/memberwithdraw/shop/controller/Withdraw.php
@@ -1,35 +1,27 @@
-isJson()) {
- $id = input('id', 0);
- $withdraw_model = new WithdrawModel();
- $result = $withdraw_model->transfer($id);
- return $result;
- }
- }
-
+isJson()) {
+ $id = input('id', 0);
+ $withdraw_model = new WithdrawModel();
+ $result = $withdraw_model->transfer($id);
+ return $result;
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/merch/config/diy_view.php b/src/addon/merch/config/diy_view.php
index 0e685b414..0f63c58ae 100644
--- a/src/addon/merch/config/diy_view.php
+++ b/src/addon/merch/config/diy_view.php
@@ -1,48 +1,40 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [
- /* [
- 'name' => 'MERCH_INFO',
- 'title' => '多商户',
- 'parent' => 'BASICS_LINK',
- 'wap_url' => '',
- 'web_url' => '',
- 'sort' => 0
- ]*/
- ],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [
+ /* [
+ 'name' => 'MERCH_INFO',
+ 'title' => '多商户',
+ 'parent' => 'BASICS_LINK',
+ 'wap_url' => '',
+ 'web_url' => '',
+ 'sort' => 0
+ ]*/
+ ],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/merch/event/Install.php b/src/addon/merch/event/Install.php
index 70d49c08d..27360fd8a 100644
--- a/src/addon/merch/event/Install.php
+++ b/src/addon/merch/event/Install.php
@@ -1,25 +1,17 @@
-getMessage());
- }
- }
+getMessage());
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/personnel/config/diy_view.php b/src/addon/personnel/config/diy_view.php
index 1872e00c4..9d29d35bc 100644
--- a/src/addon/personnel/config/diy_view.php
+++ b/src/addon/personnel/config/diy_view.php
@@ -1,13 +1,6 @@
'页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
diff --git a/src/addon/personnel/config/info.php b/src/addon/personnel/config/info.php
index 73bae96f3..d7752f36f 100644
--- a/src/addon/personnel/config/info.php
+++ b/src/addon/personnel/config/info.php
@@ -1,13 +1,5 @@
'personnel',
'title' => '电子名片',
diff --git a/src/addon/personnel/data/install.sql b/src/addon/personnel/data/install.sql
index 7a996ca29..30637d6de 100644
--- a/src/addon/personnel/data/install.sql
+++ b/src/addon/personnel/data/install.sql
@@ -6,14 +6,14 @@ CREATE TABLE IF NOT EXISTS `lucky_personnel_channel`
`channel_id` int unsigned NOT NULL AUTO_INCREMENT,
`site_id` int unsigned NOT NULL DEFAULT 0 COMMENT '站点ID',
`create_time` int unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
- `channel_type` varchar(20) NOT NULL DEFAULT 'wechat' COMMENT '视频号类型:wechat-微信视频号,douyin-抖音,kuaishou-快手,redbook-小红书,bilibili-B站',
- `channel_name` varchar(100) NOT NULL DEFAULT '' COMMENT '视频号ID',
- `feed_id` varchar(100) NOT NULL DEFAULT '' COMMENT '视频号内容ID',
+ `channel_type` varchar(30) NOT NULL DEFAULT 'wechat' COMMENT '视频号类型:wechat-微信视频号,douyin-抖音,kuaishou-快手,redbook-小红书,bilibili-B站',
+ `channel_name` varchar(200) NOT NULL DEFAULT '' COMMENT '视频号ID',
+ `feed_id` varchar(500) NOT NULL DEFAULT '' COMMENT '视频号内容ID',
`feed_token` varchar(255) NOT NULL DEFAULT '' COMMENT '视频号视频的标识',
- `avatar_image_type` varchar(10) NOT NULL DEFAULT 'upload' COMMENT '头像类型:upload-上传图片,url-URL',
+ `avatar_image_type` varchar(20) NOT NULL DEFAULT 'upload' COMMENT '头像类型:upload-上传图片,url-URL',
`avatar_url` varchar(500) NOT NULL DEFAULT '' COMMENT '头像URL',
- `video_title` varchar(200) NOT NULL DEFAULT '' COMMENT '视频标题',
- `cover_image_type` varchar(10) NOT NULL DEFAULT 'upload' COMMENT '封面类型:upload-上传图片,url-URL',
+ `video_title` varchar(500) NOT NULL DEFAULT '' COMMENT '视频标题',
+ `cover_image_type` varchar(20) NOT NULL DEFAULT 'upload' COMMENT '封面类型:upload-上传图片,url-URL',
`cover_url` varchar(500) NOT NULL DEFAULT '' COMMENT '封面URL',
`view_count` int unsigned NOT NULL DEFAULT 0 COMMENT '视频观看次数',
`show_view_count` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否显示视频观看次数:0-不显示,1-显示',
diff --git a/src/addon/personnel/event/Install.php b/src/addon/personnel/event/Install.php
index 3a95457d9..261811c78 100644
--- a/src/addon/personnel/event/Install.php
+++ b/src/addon/personnel/event/Install.php
@@ -1,13 +1,6 @@
{
// 特别注意:layui的select元素,不能使用v-model绑定数据, 只能使用layui的form.on('select')事件监听和form.val()方法设置默认值
diff --git a/src/addon/pointcash/config/diy_view.php b/src/addon/pointcash/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/pointcash/config/diy_view.php
+++ b/src/addon/pointcash/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/pointcash/config/info.php b/src/addon/pointcash/config/info.php
index 838e1a083..e1b488f87 100644
--- a/src/addon/pointcash/config/info.php
+++ b/src/addon/pointcash/config/info.php
@@ -1,20 +1,12 @@
- 'pointcash',
- 'title' => '积分抵现',
- 'description' => '下单时积分可抵部分现金',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'pointcash',
+ 'title' => '积分抵现',
+ 'description' => '下单时积分可抵部分现金',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/pointcash/event/Install.php b/src/addon/pointcash/event/Install.php
index c09b8d9d2..25dcf2d59 100644
--- a/src/addon/pointcash/event/Install.php
+++ b/src/addon/pointcash/event/Install.php
@@ -1,25 +1,17 @@
- [
- 'pointcash' => [
- 'type_name' => '积分抵现',
- 'type_url' => '',
- ],
- ]
- ];
- if ($data == '') {
- return $from_type;
- } else {
- return $from_type[$data] ?? [];
- }
-
- }
+ [
+ 'pointcash' => [
+ 'type_name' => '积分抵现',
+ 'type_url' => '',
+ ],
+ ]
+ ];
+ if ($data == '') {
+ return $from_type;
+ } else {
+ return $from_type[$data] ?? [];
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointcash/event/PointRule.php b/src/addon/pointcash/event/PointRule.php
index 0f34aa2dc..7b7e5f585 100644
--- a/src/addon/pointcash/event/PointRule.php
+++ b/src/addon/pointcash/event/PointRule.php
@@ -1,34 +1,25 @@
-getPointCashConfig($data['site_id'])['data'];
-
- $data = [
- 'title' => '积分抵现',
- 'content' => !$info['is_use'] || !$info['value']['cash_rate'] ? '-' : $info['value']['cash_rate'] . "积分可抵1元",
- 'url' => 'pointcash://shop/config/index',
- 'update_time' => $info['modify_time']
- ];
- return $data;
- }
+getPointCashConfig($data['site_id'])['data'];
+
+ $data = [
+ 'title' => '积分抵现',
+ 'content' => !$info['is_use'] || !$info['value']['cash_rate'] ? '-' : $info['value']['cash_rate'] . "积分可抵1元",
+ 'url' => 'pointcash://shop/config/index',
+ 'update_time' => $info['modify_time']
+ ];
+ return $data;
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointcash/event/ShowPromotion.php b/src/addon/pointcash/event/ShowPromotion.php
index f260abd57..a1785ee9b 100644
--- a/src/addon/pointcash/event/ShowPromotion.php
+++ b/src/addon/pointcash/event/ShowPromotion.php
@@ -1,95 +1,87 @@
- [
-
- ],
- 'shop' => [
- [
- //插件名称
- 'name' => 'pointcash',
- //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
- 'show_type' => 'shop',
- //展示主题
- 'title' => '积分抵现',
- //展示介绍
- 'description' => '下单时积分抵扣现金',
- //展示图标
- 'icon' => 'addon/pointcash/icon.png',
- //跳转链接
- 'url' => 'pointcash://shop/config/index',
- 'summary' => $this->summary($params)
- ],
-
- ],
-
- ];
- return $data;
- }
-
- /**
- * 营销活动概况
- * @param $params
- * @return array
- */
- private function summary($params)
- {
- if (empty($params)) {
- return [];
- }
-
- if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
- return [];
- }
-
- if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Config() )->getPointCashConfig($params[ 'site_id' ])[ 'data' ];
- //获取活动数量
- if (isset($params[ 'count' ])) {
- return [
- 'count' => $config[ 'is_use' ]
- ];
- }
-
- //获取活动概况,需要获取开始时间与结束时间
-
- if (isset($params[ 'summary' ])) {
- $value = $config[ 'value' ];
- return [
- 'unlimited_time' => [
- 'status' => $config[ 'is_use' ],
- 'detail' => empty($value[ 'cash_rate' ]) ? '未配置活动' : $value[ 'cash_rate' ] . '积分可抵1元',
- 'switch_type' => empty($value[ 'cash_rate' ]) ? 'jump' : 'switch',
- 'config_key' => 'POINTCASH_CONFIG'
- ]
- ];
- }
- }
-
+ [
+
+ ],
+ 'shop' => [
+ [
+ //插件名称
+ 'name' => 'pointcash',
+ //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
+ 'show_type' => 'shop',
+ //展示主题
+ 'title' => '积分抵现',
+ //展示介绍
+ 'description' => '下单时积分抵扣现金',
+ //展示图标
+ 'icon' => 'addon/pointcash/icon.png',
+ //跳转链接
+ 'url' => 'pointcash://shop/config/index',
+ 'summary' => $this->summary($params)
+ ],
+
+ ],
+
+ ];
+ return $data;
+ }
+
+ /**
+ * 营销活动概况
+ * @param $params
+ * @return array
+ */
+ private function summary($params)
+ {
+ if (empty($params)) {
+ return [];
+ }
+
+ if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
+ return [];
+ }
+
+ if (isset($params[ 'count' ]) || isset($params[ 'summary' ])) $config = ( new Config() )->getPointCashConfig($params[ 'site_id' ])[ 'data' ];
+ //获取活动数量
+ if (isset($params[ 'count' ])) {
+ return [
+ 'count' => $config[ 'is_use' ]
+ ];
+ }
+
+ //获取活动概况,需要获取开始时间与结束时间
+
+ if (isset($params[ 'summary' ])) {
+ $value = $config[ 'value' ];
+ return [
+ 'unlimited_time' => [
+ 'status' => $config[ 'is_use' ],
+ 'detail' => empty($value[ 'cash_rate' ]) ? '未配置活动' : $value[ 'cash_rate' ] . '积分可抵1元',
+ 'switch_type' => empty($value[ 'cash_rate' ]) ? 'jump' : 'switch',
+ 'config_key' => 'POINTCASH_CONFIG'
+ ]
+ ];
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/pointcash/event/UnInstall.php b/src/addon/pointcash/event/UnInstall.php
index e6a0736f6..85b76aaa9 100644
--- a/src/addon/pointcash/event/UnInstall.php
+++ b/src/addon/pointcash/event/UnInstall.php
@@ -1,25 +1,17 @@
-setConfig($data, '积分抵现', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'POINTCASH_CONFIG' ] ]);
- return $res;
- }
-
- /**
- * 获取积分抵现配置
- * @param $site_id
- * @param string $app_module
- * @return array
- */
- public function getPointCashConfig($site_id, $app_module = 'shop')
- {
- $config = new ConfigModel();
- $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'POINTCASH_CONFIG' ] ]);
- if (empty($res[ 'data' ][ 'value' ])) {
- //默认值设置
- $res[ 'data' ][ 'value' ] = [
- 'is_enable' => 0, // 是否开启
- 'cash_rate' => 0, // 抵现比率
- 'is_limit' => 0, // 是否限制订单金额门槛
- 'limit' => 0.00, // 订单金额门槛
- 'is_limit_use' => 0, // 是否限制使用上限
- 'type' => 0, // 限制类型 0:固定金额 1:订单百分比
- 'max_use' => 0 // 最大可用
- ];
- }
- return $res;
- }
+setConfig($data, '积分抵现', 1, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'POINTCASH_CONFIG' ] ]);
+ return $res;
+ }
+
+ /**
+ * 获取积分抵现配置
+ * @param $site_id
+ * @param string $app_module
+ * @return array
+ */
+ public function getPointCashConfig($site_id, $app_module = 'shop')
+ {
+ $config = new ConfigModel();
+ $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', $app_module ], [ 'config_key', '=', 'POINTCASH_CONFIG' ] ]);
+ if (empty($res[ 'data' ][ 'value' ])) {
+ //默认值设置
+ $res[ 'data' ][ 'value' ] = [
+ 'is_enable' => 0, // 是否开启
+ 'cash_rate' => 0, // 抵现比率
+ 'is_limit' => 0, // 是否限制订单金额门槛
+ 'limit' => 0.00, // 订单金额门槛
+ 'is_limit_use' => 0, // 是否限制使用上限
+ 'type' => 0, // 限制类型 0:固定金额 1:订单百分比
+ 'max_use' => 0 // 最大可用
+ ];
+ }
+ return $res;
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointcash/shop/controller/Config.php b/src/addon/pointcash/shop/controller/Config.php
index a13db289f..f82a10d34 100644
--- a/src/addon/pointcash/shop/controller/Config.php
+++ b/src/addon/pointcash/shop/controller/Config.php
@@ -1,44 +1,36 @@
-isJson()) {
- $data = [
- 'is_enable' => input('is_enable', 0), // 是否开启
- 'cash_rate' => input('cash_rate', 0), // 抵现比率
- 'is_limit' => input('is_limit', 0), // 是否限制订单金额门槛
- 'limit' => input('limit', 0.00), // 订单金额门槛
- 'is_limit_use' => input('is_limit_use', 0), // 是否限制使用上限
- 'type' => input('type', 0), // 限制类型 0:固定金额 1:订单百分比
- 'max_use' => input('max_use', 0) // 最大可用
- ];
- $res = $config->setPointCashConfig($data, $this->site_id);
- return $res;
- } else {
- $info = $config->getPointCashConfig($this->site_id);
- $this->assign('config', $info[ 'data' ][ 'value' ]);
- return $this->fetch('config/index');
- }
- }
+isJson()) {
+ $data = [
+ 'is_enable' => input('is_enable', 0), // 是否开启
+ 'cash_rate' => input('cash_rate', 0), // 抵现比率
+ 'is_limit' => input('is_limit', 0), // 是否限制订单金额门槛
+ 'limit' => input('limit', 0.00), // 订单金额门槛
+ 'is_limit_use' => input('is_limit_use', 0), // 是否限制使用上限
+ 'type' => input('type', 0), // 限制类型 0:固定金额 1:订单百分比
+ 'max_use' => input('max_use', 0) // 最大可用
+ ];
+ $res = $config->setPointCashConfig($data, $this->site_id);
+ return $res;
+ } else {
+ $info = $config->getPointCashConfig($this->site_id);
+ $this->assign('config', $info[ 'data' ][ 'value' ]);
+ return $this->fetch('config/index');
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/api/controller/Goods.php b/src/addon/pointexchange/api/controller/Goods.php
index 7d4ffbaad..c6cad13e7 100644
--- a/src/addon/pointexchange/api/controller/Goods.php
+++ b/src/addon/pointexchange/api/controller/Goods.php
@@ -1,209 +1,201 @@
-params['id'] ?? 0;
- if (empty($id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- $exchange_model = new ExchangeModel();
-
- $exchange_info = $exchange_model->getExchangeInfo($id, 'type, type_id')[ 'data' ];
- $condition = [
- [ 'peg.id', '=', $id ],
- [ 'peg.site_id', '=', $this->site_id ],
- [ 'peg.state', '=', 1 ],
- ];
-
- if (empty($exchange_info)) return $this->response($this->error('', '商品未找到'));
- $info = $exchange_model->getExchangeDetail($condition, $exchange_info[ 'type' ])[ 'data' ];
-
- if (empty($info)) return $this->response($this->error($info));
-
- if ($exchange_info[ 'type' ] == 1) {
-
- //判断商品规格项
- $goods_spec_format = $exchange_model->getGoodsSpecFormat($info[ 'exchange_id' ], $this->site_id, $info[ 'goods_spec_format' ]);
- $info[ 'goods_spec_format' ] = json_encode($goods_spec_format);
-
- $goods_service = new GoodsService();
- $info[ 'goods_service' ] = $goods_service->getServiceList([ [ 'site_id', '=', $this->site_id ], [ 'id', 'in', $info[ 'goods_service_ids' ] ] ], 'service_name,desc,icon')[ 'data' ];
- }
-
- return $this->response($this->success($info));
- }
-
- /**
- * 查询商品SKU集合
- * @return false|string
- */
- public function goodsSku()
- {
- $goods_id = $this->params['goods_id'] ?? 0;
- $exchange_id = $this->params['exchange_id'] ?? 0;
- $type = $this->params['type'] ?? 0;
- if (empty($goods_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- if (empty($exchange_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- $exchange_model = new ExchangeModel();
- $condition = [
- [ 'peg.id', '=', $exchange_id ],
- [ 'peg.site_id', '=', $this->site_id ],
- [ 'peg.state', '=', 1 ],
- ];
- $list = $exchange_model->getExchangeSkuList($condition, $type);
- if (!empty($list[ 'data' ])) {
- foreach ($list[ 'data' ] as $k => $v) {
- if (!empty($v[ 'goods_spec_format' ])) {
- $goods_spec_format = $exchange_model->getGoodsSpecFormat($v[ 'exchange_id' ], $this->site_id, $v[ 'goods_spec_format' ]);
- $list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
- }
- }
- }
-
- return $this->response($list);
- }
-
- public function page()
- {
- $page = $this->params['page'] ?? 1;
- $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
- $type = $this->params['type'] ?? 1;//兑换类型,1:商品,2:优惠券,3:红包
-
- //商品类型条件查询
- $keyword = $this->params['keyword'] ?? ''; //关键词
- $order = $this->params['order'] ?? '';//排序(综合、上新时间、价格)
- $sort = $this->params['sort'] ?? '';//升序、降序
- $min_point = $this->params['min_point'] ?? 0;//积分区间,小
- $max_point = $this->params['max_point'] ?? 0;//积分区间,大
- $category_id = $this->params['category_id'] ?? 0;//分类
- $condition = [
- [ 'peg.state', '=', 1 ],
- [ 'peg.type', '=', $type ],
- [ 'peg.site_id', '=', $this->site_id ]
- ];
-
- if (!empty($keyword)) {
- $condition[] = [ 'g.goods_name|peg.name', 'like', '%' . $keyword . '%' ];
- }
-
- // 非法参数进行过滤
- if ($sort != 'desc' && $sort != 'asc') {
- $sort = '';
- }
- // 非法参数进行过滤
- if ($order != '') {
- if ($order != 'create_time' && $order != 'point') {
- $order = 'peg.sort';
- } elseif ($order == 'create_time') {
- $order = 'peg.create_time';
- } else {
- $order = 'peg.' . $order;
- }
- $order_by = $order . ' ' . $sort;
- } else {
- $config_model = new ConfigModel();
- $sort_config = $config_model->getGoodsSort($this->site_id)[ 'data' ][ 'value' ];
- $order_by = 'peg.sort ' . $sort_config[ 'type' ] . ',peg.create_time desc';
- }
-
- if ($min_point != '' && $max_point != '') {
- $condition[] = [ 'peg.point', 'between', [ $min_point, $max_point ] ];
- } elseif ($min_point != '') {
- $condition[] = [ 'peg.point', '>=', $min_point ];
- } elseif ($max_point != '') {
- $condition[] = [ 'peg.point', '<=', $max_point ];
- }
-
- if (!empty($category_id)) {
- $goods_category_model = new GoodsCategoryModel();
-
- // 查询当前
- $category_list = $goods_category_model->getCategoryList([ [ 'category_id', '=', $category_id ], [ 'site_id', '=', $this->site_id ] ], 'category_id,pid,level')[ 'data' ];
-
- // 查询子级
- $category_child_list = $goods_category_model->getCategoryList([ [ 'pid', '=', $category_id ], [ 'site_id', '=', $this->site_id ] ], 'category_id,pid,level')[ 'data' ];
-
- $temp_category_list = [];
- if (!empty($category_list)) {
- $temp_category_list = $category_list;
- } elseif (!empty($category_child_list)) {
- $temp_category_list = $category_child_list;
- }
-
- if (!empty($temp_category_list)) {
- $category_id_arr = [];
- foreach ($temp_category_list as $k => $v) {
- // 三级分类,并且都能查询到
- if ($v[ 'level' ] == 3 && !empty($category_list) && !empty($category_child_list)) {
- $category_id_arr[] = $v['pid'];
- } else {
- $category_id_arr[] = $v['category_id'];
- }
- }
- $category_id_arr = array_unique($category_id_arr);
- $temp_condition = [];
- foreach ($category_id_arr as $ck => $cv) {
- $temp_condition[] = '%,' . $cv . ',%';
- }
- $category_condition = $temp_condition;
- $condition[] = [ 'g.category_id', 'like', $category_condition, 'or' ];
- }
- }
-
- $field = 'peg.*';
-
- $alias = 'peg';
- $join = [];
- if ($type == 1) {
- $condition[] = [ 'g.is_delete', '=', 0 ];
- $condition[] = [ 'g.goods_state', '=', 1 ];
-
- $join = [
- [ 'goods g', 'peg.type_id = g.goods_id', 'inner' ]
- ];
- $field .= ',g.goods_name as name,g.goods_image as image, g.goods_stock as stock, g.stock_show,g.sale_show,(g.sale_num + g.virtual_sale) as sale_num';
-
- } elseif ($type == 2) {
- $field .= ',pct.type as coupon_type,pct.goods_type,pct.at_least,pct.money,pct.discount';
- $join = [
- [ 'promotion_coupon_type pct', 'peg.type_id = pct.coupon_type_id', 'inner' ]
- ];
- }
- $exchange_model = new ExchangeModel();
-
- $list = $exchange_model->getExchangeGoodsPageList($condition, $page, $page_size, $order_by, $field, $alias, $join);
-
- return $this->response($list);
- }
-
+params['id'] ?? 0;
+ if (empty($id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ $exchange_model = new ExchangeModel();
+
+ $exchange_info = $exchange_model->getExchangeInfo($id, 'type, type_id')[ 'data' ];
+ $condition = [
+ [ 'peg.id', '=', $id ],
+ [ 'peg.site_id', '=', $this->site_id ],
+ [ 'peg.state', '=', 1 ],
+ ];
+
+ if (empty($exchange_info)) return $this->response($this->error('', '商品未找到'));
+ $info = $exchange_model->getExchangeDetail($condition, $exchange_info[ 'type' ])[ 'data' ];
+
+ if (empty($info)) return $this->response($this->error($info));
+
+ if ($exchange_info[ 'type' ] == 1) {
+
+ //判断商品规格项
+ $goods_spec_format = $exchange_model->getGoodsSpecFormat($info[ 'exchange_id' ], $this->site_id, $info[ 'goods_spec_format' ]);
+ $info[ 'goods_spec_format' ] = json_encode($goods_spec_format);
+
+ $goods_service = new GoodsService();
+ $info[ 'goods_service' ] = $goods_service->getServiceList([ [ 'site_id', '=', $this->site_id ], [ 'id', 'in', $info[ 'goods_service_ids' ] ] ], 'service_name,desc,icon')[ 'data' ];
+ }
+
+ return $this->response($this->success($info));
+ }
+
+ /**
+ * 查询商品SKU集合
+ * @return false|string
+ */
+ public function goodsSku()
+ {
+ $goods_id = $this->params['goods_id'] ?? 0;
+ $exchange_id = $this->params['exchange_id'] ?? 0;
+ $type = $this->params['type'] ?? 0;
+ if (empty($goods_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ if (empty($exchange_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ $exchange_model = new ExchangeModel();
+ $condition = [
+ [ 'peg.id', '=', $exchange_id ],
+ [ 'peg.site_id', '=', $this->site_id ],
+ [ 'peg.state', '=', 1 ],
+ ];
+ $list = $exchange_model->getExchangeSkuList($condition, $type);
+ if (!empty($list[ 'data' ])) {
+ foreach ($list[ 'data' ] as $k => $v) {
+ if (!empty($v[ 'goods_spec_format' ])) {
+ $goods_spec_format = $exchange_model->getGoodsSpecFormat($v[ 'exchange_id' ], $this->site_id, $v[ 'goods_spec_format' ]);
+ $list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
+ }
+ }
+ }
+
+ return $this->response($list);
+ }
+
+ public function page()
+ {
+ $page = $this->params['page'] ?? 1;
+ $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
+ $type = $this->params['type'] ?? 1;//兑换类型,1:商品,2:优惠券,3:红包
+
+ //商品类型条件查询
+ $keyword = $this->params['keyword'] ?? ''; //关键词
+ $order = $this->params['order'] ?? '';//排序(综合、上新时间、价格)
+ $sort = $this->params['sort'] ?? '';//升序、降序
+ $min_point = $this->params['min_point'] ?? 0;//积分区间,小
+ $max_point = $this->params['max_point'] ?? 0;//积分区间,大
+ $category_id = $this->params['category_id'] ?? 0;//分类
+ $condition = [
+ [ 'peg.state', '=', 1 ],
+ [ 'peg.type', '=', $type ],
+ [ 'peg.site_id', '=', $this->site_id ]
+ ];
+
+ if (!empty($keyword)) {
+ $condition[] = [ 'g.goods_name|peg.name', 'like', '%' . $keyword . '%' ];
+ }
+
+ // 非法参数进行过滤
+ if ($sort != 'desc' && $sort != 'asc') {
+ $sort = '';
+ }
+ // 非法参数进行过滤
+ if ($order != '') {
+ if ($order != 'create_time' && $order != 'point') {
+ $order = 'peg.sort';
+ } elseif ($order == 'create_time') {
+ $order = 'peg.create_time';
+ } else {
+ $order = 'peg.' . $order;
+ }
+ $order_by = $order . ' ' . $sort;
+ } else {
+ $config_model = new ConfigModel();
+ $sort_config = $config_model->getGoodsSort($this->site_id)[ 'data' ][ 'value' ];
+ $order_by = 'peg.sort ' . $sort_config[ 'type' ] . ',peg.create_time desc';
+ }
+
+ if ($min_point != '' && $max_point != '') {
+ $condition[] = [ 'peg.point', 'between', [ $min_point, $max_point ] ];
+ } elseif ($min_point != '') {
+ $condition[] = [ 'peg.point', '>=', $min_point ];
+ } elseif ($max_point != '') {
+ $condition[] = [ 'peg.point', '<=', $max_point ];
+ }
+
+ if (!empty($category_id)) {
+ $goods_category_model = new GoodsCategoryModel();
+
+ // 查询当前
+ $category_list = $goods_category_model->getCategoryList([ [ 'category_id', '=', $category_id ], [ 'site_id', '=', $this->site_id ] ], 'category_id,pid,level')[ 'data' ];
+
+ // 查询子级
+ $category_child_list = $goods_category_model->getCategoryList([ [ 'pid', '=', $category_id ], [ 'site_id', '=', $this->site_id ] ], 'category_id,pid,level')[ 'data' ];
+
+ $temp_category_list = [];
+ if (!empty($category_list)) {
+ $temp_category_list = $category_list;
+ } elseif (!empty($category_child_list)) {
+ $temp_category_list = $category_child_list;
+ }
+
+ if (!empty($temp_category_list)) {
+ $category_id_arr = [];
+ foreach ($temp_category_list as $k => $v) {
+ // 三级分类,并且都能查询到
+ if ($v[ 'level' ] == 3 && !empty($category_list) && !empty($category_child_list)) {
+ $category_id_arr[] = $v['pid'];
+ } else {
+ $category_id_arr[] = $v['category_id'];
+ }
+ }
+ $category_id_arr = array_unique($category_id_arr);
+ $temp_condition = [];
+ foreach ($category_id_arr as $ck => $cv) {
+ $temp_condition[] = '%,' . $cv . ',%';
+ }
+ $category_condition = $temp_condition;
+ $condition[] = [ 'g.category_id', 'like', $category_condition, 'or' ];
+ }
+ }
+
+ $field = 'peg.*';
+
+ $alias = 'peg';
+ $join = [];
+ if ($type == 1) {
+ $condition[] = [ 'g.is_delete', '=', 0 ];
+ $condition[] = [ 'g.goods_state', '=', 1 ];
+
+ $join = [
+ [ 'goods g', 'peg.type_id = g.goods_id', 'inner' ]
+ ];
+ $field .= ',g.goods_name as name,g.goods_image as image, g.goods_stock as stock, g.stock_show,g.sale_show,(g.sale_num + g.virtual_sale) as sale_num';
+
+ } elseif ($type == 2) {
+ $field .= ',pct.type as coupon_type,pct.goods_type,pct.at_least,pct.money,pct.discount';
+ $join = [
+ [ 'promotion_coupon_type pct', 'peg.type_id = pct.coupon_type_id', 'inner' ]
+ ];
+ }
+ $exchange_model = new ExchangeModel();
+
+ $list = $exchange_model->getExchangeGoodsPageList($condition, $page, $page_size, $order_by, $field, $alias, $join);
+
+ return $this->response($list);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/api/controller/Order.php b/src/addon/pointexchange/api/controller/Order.php
index 6cc4fedd1..6584fbcf7 100644
--- a/src/addon/pointexchange/api/controller/Order.php
+++ b/src/addon/pointexchange/api/controller/Order.php
@@ -1,83 +1,74 @@
-checkToken();
- if ($token['code'] < 0) return $this->response($token);
-
- $order_id = $this->params['order_id'] ?? 0;
- if (empty($order_id)) {
- return $this->response($this->error('', 'REQUEST_ORDER_ID'));
- }
-
- $condition = [
- [ 'order_id', '=', $order_id ],
- [ 'member_id', '=', $this->member_id ],
- [ 'site_id', '=', $this->site_id ],
- ];
- $field = '*';
- $exchange_model = new OrderModel();
-
- $info = $exchange_model->getOrderInfo($condition, $field);
- return $this->response($info);
- }
-
- public function page()
- {
- $token = $this->checkToken();
- if ($token['code'] < 0) return $this->response($token);
-
- $page = $this->params['page'] ?? 1;
- $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
- $order_status = $this->params['order_status'] ?? 'all';
- $condition = [
- [ 'member_id', '=', $this->member_id ],
- [ 'site_id', '=', $this->site_id ],
- ];
- if ($order_status != 'all') $condition[] = ['order_status', '=', $order_status];
- $order = 'create_time desc';
- $field = '*';
-
- $exchange_model = new OrderModel();
- $list = $exchange_model->getExchangePageList($condition, $page, $page_size, $order, $field);
- return $this->response($list);
- }
-
- /**
- * 关闭订单
- * @return false|string
- */
- public function close(){
- $token = $this->checkToken();
- if ($token['code'] < 0) return $this->response($token);
-
- $order_id = $this->params['order_id'] ?? 0;
-
- $exchange_model = new OrderModel();
- $result = $exchange_model->closeOrder($order_id);
- return $this->response($result);
- }
-
+checkToken();
+ if ($token['code'] < 0) return $this->response($token);
+
+ $order_id = $this->params['order_id'] ?? 0;
+ if (empty($order_id)) {
+ return $this->response($this->error('', 'REQUEST_ORDER_ID'));
+ }
+
+ $condition = [
+ [ 'order_id', '=', $order_id ],
+ [ 'member_id', '=', $this->member_id ],
+ [ 'site_id', '=', $this->site_id ],
+ ];
+ $field = '*';
+ $exchange_model = new OrderModel();
+
+ $info = $exchange_model->getOrderInfo($condition, $field);
+ return $this->response($info);
+ }
+
+ public function page()
+ {
+ $token = $this->checkToken();
+ if ($token['code'] < 0) return $this->response($token);
+
+ $page = $this->params['page'] ?? 1;
+ $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;
+ $order_status = $this->params['order_status'] ?? 'all';
+ $condition = [
+ [ 'member_id', '=', $this->member_id ],
+ [ 'site_id', '=', $this->site_id ],
+ ];
+ if ($order_status != 'all') $condition[] = ['order_status', '=', $order_status];
+ $order = 'create_time desc';
+ $field = '*';
+
+ $exchange_model = new OrderModel();
+ $list = $exchange_model->getExchangePageList($condition, $page, $page_size, $order, $field);
+ return $this->response($list);
+ }
+
+ /**
+ * 关闭订单
+ * @return false|string
+ */
+ public function close(){
+ $token = $this->checkToken();
+ if ($token['code'] < 0) return $this->response($token);
+
+ $order_id = $this->params['order_id'] ?? 0;
+
+ $exchange_model = new OrderModel();
+ $result = $exchange_model->closeOrder($order_id);
+ return $this->response($result);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/config/info.php b/src/addon/pointexchange/config/info.php
index 0f4944b02..e5e01967c 100644
--- a/src/addon/pointexchange/config/info.php
+++ b/src/addon/pointexchange/config/info.php
@@ -1,20 +1,12 @@
- 'pointexchange',
- 'title' => '积分商城',
- 'description' => '积分购买商品,形成积分营销闭环',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '1.0',
- 'version_no' => '100000',
- 'content' => '',
+ 'pointexchange',
+ 'title' => '积分商城',
+ 'description' => '积分购买商品,形成积分营销闭环',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '1.0',
+ 'version_no' => '100000',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/CouponGetType.php b/src/addon/pointexchange/event/CouponGetType.php
index 48ca6d9d7..1bf585ff1 100644
--- a/src/addon/pointexchange/event/CouponGetType.php
+++ b/src/addon/pointexchange/event/CouponGetType.php
@@ -1,26 +1,17 @@
- '积分兑换'];
- }
+ '积分兑换'];
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/CronExchangeOrderClose.php b/src/addon/pointexchange/event/CronExchangeOrderClose.php
index 5a7e017fb..0037e8f4a 100644
--- a/src/addon/pointexchange/event/CronExchangeOrderClose.php
+++ b/src/addon/pointexchange/event/CronExchangeOrderClose.php
@@ -1,28 +1,20 @@
-closeOrder($data['relate_id']);
- }
-
+closeOrder($data['relate_id']);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/Install.php b/src/addon/pointexchange/event/Install.php
index 3f2254826..657892b4a 100644
--- a/src/addon/pointexchange/event/Install.php
+++ b/src/addon/pointexchange/event/Install.php
@@ -1,26 +1,18 @@
- [
- 'pointexchange' => [
- 'type_name' => '积分兑换',
- 'type_url' => ''
- ]
- ],
-// 'point' => [
-// 'pointexchangerefund' => [
-// 'type_name' => '积分兑换退还',
-// 'type_url' => ''
-// ],
-//
-// ]
- ];
- if($data == ''){
- return $from_type;
- }else{
- return $from_type[$data] ?? [];
- }
-
- }
+ [
+ 'pointexchange' => [
+ 'type_name' => '积分兑换',
+ 'type_url' => ''
+ ]
+ ],
+// 'point' => [
+// 'pointexchangerefund' => [
+// 'type_name' => '积分兑换退还',
+// 'type_url' => ''
+// ],
+//
+// ]
+ ];
+ if($data == ''){
+ return $from_type;
+ }else{
+ return $from_type[$data] ?? [];
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/OrderClose.php b/src/addon/pointexchange/event/OrderClose.php
index afe6c56e4..3899287be 100644
--- a/src/addon/pointexchange/event/OrderClose.php
+++ b/src/addon/pointexchange/event/OrderClose.php
@@ -1,41 +1,33 @@
-getOrderInfo([ [ 'relate_order_id', '=', $param[ 'order_id' ] ] ]);
-
- if ($order_info_result[ 'code' ] < 0 || empty($order_info_result[ 'data' ])) {
- return $order_info_result;
- }
- if (empty($order_info_result[ 'data' ])) {
- $order_info_result[ 'data' ][ 'order_id' ] = $param[ 'order_id' ];
- }
- $res = $order_model->closeOrder($order_info_result[ 'data' ][ 'order_id' ]);
- return $res;
- }
+getOrderInfo([ [ 'relate_order_id', '=', $param[ 'order_id' ] ] ]);
+
+ if ($order_info_result[ 'code' ] < 0 || empty($order_info_result[ 'data' ])) {
+ return $order_info_result;
+ }
+ if (empty($order_info_result[ 'data' ])) {
+ $order_info_result[ 'data' ][ 'order_id' ] = $param[ 'order_id' ];
+ }
+ $res = $order_model->closeOrder($order_info_result[ 'data' ][ 'order_id' ]);
+ return $res;
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/OrderPromotionType.php b/src/addon/pointexchange/event/OrderPromotionType.php
index 7461e09c1..992885d3a 100644
--- a/src/addon/pointexchange/event/OrderPromotionType.php
+++ b/src/addon/pointexchange/event/OrderPromotionType.php
@@ -1,29 +1,20 @@
- "积分兑换", "type" => "pointexchange"];
- }
+ "积分兑换", "type" => "pointexchange"];
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/PointexchangeOrderPayNotify.php b/src/addon/pointexchange/event/PointexchangeOrderPayNotify.php
index 772f068a3..7169c7e50 100644
--- a/src/addon/pointexchange/event/PointexchangeOrderPayNotify.php
+++ b/src/addon/pointexchange/event/PointexchangeOrderPayNotify.php
@@ -1,29 +1,20 @@
-orderPay($data);
- }
-
+orderPay($data);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/ShowPromotion.php b/src/addon/pointexchange/event/ShowPromotion.php
index 6089a6463..b930bd157 100644
--- a/src/addon/pointexchange/event/ShowPromotion.php
+++ b/src/addon/pointexchange/event/ShowPromotion.php
@@ -1,52 +1,44 @@
- [
-
- ],
- 'shop' => [
- [
- //插件名称
- 'name' => 'pointexchange',
- //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
- 'show_type' => 'shop',
- //展示主题
- 'title' => '积分商城',
- //展示介绍
- 'description' => '客户积分兑换更多好物',
- //展示图标
- 'icon' => 'addon/pointexchange/icon.png',
- //跳转链接
- 'url' => 'pointexchange://shop/exchange/lists',
- ],
-
- ],
-
- ];
- return $data;
- }
+ [
+
+ ],
+ 'shop' => [
+ [
+ //插件名称
+ 'name' => 'pointexchange',
+ //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具)
+ 'show_type' => 'shop',
+ //展示主题
+ 'title' => '积分商城',
+ //展示介绍
+ 'description' => '客户积分兑换更多好物',
+ //展示图标
+ 'icon' => 'addon/pointexchange/icon.png',
+ //跳转链接
+ 'url' => 'pointexchange://shop/exchange/lists',
+ ],
+
+ ],
+
+ ];
+ return $data;
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/event/UnInstall.php b/src/addon/pointexchange/event/UnInstall.php
index e23c13679..a45dcc20c 100644
--- a/src/addon/pointexchange/event/UnInstall.php
+++ b/src/addon/pointexchange/event/UnInstall.php
@@ -1,26 +1,18 @@
- [
- 'name' => 'goods',
- 'title' => '兑换商品',
- ],
- 2 => [
- 'name' => 'coupon',
- 'title' => '兑换优惠券',
- ],
- 3 => [
- 'name' => 'balance',
- 'title' => '兑换红包',
- ],
- ];
-
- /**
- * 添加积分兑换
- * @param array $data
- */
- public function addExchange($data)
- {
-
- model('promotion_exchange')->startTrans();
- try {
- $exchange_goods_data = [
- 'site_id' => $data[ 'site_id' ],
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'state' => $data[ 'state' ],
- 'create_time' => time(),
- ];
- if ($data[ 'type' ] == 1) {
- $exchange_goods = $data[ 'goods_data' ];
-
- foreach ($exchange_goods as $k => $v) {
- $exist = model('promotion_exchange_goods')->getInfo([ [ 'type', '=', 1 ], [ 'type_id', '=', $v[ 'goods_id' ] ] ], 'id');
- if (!empty($exist)) {
- return $this->error('', '商品已存在,请不要重复添加');
- }
- $sku_model = new Goods();
- $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $v[ 'sku_list' ][ 0 ][ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
- $exchange_goods_data[ 'type_id' ] = $v[ 'goods_id' ];
- $exchange_goods_data[ 'name' ] = $sku_info[ 'sku_name' ];
- $exchange_goods_data[ 'image' ] = $sku_info[ 'sku_image' ];
- $exchange_goods_data[ 'point' ] = $v[ 'sku_list' ][ 0 ][ 'point' ];
- $exchange_goods_data[ 'price' ] = $v[ 'sku_list' ][ 0 ][ 'exchange_price' ];
- $exchange_goods_data[ 'content' ] = $sku_info[ 'goods_content' ];
- $exchange_goods_data[ 'rule' ] = $data[ 'rule' ];
- $exchange_goods_data[ 'pay_type' ] = $v[ 'sku_list' ][ 0 ][ 'exchange_price' ] ? 1 : 0;
- $exchange_goods_id = model('promotion_exchange_goods')->add($exchange_goods_data);
-
- foreach ($v[ 'sku_list' ] as $index => $item) {
- $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
- $exchange_data = [
- 'site_id' => $data[ 'site_id' ],
- 'exchange_goods_id' => $exchange_goods_id,
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'type_id' => $item[ 'sku_id' ],
- 'state' => $data[ 'state' ],
- 'rule' => $data[ 'rule' ],
- 'name' => $sku_info[ 'sku_name' ],
- 'image' => $sku_info[ 'sku_image' ],
- 'stock' => $sku_info[ 'stock' ],
- 'pay_type' => empty($item[ 'exchange_price' ]) ? 0 : 1,
- 'point' => $item[ 'point' ],
- 'market_price' => $sku_info[ 'price' ],
- 'price' => $item[ 'exchange_price' ],
- 'limit_num' => $item[ 'limit_num' ],
- 'create_time' => time(),
- 'content' => $sku_info[ 'goods_content' ],
-
- 'is_free_shipping' => $data[ 'is_free_shipping' ], //是否免邮(0不免邮 1免邮)
- 'delivery_type' => $data[ 'delivery_type' ] ?? 1, //运费类型( 0 固定运费 1运费模板 2按照商品)
- 'shipping_template' => $data[ 'shipping_template' ], //运费模板
- 'delivery_price' => $data[ 'delivery_price' ] ?? 0 //运费
- ];
- model('promotion_exchange')->add($exchange_data);
-
- }
- }
- } elseif ($data[ 'type' ] == 2) {
- $exist = model('promotion_exchange_goods')->getInfo([ [ 'type', '=', 2 ], [ 'type_id', '=', $data[ 'coupon_type_id' ] ] ], 'id');
- if (!empty($exist)) {
- return $this->error('', '该优惠券已存在,请不要重复添加');
- }
-
- $coupon = new Coupon();
- $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $data[ 'coupon_type_id' ] ] ], 'coupon_type_id,coupon_name,money,count,image,status,type,discount')[ 'data' ];
-
- $exchange_goods_data[ 'type_id' ] = $data[ 'coupon_type_id' ];
- $exchange_goods_data[ 'name' ] = $coupon_type_info[ 'coupon_name' ];
- $exchange_goods_data[ 'image' ] = $coupon_type_info[ 'image' ];
- $exchange_goods_data[ 'point' ] = $data[ 'point' ];
- $exchange_goods_data[ 'content' ] = $data[ 'content' ];
-
- $exchange_goods_id = model('promotion_exchange_goods')->add($exchange_goods_data);
-
- $exchange_data = [
- 'site_id' => $data[ 'site_id' ],
- 'exchange_goods_id' => $exchange_goods_id,
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'state' => $data[ 'state' ],
- 'type_id' => $data[ 'coupon_type_id' ],
- 'name' => $coupon_type_info[ 'coupon_name' ],
- 'image' => $coupon_type_info[ 'image' ],
- 'stock' => $data[ 'stock' ],
- 'pay_type' => 0,
- 'point' => $data[ 'point' ],
- 'create_time' => time(),
- 'content' => $data[ 'content' ],
- ];
- if ($coupon_type_info[ 'type' ] == 'reward') {
- $exchange_data[ 'market_price' ] = $coupon_type_info[ 'money' ];
- } elseif ($coupon_type_info[ 'type' ] == 'discount') {
- $exchange_data[ 'market_price' ] = $coupon_type_info[ 'discount' ];
- }
-
- model('promotion_exchange')->add($exchange_data);
-
- } elseif ($data[ 'type' ] == 3) {
-
- $exchange_goods_data[ 'name' ] = $data[ 'name' ];
- $exchange_goods_data[ 'image' ] = $data[ 'image' ];
- $exchange_goods_data[ 'point' ] = $data[ 'point' ];
- $exchange_goods_data[ 'balance' ] = $data[ 'balance' ];
- $exchange_goods_data[ 'content' ] = $data[ 'content' ];
-
- $exchange_goods_id = model('promotion_exchange_goods')->add($exchange_goods_data);
-
- $exchange_data = [
- 'site_id' => $data[ 'site_id' ],
- 'exchange_goods_id' => $exchange_goods_id,
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'state' => $data[ 'state' ],
- 'name' => $data[ 'name' ],
- 'image' => $data[ 'image' ],
- 'stock' => $data[ 'stock' ],
- 'pay_type' => 0,
- 'point' => $data[ 'point' ],
- 'balance' => $data[ 'balance' ],
- 'create_time' => time(),
- 'content' => $data[ 'content' ],
- ];
-
- model('promotion_exchange')->add($exchange_data);
- }
-
- model('promotion_exchange')->commit();
- return $this->success();
- } catch (\Exception $e) {
- model('promotion_exchange')->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
- /**
- * 编辑积分兑换
- * @param array $data
- */
- public function editExchange($data)
- {
- model('promotion_exchange')->startTrans();
- try {
- $exchange_goods_id = $data[ 'id' ];
- if ($data[ 'type' ] == 1) {
- $goods_data = $data[ 'goods_data' ];
-
- $sku_model = new Goods();
- $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $goods_data[ 0 ][ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
- $exchange_goods_data = [
- 'modify_time' => time(),
- 'pay_type' => $goods_data[ 0 ][ 'exchange_price' ] ? 1 : 0,
- ];
- $exchange_goods_data[ 'name' ] = $sku_info[ 'sku_name' ];
- $exchange_goods_data[ 'image' ] = $sku_info[ 'sku_image' ];
- $exchange_goods_data[ 'point' ] = $goods_data[ 0 ][ 'point' ];
- $exchange_goods_data[ 'price' ] = $goods_data[ 0 ][ 'exchange_price' ];
- $exchange_goods_data[ 'content' ] = $sku_info[ 'goods_content' ];
- $exchange_goods_data[ 'rule' ] = $data[ 'rule' ];
- $exchange_goods_data[ 'state' ] = $data[ 'state' ];
- model('promotion_exchange_goods')->update($exchange_goods_data, [ [ 'id', '=', $exchange_goods_id ] ]);
-
- model('promotion_exchange')->delete([ [ 'exchange_goods_id', '=', $exchange_goods_id ] ]);
-
- foreach ($goods_data as $index => $item) {
- $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
- $exchange_data = [
- 'site_id' => $data[ 'site_id' ],
- 'exchange_goods_id' => $exchange_goods_id,
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'type_id' => $item[ 'sku_id' ],
- 'state' => $data[ 'state' ],
- 'rule' => $data[ 'rule' ],
- 'name' => $sku_info[ 'sku_name' ],
- 'image' => $sku_info[ 'sku_image' ],
- 'stock' => $sku_info[ 'stock' ],
- 'pay_type' => empty($item[ 'exchange_price' ]) ? 0 : 1,
- 'point' => $item[ 'point' ],
- 'market_price' => $sku_info[ 'price' ],
- 'price' => $item[ 'exchange_price' ],
- 'limit_num' => $item[ 'limit_num' ],
- 'create_time' => time(),
- 'content' => $sku_info[ 'goods_content' ],
-
- 'is_free_shipping' => $data[ 'is_free_shipping' ], //是否免邮(0不免邮 1免邮)
- 'delivery_type' => $data[ 'delivery_type' ] ?? 1, //运费类型( 0 固定运费 1运费模板 2按照商品)
- 'shipping_template' => $data[ 'shipping_template' ], //运费模板
- 'delivery_price' => $data[ 'delivery_price' ] ?? 0 //运费
-
- ];
- model('promotion_exchange')->add($exchange_data);
- }
-
- } else if ($data[ 'type' ] == 2) {
- $coupon = new Coupon();
- $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $data[ 'coupon_type_id' ] ] ], 'coupon_type_id,coupon_name,money,count,image,status,type,discount')[ 'data' ];
- $exchange_goods_data = [];
- $exchange_goods_data[ 'type_id' ] = $data[ 'coupon_type_id' ];
- $exchange_goods_data[ 'name' ] = $coupon_type_info[ 'coupon_name' ];
- $exchange_goods_data[ 'image' ] = $coupon_type_info[ 'image' ];
- $exchange_goods_data[ 'point' ] = $data[ 'point' ];
- $exchange_goods_data[ 'content' ] = $data[ 'content' ];
- $exchange_goods_data[ 'state' ] = $data[ 'state' ];
-
- model('promotion_exchange_goods')->update($exchange_goods_data, [ [ 'id', '=', $exchange_goods_id ] ]);
- $exchange_data = [
- 'site_id' => $data[ 'site_id' ],
- 'exchange_goods_id' => $exchange_goods_id,
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'state' => $data[ 'state' ],
- 'type_id' => $data[ 'coupon_type_id' ],
- 'name' => $coupon_type_info[ 'coupon_name' ],
- 'image' => $coupon_type_info[ 'image' ],
- 'stock' => $data[ 'stock' ],
- 'pay_type' => 0,
- 'point' => $data[ 'point' ],
- 'create_time' => time(),
- 'content' => $data[ 'content' ],
- ];
- if ($coupon_type_info[ 'type' ] == 'reward') {
- $exchange_data[ 'market_price' ] = $coupon_type_info[ 'money' ];
- } elseif ($coupon_type_info[ 'type' ] == 'discount') {
- $exchange_data[ 'market_price' ] = $coupon_type_info[ 'discount' ];
- }
- model('promotion_exchange')->delete([ [ 'exchange_goods_id', '=', $exchange_goods_id ] ]);
- model('promotion_exchange')->add($exchange_data);
-
- } else if ($data[ 'type' ] == 3) {
- $exchange_goods_data = [];
- $exchange_goods_data[ 'name' ] = $data[ 'name' ];
- $exchange_goods_data[ 'image' ] = $data[ 'image' ];
- $exchange_goods_data[ 'point' ] = $data[ 'point' ];
- $exchange_goods_data[ 'balance' ] = $data[ 'balance' ];
- $exchange_goods_data[ 'content' ] = $data[ 'content' ];
- $exchange_goods_data[ 'state' ] = $data[ 'state' ];
-
- $exchange_goods_info = model('promotion_exchange_goods')->getInfo([ [ 'id', '=', $exchange_goods_id ] ]);
- if (!empty($exchange_goods_info[ 'image' ]) && !empty($data[ 'image' ]) && $exchange_goods_info[ 'image' ] != $data[ 'image' ]) {
- $upload_model = new Upload();
- $upload_model->deletePic($exchange_goods_info[ 'image' ], $data[ 'site_id' ]);
- }
-
- model('promotion_exchange_goods')->update($exchange_goods_data, [ [ 'id', '=', $exchange_goods_id ] ]);
-
- $exchange_data = [
- 'site_id' => $data[ 'site_id' ],
- 'exchange_goods_id' => $exchange_goods_id,
- 'type' => $data[ 'type' ],
- 'type_name' => $data[ 'type_name' ],
- 'state' => $data[ 'state' ],
- 'name' => $data[ 'name' ],
- 'image' => $data[ 'image' ],
- 'stock' => $data[ 'stock' ],
- 'pay_type' => 0,
- 'point' => $data[ 'point' ],
- 'balance' => $data[ 'balance' ],
- 'create_time' => time(),
- 'content' => $data[ 'content' ],
- ];
- model('promotion_exchange')->delete([ [ 'exchange_goods_id', '=', $exchange_goods_id ] ]);
- model('promotion_exchange')->add($exchange_data);
-
- }
-
- model('promotion_exchange')->commit();
- return $this->success();
- } catch (\Exception $e) {
- model('promotion_exchange')->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
- /**
- * 删除积分兑换
- * @param string $ids
- */
- public function deleteExchange($ids)
- {
- $list = model("promotion_exchange")->getList([ [ 'exchange_goods_id', 'in', $ids ] ]);
- if ($list) {
- foreach ($list as $k => $v) {
- if (!empty($v[ 'image' ])) {
- $upload_model = new Upload();
- $upload_model->deletePic($v[ 'image' ], $v[ 'site_id' ]);
- }
- }
- }
-
- model("promotion_exchange")->delete([ [ 'exchange_goods_id', 'in', $ids ] ]);
- model("promotion_exchange_goods")->delete([ [ 'id', 'in', $ids ] ]);
- return $this->success();
- }
-
- /**
- * 获取积分兑换信息
- * @param int $id
- */
- public function getExchangeInfo($id, $field = '*', $sku_id = 0)
- {
-
- $condition = [
- [ 'exchange_goods_id', '=', $id ]
- ];
- if ($sku_id) $condition[] = [ 'type_id', '=', $sku_id ];
-
- $info = model("promotion_exchange")->getInfo($condition, $field);
- if (!empty($info) && !empty($info[ 'type' ])) {
- switch ( $info[ 'type' ] ) {
- case 1:
- //商品
- $goods = new Goods();
- $goods_sku_info = $goods->getGoodsSkuInfo([ [ 'sku_id', '=', $info[ 'type_id' ], [ 'goods_state', '=', 1 ], [ 'is_delete', '=', 0 ] ] ], 'sku_id,sku_name,stock')[ 'data' ];
- if (!empty($goods_sku_info)) {
- $goods_sku_info[ 'stock' ] = numberFormat($goods_sku_info[ 'stock' ]);
- $info = array_merge($info, $goods_sku_info);
- } else {
- $info = [];
- }
- break;
- case 2:
- //优惠券
- $coupon = new Coupon();
- $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $info[ 'type_id' ] ] ], 'type as coupon_type,discount_limit,count,lead_count')[ 'data' ];
-
- if (!empty($coupon_type_info)) {
- $info = array_merge($info, $coupon_type_info);
- } else {
- $info = [];
- }
- break;
- case 3:
- //余额红包
- break;
- }
- }
- return $this->success($info);
- }
-
- /**
- * 获取积分兑换商品详情
- * @param $id
- * @param $site_id
- * @return array
- */
- public function getExchangeGoodsDetail($id, $site_id)
- {
- $info = model("promotion_exchange_goods")->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'id,type,type_name,type_id,name,image,pay_type,point,price,delivery_price,balance,state,content,rule');
- // 兑换类型,1:商品,2:优惠券,3:红包
- switch ( $info[ 'type' ] ) {
- case 1:
- //商品
- $goods_sku = model('goods_sku')->getList([ [ 'goods_id', '=', $info[ 'type_id' ] ], [ 'is_delete', '=', 0 ], [ 'goods_state', '=', 1 ] ], 'stock, price,sku_id,sku_name,discount_price,stock as goods_stock,sku_image,sku_images,goods_id,site_id,goods_content');
- $exchange_list = model("promotion_exchange")->getList([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'limit_num, id,type,type_name,type_id,name,image,pay_type,point,price,delivery_price,balance,state,content,delivery_type,is_free_shipping,shipping_template,rule');
-
- foreach ($goods_sku as $k => $v) {
- $goods_sku[ $k ][ 'is_select' ] = 0;
- $goods_sku[ $k ][ 'exchange_price' ] = 0;
- $goods_sku[ $k ][ 'point' ] = 0;
- $goods_sku[ $k ][ 'limit_num' ] = 0;
- $goods_sku[ $k ][ 'stock' ] = numberFormat($goods_sku[ $k ][ 'stock' ]);
- $goods_sku[ $k ][ 'goods_stock' ] = numberFormat($goods_sku[ $k ][ 'goods_stock' ]);
- foreach ($exchange_list as $key => $val) {
- if ($val[ 'type_id' ] == $v[ 'sku_id' ]) {
- $goods_sku[ $k ][ 'is_select' ] = 1;
- $goods_sku[ $k ][ 'exchange_price' ] = $val[ 'price' ];
- $goods_sku[ $k ][ 'limit_num' ] = $val[ 'limit_num' ];
- $goods_sku[ $k ][ 'point' ] = $val[ 'point' ];
- }
- }
- }
-
- $info[ 'goods_sku' ] = $goods_sku;
- $info[ 'exchange_goods' ] = $exchange_list;
-
- break;
- case 2:
- //优惠券
- $coupon = new Coupon();
- $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $info[ 'type_id' ] ] ], 'coupon_type_id,coupon_name,money,count as stock,status,lead_count,max_fetch,at_least,end_time,validity_type,fixed_term,goods_type,is_limit,type as coupon_type,discount_limit,discount')[ 'data' ];
- $exchange_info = model("promotion_exchange")->getInfo([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'market_price,stock');
- if (!empty($coupon_type_info)) {
- $info = array_merge($info, $coupon_type_info);
- } else {
- $info = [];
- }
- $info = array_merge($info, $exchange_info);
-
- break;
- case 3:
- //余额红包
- $exchange_info = model("promotion_exchange")->getInfo([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'stock');
- if (!empty($exchange_info)) {
- $info = array_merge($info, $exchange_info);
- } else {
- $info = [];
- }
- break;
- }
- if (!empty($info)) {
- return $this->success($info);
- } else {
- return $this->error('', '该兑换物品已失效');
- }
- }
-
- /**
- * 获取积分兑换列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @param string $alias
- * @param array $join
- * @return array
- */
- public function getExchangeList($condition = [], $field = '*', $order = '', $limit = null, $alias = '', $join = [])
- {
- $list = model('promotion_exchange')->getList($condition, $field, $order, $alias, $join, '', $limit);
- return $this->success($list);
- }
-
- /**
- * 获取积分兑换列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @param string $alias
- * @param array $join
- * @return array
- */
- public function getExchangePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*', $alias = '', $join = [])
- {
- $list = model('promotion_exchange')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- return $this->success($list);
- }
-
- /**
- * 获取积分兑换列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @return array
- */
- public function getExchangeGoodsList($condition = [], $field = '*', $order = '', $limit = null)
- {
- $list = model('promotion_exchange_goods')->getList($condition, $field, $order, '', '', '', $limit);
- return $this->success($list);
- }
-
- /**
- * 获取积分兑换列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @param string $alias
- * @param array $join
- * @return array
- */
- public function getExchangeGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*', $alias = '', $join = [])
- {
- $list = model('promotion_exchange_goods')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- if(!empty($list['list']))
- {
- $goods_id_array = [];
- foreach ($list['list'] as $k => $v)
- {
- if($v['type'] == 1)
- {
- $goods_id_array[] = $v['type_id'];
- }
- }
- if(!empty($goods_id_array))
- {
- $goods_array = [];
- $goods_ids = implode(",", $goods_id_array);
- $goods_list = model('goods')->getList([ [ 'goods_id', 'in', $goods_ids ], ['is_delete', '=', 0] ], "goods_id, goods_name, is_delete");
- if(!empty($goods_list))
- {
- $key = array_column($goods_list, 'goods_id');
- $goods_array = array_combine($key, $goods_list);
- }
-
- }
- foreach ($list[ 'list' ] as $k => $v) {
- if ($v[ 'type' ] == 1) {
- $goods_info = $goods_array[$v['type_id']] ?? [];
- if (empty($goods_info)) {
- unset($list[ 'list' ][ $k ]);
- } else {
- if ($goods_info[ 'is_delete' ] == 1) {
- unset($list[ 'list' ][ $k ]);
- } else {
- $list[ 'list' ][ $k ][ 'g_name' ] = $goods_info[ 'goods_name' ];
- }
- }
-
- }
- }
- }
-
- return $this->success($list);
- }
-
- /**
- * 增加库存
- * @param $param
- */
- public function incStock($param)
- {
- $condition = array (
- [ "id", "=", $param[ "id" ] ]
- );
- $num = $param[ "num" ];
- $info = model("promotion_exchange")->getInfo($condition, "stock, name");
- if (empty($info))
- return $this->error(-1, "");
-
- //编辑sku库存
- $result = model("promotion_exchange")->setInc($condition, "stock", $num);
-
- return $this->success($result);
- }
-
- /**
- * 减少库存
- * @param $param
- */
- public function decStock($param)
- {
- $condition = array (
- [ "id", "=", $param[ "id" ] ]
- );
- $num = $param[ "num" ];
-
- $info = model("promotion_exchange")->getInfo($condition, "stock, name, type");
- if (empty($info))
- return $this->error();
-
- if ($info[ 'type' ] == 2 && $info[ 'stock' ] == -1) {
- return $this->success();
- }
-
- if ($info[ "stock" ] < 0) {
- return $this->error('', $info[ "name" ] . "库存不足!");
- }
-
- //编辑sku库存
- $result = model("promotion_exchange")->setDec($condition, "stock", $num);
- if ($result === false)
- return $this->error();
-
- return $this->success($result);
- }
-
- /**
- * 修改标签排序
- * @param $sort
- * @param $id
- * @return array
- */
- public function modifyExchangeSort($sort, $id)
- {
- $res = model('promotion_exchange_goods')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
- return $this->success($res);
- }
-
- /**
- * 兑换商品详情
- * @param array $condition
- * @param int $type
- * @return array
- */
- public function getExchangeDetail($condition = [], $type = 1)
- {
- $alias = 'pe';
- $field = 'peg.type,peg.id as exchange_id, pe.id,pe.type_id as sku_id,peg.type_id as goods_id,pe.pay_type,pe.point, pe.price as exchange_price, pe.limit_num,
- pe.delivery_price,pe.balance,pe.state,pe.content,pe.exchange_goods_id,pe.rule';
- $join = [
- [ 'promotion_exchange_goods peg', 'pe.exchange_goods_id = peg.id', 'inner' ]
- ];
- if ($type == 1) {
- $condition[] = [ 'g.goods_state', '=', 1 ];
- $condition[] = [ 'g.is_delete', '=', 0 ];
-
- $field .= ',sku.site_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,sku.stock,sku.click_num,
- (sku.sale_num + sku.virtual_sale) as sale_num,sku.collect_num,sku.sku_image,
- sku.sku_images,sku.site_id,sku.goods_content,sku.goods_state,sku.is_virtual,
- sku.is_free_shipping,sku.goods_spec_format,sku.goods_attr_format,sku.introduction,
- sku.unit,sku.video_url,sku.evaluate,sku.goods_service_ids,g.goods_image,g.goods_stock,g.goods_name,sku.qr_id,g.stock_show,g.sale_show';
-
- $join[] = [ 'goods_sku sku', 'pe.type_id = sku.sku_id', 'inner' ];
- $join[] = [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ];
- } else if ($type == 2) {
- $join[] = [ 'promotion_coupon_type pct', 'pct.coupon_type_id = peg.type_id', 'inner' ];
- $field .= ',pe.stock,pct.type as coupon_type,pct.discount_limit,pct.image,pct.coupon_name as name,pct.count, pct.lead_count
- ,pct.money, pct.discount, pct.at_least, pct.validity_type,pct.fixed_term,pct.end_time, pct.image';
-// $condition[] = [ 'pct.is_show', '=', 1 ];
-// $condition[] = [ 'pct.is_forbidden', '=', 0 ];
-
- } else if ($type == 3) {
- $field .= ',pe.stock,pe.name,pe.image,pe.balance';
- }
- $info = model('promotion_exchange')->getInfo($condition, $field, $alias, $join);
- if (!empty($info)) {
- if (isset($info[ 'stock' ])) {
- $info[ 'stock' ] = numberFormat($info[ 'stock' ]);
- }
- if (isset($info[ 'sale_num' ])) {
- $info[ 'sale_num' ] = numberFormat($info[ 'sale_num' ]);
- }
- }
- return $this->success($info);
- }
-
- /**
- * 兑换商品详情
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getExchangeSkuList($condition = [], $type = 1)
- {
- $alias = 'pe';
- $field = 'peg.type,peg.id as exchange_id, pe.id,pe.type_id as sku_id,peg.type_id as goods_id,pe.pay_type,pe.point, pe.price as exchange_price, pe.limit_num,
- pe.delivery_price,pe.balance,pe.state,pe.exchange_goods_id,pe.rule';
- $join = [
- [ 'promotion_exchange_goods peg', 'pe.exchange_goods_id = peg.id', 'inner' ]
- ];
- if ($type == 1) {
- $condition[] = [ 'g.goods_state', '=', 1 ];
- $condition[] = [ 'g.is_delete', '=', 0 ];
-
- $field .= ',sku.sku_name,sku.sku_spec_format,sku.price,sku.stock,sku.sku_image,sku.sku_images,sku.goods_spec_format,g.goods_image';
-
- $join[] = [ 'goods_sku sku', 'pe.type_id = sku.sku_id', 'inner' ];
- $join[] = [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ];
- } else if ($type == 2) {
- $join[] = [ 'promotion_coupon_type pct', 'pct.coupon_type_id = peg.type_id', 'inner' ];
- $field .= ',pe.stock,pct.type as coupon_type,pct.discount_limit,pct.image,pct.coupon_name as name,pct.count, pct.lead_count
- ,pct.money, pct.discount, pct.at_least, pct.validity_type,pct.fixed_term,pct.end_time, pct.image';
-
- } else if ($type == 3) {
- $field .= ',pe.stock,pe.name,pe.image,pe.balance';
- }
- $list = model('promotion_exchange')->getList($condition, $field, '', $alias, $join);
- foreach ($list as $k => $v) {
- if (isset($v[ 'stock' ])) {
- $list[ $k ][ 'stock' ] = numberFormat($list[ $k ][ 'stock' ]);
- }
- }
- return $this->success($list);
- }
-
- /**
- * 判断规格值是否禁用
- * @param $id
- * @param $site_id
- * @param string $goods_spec_format
- * @return int|mixed
- */
- public function getGoodsSpecFormat($id, $site_id, $goods_spec_format = '')
- {
- //获取活动参与的商品sku_ids
- $sku_ids = model('promotion_exchange')->getColumn([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'type_id');
- $goods_model = new Goods();
- $res = $goods_model->getGoodsSpecFormat($sku_ids, $goods_spec_format);
- return $res;
- }
-
+ [
+ 'name' => 'goods',
+ 'title' => '兑换商品',
+ ],
+ 2 => [
+ 'name' => 'coupon',
+ 'title' => '兑换优惠券',
+ ],
+ 3 => [
+ 'name' => 'balance',
+ 'title' => '兑换红包',
+ ],
+ ];
+
+ /**
+ * 添加积分兑换
+ * @param array $data
+ */
+ public function addExchange($data)
+ {
+
+ model('promotion_exchange')->startTrans();
+ try {
+ $exchange_goods_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'state' => $data[ 'state' ],
+ 'create_time' => time(),
+ ];
+ if ($data[ 'type' ] == 1) {
+ $exchange_goods = $data[ 'goods_data' ];
+
+ foreach ($exchange_goods as $k => $v) {
+ $exist = model('promotion_exchange_goods')->getInfo([ [ 'type', '=', 1 ], [ 'type_id', '=', $v[ 'goods_id' ] ] ], 'id');
+ if (!empty($exist)) {
+ return $this->error('', '商品已存在,请不要重复添加');
+ }
+ $sku_model = new Goods();
+ $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $v[ 'sku_list' ][ 0 ][ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
+ $exchange_goods_data[ 'type_id' ] = $v[ 'goods_id' ];
+ $exchange_goods_data[ 'name' ] = $sku_info[ 'sku_name' ];
+ $exchange_goods_data[ 'image' ] = $sku_info[ 'sku_image' ];
+ $exchange_goods_data[ 'point' ] = $v[ 'sku_list' ][ 0 ][ 'point' ];
+ $exchange_goods_data[ 'price' ] = $v[ 'sku_list' ][ 0 ][ 'exchange_price' ];
+ $exchange_goods_data[ 'content' ] = $sku_info[ 'goods_content' ];
+ $exchange_goods_data[ 'rule' ] = $data[ 'rule' ];
+ $exchange_goods_data[ 'pay_type' ] = $v[ 'sku_list' ][ 0 ][ 'exchange_price' ] ? 1 : 0;
+ $exchange_goods_id = model('promotion_exchange_goods')->add($exchange_goods_data);
+
+ foreach ($v[ 'sku_list' ] as $index => $item) {
+ $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
+ $exchange_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'exchange_goods_id' => $exchange_goods_id,
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'type_id' => $item[ 'sku_id' ],
+ 'state' => $data[ 'state' ],
+ 'rule' => $data[ 'rule' ],
+ 'name' => $sku_info[ 'sku_name' ],
+ 'image' => $sku_info[ 'sku_image' ],
+ 'stock' => $sku_info[ 'stock' ],
+ 'pay_type' => empty($item[ 'exchange_price' ]) ? 0 : 1,
+ 'point' => $item[ 'point' ],
+ 'market_price' => $sku_info[ 'price' ],
+ 'price' => $item[ 'exchange_price' ],
+ 'limit_num' => $item[ 'limit_num' ],
+ 'create_time' => time(),
+ 'content' => $sku_info[ 'goods_content' ],
+
+ 'is_free_shipping' => $data[ 'is_free_shipping' ], //是否免邮(0不免邮 1免邮)
+ 'delivery_type' => $data[ 'delivery_type' ] ?? 1, //运费类型( 0 固定运费 1运费模板 2按照商品)
+ 'shipping_template' => $data[ 'shipping_template' ], //运费模板
+ 'delivery_price' => $data[ 'delivery_price' ] ?? 0 //运费
+ ];
+ model('promotion_exchange')->add($exchange_data);
+
+ }
+ }
+ } elseif ($data[ 'type' ] == 2) {
+ $exist = model('promotion_exchange_goods')->getInfo([ [ 'type', '=', 2 ], [ 'type_id', '=', $data[ 'coupon_type_id' ] ] ], 'id');
+ if (!empty($exist)) {
+ return $this->error('', '该优惠券已存在,请不要重复添加');
+ }
+
+ $coupon = new Coupon();
+ $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $data[ 'coupon_type_id' ] ] ], 'coupon_type_id,coupon_name,money,count,image,status,type,discount')[ 'data' ];
+
+ $exchange_goods_data[ 'type_id' ] = $data[ 'coupon_type_id' ];
+ $exchange_goods_data[ 'name' ] = $coupon_type_info[ 'coupon_name' ];
+ $exchange_goods_data[ 'image' ] = $coupon_type_info[ 'image' ];
+ $exchange_goods_data[ 'point' ] = $data[ 'point' ];
+ $exchange_goods_data[ 'content' ] = $data[ 'content' ];
+
+ $exchange_goods_id = model('promotion_exchange_goods')->add($exchange_goods_data);
+
+ $exchange_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'exchange_goods_id' => $exchange_goods_id,
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'state' => $data[ 'state' ],
+ 'type_id' => $data[ 'coupon_type_id' ],
+ 'name' => $coupon_type_info[ 'coupon_name' ],
+ 'image' => $coupon_type_info[ 'image' ],
+ 'stock' => $data[ 'stock' ],
+ 'pay_type' => 0,
+ 'point' => $data[ 'point' ],
+ 'create_time' => time(),
+ 'content' => $data[ 'content' ],
+ ];
+ if ($coupon_type_info[ 'type' ] == 'reward') {
+ $exchange_data[ 'market_price' ] = $coupon_type_info[ 'money' ];
+ } elseif ($coupon_type_info[ 'type' ] == 'discount') {
+ $exchange_data[ 'market_price' ] = $coupon_type_info[ 'discount' ];
+ }
+
+ model('promotion_exchange')->add($exchange_data);
+
+ } elseif ($data[ 'type' ] == 3) {
+
+ $exchange_goods_data[ 'name' ] = $data[ 'name' ];
+ $exchange_goods_data[ 'image' ] = $data[ 'image' ];
+ $exchange_goods_data[ 'point' ] = $data[ 'point' ];
+ $exchange_goods_data[ 'balance' ] = $data[ 'balance' ];
+ $exchange_goods_data[ 'content' ] = $data[ 'content' ];
+
+ $exchange_goods_id = model('promotion_exchange_goods')->add($exchange_goods_data);
+
+ $exchange_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'exchange_goods_id' => $exchange_goods_id,
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'state' => $data[ 'state' ],
+ 'name' => $data[ 'name' ],
+ 'image' => $data[ 'image' ],
+ 'stock' => $data[ 'stock' ],
+ 'pay_type' => 0,
+ 'point' => $data[ 'point' ],
+ 'balance' => $data[ 'balance' ],
+ 'create_time' => time(),
+ 'content' => $data[ 'content' ],
+ ];
+
+ model('promotion_exchange')->add($exchange_data);
+ }
+
+ model('promotion_exchange')->commit();
+ return $this->success();
+ } catch (\Exception $e) {
+ model('promotion_exchange')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
+ /**
+ * 编辑积分兑换
+ * @param array $data
+ */
+ public function editExchange($data)
+ {
+ model('promotion_exchange')->startTrans();
+ try {
+ $exchange_goods_id = $data[ 'id' ];
+ if ($data[ 'type' ] == 1) {
+ $goods_data = $data[ 'goods_data' ];
+
+ $sku_model = new Goods();
+ $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $goods_data[ 0 ][ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
+ $exchange_goods_data = [
+ 'modify_time' => time(),
+ 'pay_type' => $goods_data[ 0 ][ 'exchange_price' ] ? 1 : 0,
+ ];
+ $exchange_goods_data[ 'name' ] = $sku_info[ 'sku_name' ];
+ $exchange_goods_data[ 'image' ] = $sku_info[ 'sku_image' ];
+ $exchange_goods_data[ 'point' ] = $goods_data[ 0 ][ 'point' ];
+ $exchange_goods_data[ 'price' ] = $goods_data[ 0 ][ 'exchange_price' ];
+ $exchange_goods_data[ 'content' ] = $sku_info[ 'goods_content' ];
+ $exchange_goods_data[ 'rule' ] = $data[ 'rule' ];
+ $exchange_goods_data[ 'state' ] = $data[ 'state' ];
+ model('promotion_exchange_goods')->update($exchange_goods_data, [ [ 'id', '=', $exchange_goods_id ] ]);
+
+ model('promotion_exchange')->delete([ [ 'exchange_goods_id', '=', $exchange_goods_id ] ]);
+
+ foreach ($goods_data as $index => $item) {
+ $sku_info = $sku_model->getGoodsSkuInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'sku_name,sku_image,price,stock,goods_content')[ 'data' ];
+ $exchange_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'exchange_goods_id' => $exchange_goods_id,
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'type_id' => $item[ 'sku_id' ],
+ 'state' => $data[ 'state' ],
+ 'rule' => $data[ 'rule' ],
+ 'name' => $sku_info[ 'sku_name' ],
+ 'image' => $sku_info[ 'sku_image' ],
+ 'stock' => $sku_info[ 'stock' ],
+ 'pay_type' => empty($item[ 'exchange_price' ]) ? 0 : 1,
+ 'point' => $item[ 'point' ],
+ 'market_price' => $sku_info[ 'price' ],
+ 'price' => $item[ 'exchange_price' ],
+ 'limit_num' => $item[ 'limit_num' ],
+ 'create_time' => time(),
+ 'content' => $sku_info[ 'goods_content' ],
+
+ 'is_free_shipping' => $data[ 'is_free_shipping' ], //是否免邮(0不免邮 1免邮)
+ 'delivery_type' => $data[ 'delivery_type' ] ?? 1, //运费类型( 0 固定运费 1运费模板 2按照商品)
+ 'shipping_template' => $data[ 'shipping_template' ], //运费模板
+ 'delivery_price' => $data[ 'delivery_price' ] ?? 0 //运费
+
+ ];
+ model('promotion_exchange')->add($exchange_data);
+ }
+
+ } else if ($data[ 'type' ] == 2) {
+ $coupon = new Coupon();
+ $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $data[ 'coupon_type_id' ] ] ], 'coupon_type_id,coupon_name,money,count,image,status,type,discount')[ 'data' ];
+ $exchange_goods_data = [];
+ $exchange_goods_data[ 'type_id' ] = $data[ 'coupon_type_id' ];
+ $exchange_goods_data[ 'name' ] = $coupon_type_info[ 'coupon_name' ];
+ $exchange_goods_data[ 'image' ] = $coupon_type_info[ 'image' ];
+ $exchange_goods_data[ 'point' ] = $data[ 'point' ];
+ $exchange_goods_data[ 'content' ] = $data[ 'content' ];
+ $exchange_goods_data[ 'state' ] = $data[ 'state' ];
+
+ model('promotion_exchange_goods')->update($exchange_goods_data, [ [ 'id', '=', $exchange_goods_id ] ]);
+ $exchange_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'exchange_goods_id' => $exchange_goods_id,
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'state' => $data[ 'state' ],
+ 'type_id' => $data[ 'coupon_type_id' ],
+ 'name' => $coupon_type_info[ 'coupon_name' ],
+ 'image' => $coupon_type_info[ 'image' ],
+ 'stock' => $data[ 'stock' ],
+ 'pay_type' => 0,
+ 'point' => $data[ 'point' ],
+ 'create_time' => time(),
+ 'content' => $data[ 'content' ],
+ ];
+ if ($coupon_type_info[ 'type' ] == 'reward') {
+ $exchange_data[ 'market_price' ] = $coupon_type_info[ 'money' ];
+ } elseif ($coupon_type_info[ 'type' ] == 'discount') {
+ $exchange_data[ 'market_price' ] = $coupon_type_info[ 'discount' ];
+ }
+ model('promotion_exchange')->delete([ [ 'exchange_goods_id', '=', $exchange_goods_id ] ]);
+ model('promotion_exchange')->add($exchange_data);
+
+ } else if ($data[ 'type' ] == 3) {
+ $exchange_goods_data = [];
+ $exchange_goods_data[ 'name' ] = $data[ 'name' ];
+ $exchange_goods_data[ 'image' ] = $data[ 'image' ];
+ $exchange_goods_data[ 'point' ] = $data[ 'point' ];
+ $exchange_goods_data[ 'balance' ] = $data[ 'balance' ];
+ $exchange_goods_data[ 'content' ] = $data[ 'content' ];
+ $exchange_goods_data[ 'state' ] = $data[ 'state' ];
+
+ $exchange_goods_info = model('promotion_exchange_goods')->getInfo([ [ 'id', '=', $exchange_goods_id ] ]);
+ if (!empty($exchange_goods_info[ 'image' ]) && !empty($data[ 'image' ]) && $exchange_goods_info[ 'image' ] != $data[ 'image' ]) {
+ $upload_model = new Upload();
+ $upload_model->deletePic($exchange_goods_info[ 'image' ], $data[ 'site_id' ]);
+ }
+
+ model('promotion_exchange_goods')->update($exchange_goods_data, [ [ 'id', '=', $exchange_goods_id ] ]);
+
+ $exchange_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'exchange_goods_id' => $exchange_goods_id,
+ 'type' => $data[ 'type' ],
+ 'type_name' => $data[ 'type_name' ],
+ 'state' => $data[ 'state' ],
+ 'name' => $data[ 'name' ],
+ 'image' => $data[ 'image' ],
+ 'stock' => $data[ 'stock' ],
+ 'pay_type' => 0,
+ 'point' => $data[ 'point' ],
+ 'balance' => $data[ 'balance' ],
+ 'create_time' => time(),
+ 'content' => $data[ 'content' ],
+ ];
+ model('promotion_exchange')->delete([ [ 'exchange_goods_id', '=', $exchange_goods_id ] ]);
+ model('promotion_exchange')->add($exchange_data);
+
+ }
+
+ model('promotion_exchange')->commit();
+ return $this->success();
+ } catch (\Exception $e) {
+ model('promotion_exchange')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
+ /**
+ * 删除积分兑换
+ * @param string $ids
+ */
+ public function deleteExchange($ids)
+ {
+ $list = model("promotion_exchange")->getList([ [ 'exchange_goods_id', 'in', $ids ] ]);
+ if ($list) {
+ foreach ($list as $k => $v) {
+ if (!empty($v[ 'image' ])) {
+ $upload_model = new Upload();
+ $upload_model->deletePic($v[ 'image' ], $v[ 'site_id' ]);
+ }
+ }
+ }
+
+ model("promotion_exchange")->delete([ [ 'exchange_goods_id', 'in', $ids ] ]);
+ model("promotion_exchange_goods")->delete([ [ 'id', 'in', $ids ] ]);
+ return $this->success();
+ }
+
+ /**
+ * 获取积分兑换信息
+ * @param int $id
+ */
+ public function getExchangeInfo($id, $field = '*', $sku_id = 0)
+ {
+
+ $condition = [
+ [ 'exchange_goods_id', '=', $id ]
+ ];
+ if ($sku_id) $condition[] = [ 'type_id', '=', $sku_id ];
+
+ $info = model("promotion_exchange")->getInfo($condition, $field);
+ if (!empty($info) && !empty($info[ 'type' ])) {
+ switch ( $info[ 'type' ] ) {
+ case 1:
+ //商品
+ $goods = new Goods();
+ $goods_sku_info = $goods->getGoodsSkuInfo([ [ 'sku_id', '=', $info[ 'type_id' ], [ 'goods_state', '=', 1 ], [ 'is_delete', '=', 0 ] ] ], 'sku_id,sku_name,stock')[ 'data' ];
+ if (!empty($goods_sku_info)) {
+ $goods_sku_info[ 'stock' ] = numberFormat($goods_sku_info[ 'stock' ]);
+ $info = array_merge($info, $goods_sku_info);
+ } else {
+ $info = [];
+ }
+ break;
+ case 2:
+ //优惠券
+ $coupon = new Coupon();
+ $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $info[ 'type_id' ] ] ], 'type as coupon_type,discount_limit,count,lead_count')[ 'data' ];
+
+ if (!empty($coupon_type_info)) {
+ $info = array_merge($info, $coupon_type_info);
+ } else {
+ $info = [];
+ }
+ break;
+ case 3:
+ //余额红包
+ break;
+ }
+ }
+ return $this->success($info);
+ }
+
+ /**
+ * 获取积分兑换商品详情
+ * @param $id
+ * @param $site_id
+ * @return array
+ */
+ public function getExchangeGoodsDetail($id, $site_id)
+ {
+ $info = model("promotion_exchange_goods")->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'id,type,type_name,type_id,name,image,pay_type,point,price,delivery_price,balance,state,content,rule');
+ // 兑换类型,1:商品,2:优惠券,3:红包
+ switch ( $info[ 'type' ] ) {
+ case 1:
+ //商品
+ $goods_sku = model('goods_sku')->getList([ [ 'goods_id', '=', $info[ 'type_id' ] ], [ 'is_delete', '=', 0 ], [ 'goods_state', '=', 1 ] ], 'stock, price,sku_id,sku_name,discount_price,stock as goods_stock,sku_image,sku_images,goods_id,site_id,goods_content');
+ $exchange_list = model("promotion_exchange")->getList([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'limit_num, id,type,type_name,type_id,name,image,pay_type,point,price,delivery_price,balance,state,content,delivery_type,is_free_shipping,shipping_template,rule');
+
+ foreach ($goods_sku as $k => $v) {
+ $goods_sku[ $k ][ 'is_select' ] = 0;
+ $goods_sku[ $k ][ 'exchange_price' ] = 0;
+ $goods_sku[ $k ][ 'point' ] = 0;
+ $goods_sku[ $k ][ 'limit_num' ] = 0;
+ $goods_sku[ $k ][ 'stock' ] = numberFormat($goods_sku[ $k ][ 'stock' ]);
+ $goods_sku[ $k ][ 'goods_stock' ] = numberFormat($goods_sku[ $k ][ 'goods_stock' ]);
+ foreach ($exchange_list as $key => $val) {
+ if ($val[ 'type_id' ] == $v[ 'sku_id' ]) {
+ $goods_sku[ $k ][ 'is_select' ] = 1;
+ $goods_sku[ $k ][ 'exchange_price' ] = $val[ 'price' ];
+ $goods_sku[ $k ][ 'limit_num' ] = $val[ 'limit_num' ];
+ $goods_sku[ $k ][ 'point' ] = $val[ 'point' ];
+ }
+ }
+ }
+
+ $info[ 'goods_sku' ] = $goods_sku;
+ $info[ 'exchange_goods' ] = $exchange_list;
+
+ break;
+ case 2:
+ //优惠券
+ $coupon = new Coupon();
+ $coupon_type_info = $coupon->getCouponTypeInfo([ [ 'coupon_type_id', '=', $info[ 'type_id' ] ] ], 'coupon_type_id,coupon_name,money,count as stock,status,lead_count,max_fetch,at_least,end_time,validity_type,fixed_term,goods_type,is_limit,type as coupon_type,discount_limit,discount')[ 'data' ];
+ $exchange_info = model("promotion_exchange")->getInfo([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'market_price,stock');
+ if (!empty($coupon_type_info)) {
+ $info = array_merge($info, $coupon_type_info);
+ } else {
+ $info = [];
+ }
+ $info = array_merge($info, $exchange_info);
+
+ break;
+ case 3:
+ //余额红包
+ $exchange_info = model("promotion_exchange")->getInfo([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'stock');
+ if (!empty($exchange_info)) {
+ $info = array_merge($info, $exchange_info);
+ } else {
+ $info = [];
+ }
+ break;
+ }
+ if (!empty($info)) {
+ return $this->success($info);
+ } else {
+ return $this->error('', '该兑换物品已失效');
+ }
+ }
+
+ /**
+ * 获取积分兑换列表
+ * @param array $condition
+ * @param string $field
+ * @param string $order
+ * @param null $limit
+ * @param string $alias
+ * @param array $join
+ * @return array
+ */
+ public function getExchangeList($condition = [], $field = '*', $order = '', $limit = null, $alias = '', $join = [])
+ {
+ $list = model('promotion_exchange')->getList($condition, $field, $order, $alias, $join, '', $limit);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取积分兑换列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @param string $alias
+ * @param array $join
+ * @return array
+ */
+ public function getExchangePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*', $alias = '', $join = [])
+ {
+ $list = model('promotion_exchange')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取积分兑换列表
+ * @param array $condition
+ * @param string $field
+ * @param string $order
+ * @param null $limit
+ * @return array
+ */
+ public function getExchangeGoodsList($condition = [], $field = '*', $order = '', $limit = null)
+ {
+ $list = model('promotion_exchange_goods')->getList($condition, $field, $order, '', '', '', $limit);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取积分兑换列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @param string $alias
+ * @param array $join
+ * @return array
+ */
+ public function getExchangeGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*', $alias = '', $join = [])
+ {
+ $list = model('promotion_exchange_goods')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
+ if(!empty($list['list']))
+ {
+ $goods_id_array = [];
+ foreach ($list['list'] as $k => $v)
+ {
+ if($v['type'] == 1)
+ {
+ $goods_id_array[] = $v['type_id'];
+ }
+ }
+ if(!empty($goods_id_array))
+ {
+ $goods_array = [];
+ $goods_ids = implode(",", $goods_id_array);
+ $goods_list = model('goods')->getList([ [ 'goods_id', 'in', $goods_ids ], ['is_delete', '=', 0] ], "goods_id, goods_name, is_delete");
+ if(!empty($goods_list))
+ {
+ $key = array_column($goods_list, 'goods_id');
+ $goods_array = array_combine($key, $goods_list);
+ }
+
+ }
+ foreach ($list[ 'list' ] as $k => $v) {
+ if ($v[ 'type' ] == 1) {
+ $goods_info = $goods_array[$v['type_id']] ?? [];
+ if (empty($goods_info)) {
+ unset($list[ 'list' ][ $k ]);
+ } else {
+ if ($goods_info[ 'is_delete' ] == 1) {
+ unset($list[ 'list' ][ $k ]);
+ } else {
+ $list[ 'list' ][ $k ][ 'g_name' ] = $goods_info[ 'goods_name' ];
+ }
+ }
+
+ }
+ }
+ }
+
+ return $this->success($list);
+ }
+
+ /**
+ * 增加库存
+ * @param $param
+ */
+ public function incStock($param)
+ {
+ $condition = array (
+ [ "id", "=", $param[ "id" ] ]
+ );
+ $num = $param[ "num" ];
+ $info = model("promotion_exchange")->getInfo($condition, "stock, name");
+ if (empty($info))
+ return $this->error(-1, "");
+
+ //编辑sku库存
+ $result = model("promotion_exchange")->setInc($condition, "stock", $num);
+
+ return $this->success($result);
+ }
+
+ /**
+ * 减少库存
+ * @param $param
+ */
+ public function decStock($param)
+ {
+ $condition = array (
+ [ "id", "=", $param[ "id" ] ]
+ );
+ $num = $param[ "num" ];
+
+ $info = model("promotion_exchange")->getInfo($condition, "stock, name, type");
+ if (empty($info))
+ return $this->error();
+
+ if ($info[ 'type' ] == 2 && $info[ 'stock' ] == -1) {
+ return $this->success();
+ }
+
+ if ($info[ "stock" ] < 0) {
+ return $this->error('', $info[ "name" ] . "库存不足!");
+ }
+
+ //编辑sku库存
+ $result = model("promotion_exchange")->setDec($condition, "stock", $num);
+ if ($result === false)
+ return $this->error();
+
+ return $this->success($result);
+ }
+
+ /**
+ * 修改标签排序
+ * @param $sort
+ * @param $id
+ * @return array
+ */
+ public function modifyExchangeSort($sort, $id)
+ {
+ $res = model('promotion_exchange_goods')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
+ return $this->success($res);
+ }
+
+ /**
+ * 兑换商品详情
+ * @param array $condition
+ * @param int $type
+ * @return array
+ */
+ public function getExchangeDetail($condition = [], $type = 1)
+ {
+ $alias = 'pe';
+ $field = 'peg.type,peg.id as exchange_id, pe.id,pe.type_id as sku_id,peg.type_id as goods_id,pe.pay_type,pe.point, pe.price as exchange_price, pe.limit_num,
+ pe.delivery_price,pe.balance,pe.state,pe.content,pe.exchange_goods_id,pe.rule';
+ $join = [
+ [ 'promotion_exchange_goods peg', 'pe.exchange_goods_id = peg.id', 'inner' ]
+ ];
+ if ($type == 1) {
+ $condition[] = [ 'g.goods_state', '=', 1 ];
+ $condition[] = [ 'g.is_delete', '=', 0 ];
+
+ $field .= ',sku.site_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,sku.stock,sku.click_num,
+ (sku.sale_num + sku.virtual_sale) as sale_num,sku.collect_num,sku.sku_image,
+ sku.sku_images,sku.site_id,sku.goods_content,sku.goods_state,sku.is_virtual,
+ sku.is_free_shipping,sku.goods_spec_format,sku.goods_attr_format,sku.introduction,
+ sku.unit,sku.video_url,sku.evaluate,sku.goods_service_ids,g.goods_image,g.goods_stock,g.goods_name,sku.qr_id,g.stock_show,g.sale_show';
+
+ $join[] = [ 'goods_sku sku', 'pe.type_id = sku.sku_id', 'inner' ];
+ $join[] = [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ];
+ } else if ($type == 2) {
+ $join[] = [ 'promotion_coupon_type pct', 'pct.coupon_type_id = peg.type_id', 'inner' ];
+ $field .= ',pe.stock,pct.type as coupon_type,pct.discount_limit,pct.image,pct.coupon_name as name,pct.count, pct.lead_count
+ ,pct.money, pct.discount, pct.at_least, pct.validity_type,pct.fixed_term,pct.end_time, pct.image';
+// $condition[] = [ 'pct.is_show', '=', 1 ];
+// $condition[] = [ 'pct.is_forbidden', '=', 0 ];
+
+ } else if ($type == 3) {
+ $field .= ',pe.stock,pe.name,pe.image,pe.balance';
+ }
+ $info = model('promotion_exchange')->getInfo($condition, $field, $alias, $join);
+ if (!empty($info)) {
+ if (isset($info[ 'stock' ])) {
+ $info[ 'stock' ] = numberFormat($info[ 'stock' ]);
+ }
+ if (isset($info[ 'sale_num' ])) {
+ $info[ 'sale_num' ] = numberFormat($info[ 'sale_num' ]);
+ }
+ }
+ return $this->success($info);
+ }
+
+ /**
+ * 兑换商品详情
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getExchangeSkuList($condition = [], $type = 1)
+ {
+ $alias = 'pe';
+ $field = 'peg.type,peg.id as exchange_id, pe.id,pe.type_id as sku_id,peg.type_id as goods_id,pe.pay_type,pe.point, pe.price as exchange_price, pe.limit_num,
+ pe.delivery_price,pe.balance,pe.state,pe.exchange_goods_id,pe.rule';
+ $join = [
+ [ 'promotion_exchange_goods peg', 'pe.exchange_goods_id = peg.id', 'inner' ]
+ ];
+ if ($type == 1) {
+ $condition[] = [ 'g.goods_state', '=', 1 ];
+ $condition[] = [ 'g.is_delete', '=', 0 ];
+
+ $field .= ',sku.sku_name,sku.sku_spec_format,sku.price,sku.stock,sku.sku_image,sku.sku_images,sku.goods_spec_format,g.goods_image';
+
+ $join[] = [ 'goods_sku sku', 'pe.type_id = sku.sku_id', 'inner' ];
+ $join[] = [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ];
+ } else if ($type == 2) {
+ $join[] = [ 'promotion_coupon_type pct', 'pct.coupon_type_id = peg.type_id', 'inner' ];
+ $field .= ',pe.stock,pct.type as coupon_type,pct.discount_limit,pct.image,pct.coupon_name as name,pct.count, pct.lead_count
+ ,pct.money, pct.discount, pct.at_least, pct.validity_type,pct.fixed_term,pct.end_time, pct.image';
+
+ } else if ($type == 3) {
+ $field .= ',pe.stock,pe.name,pe.image,pe.balance';
+ }
+ $list = model('promotion_exchange')->getList($condition, $field, '', $alias, $join);
+ foreach ($list as $k => $v) {
+ if (isset($v[ 'stock' ])) {
+ $list[ $k ][ 'stock' ] = numberFormat($list[ $k ][ 'stock' ]);
+ }
+ }
+ return $this->success($list);
+ }
+
+ /**
+ * 判断规格值是否禁用
+ * @param $id
+ * @param $site_id
+ * @param string $goods_spec_format
+ * @return int|mixed
+ */
+ public function getGoodsSpecFormat($id, $site_id, $goods_spec_format = '')
+ {
+ //获取活动参与的商品sku_ids
+ $sku_ids = model('promotion_exchange')->getColumn([ [ 'exchange_goods_id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'type_id');
+ $goods_model = new Goods();
+ $res = $goods_model->getGoodsSpecFormat($sku_ids, $goods_spec_format);
+ return $res;
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/model/share/WchatShare.php b/src/addon/pointexchange/model/share/WchatShare.php
index 12e6c8cb9..512831ae4 100644
--- a/src/addon/pointexchange/model/share/WchatShare.php
+++ b/src/addon/pointexchange/model/share/WchatShare.php
@@ -1,155 +1,146 @@
- '积分商城',
- 'config_key' => 'WCHAT_SHARE_CONFIG_POINTEXCHANGE_LIST',
- 'path' => [ '/pages_promotion/point/list' ],
- 'method_prefix' => 'goodsList',
- ],
- [
- 'title' => '积分商品',
- 'config_key' => 'WCHAT_SHARE_CONFIG_POINTEXCHANGE_DETAIL',
- 'path' => [ '/pages_promotion/point/detail' ],
- 'method_prefix' => 'goodsDetail',
- ],
- ];
-
- protected $sort = 6;
-
- /**
- * 积分商城列表
- * @param $param
- * @return array
- */
- protected function goodsListShareData($param)
- {
- //跳转路径
- $link = $this->getShareLink($param);
- $config_data = $this->goodsListShareConfig($param)[ 'value' ];
-
- $data = [
- 'link' => $link,
- 'desc' => $config_data[ 'desc' ],
- 'imgUrl' => $config_data[ 'imgUrl' ],
- 'title' => $config_data[ 'title' ]
- ];
- return [
- 'permission' => [
- 'hideOptionMenu' => false,
- 'hideMenuItems' => [],
- ],
- 'data' => $data,//分享内容
- ];
- }
-
- /**
- * 积分商城列表分享配置
- * @param $param
- * @return array
- */
- public function goodsListShareConfig($param)
- {
- $site_id = $param[ 'site_id' ];
- $config = $param[ 'config' ];
-
- $config_model = new ConfigModel();
- $data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
- if (empty($data[ 'value' ])) {
- $data[ 'value' ] = [
- 'title' => "积分商城",
- 'desc' => "积分兑换更优惠哦",
- 'imgUrl' => ''
- ];
- }
- if (empty($data[ 'value' ][ 'imgUrl' ])) {
- $data[ 'value' ][ 'imgUrl' ] = img('addon/pointexchange/icon.png');
- }
- return [
- 'value' => $data[ 'value' ],
- ];
- }
-
- /**
- * 积分商城详情
- * @param $param
- * @return array
- */
- protected function goodsDetailShareData($param)
- {
- $site_id = $param[ 'site_id' ] ?? 0;
- parse_str(parse_url($param[ 'url' ])[ 'query' ] ?? '', $query);
-
- if (isset($query[ 'id' ])) {
- $id = $query[ 'id' ];
- $exchange_model = new ExchangeModel();
- $exchange_info = $exchange_model->getExchangeInfo($id, 'type, type_id');
- $exchange_info = $exchange_info[ 'data' ];
- $condition = [
- [ 'peg.id', '=', $id ],
- [ 'peg.site_id', '=', $site_id ],
- [ 'peg.state', '=', 1 ],
- ];
- $exchange_detail = $exchange_model->getExchangeDetail($condition, $exchange_info[ 'type' ])[ 'data' ];
- if (!empty($exchange_detail)) {
- $image_url = '';
- $title = '';
- switch ( $exchange_detail[ 'type' ] ) {
- case 1://商品
- $title = $exchange_detail[ 'sku_name' ];
- $image_url = $exchange_detail[ 'sku_image' ];
- break;
- case 2://优惠券
- case 3://红包
- $title = $exchange_detail[ 'name' ];
- $image_url = $exchange_detail[ 'image' ];
- break;
- }
- if ($image_url) {
- $image_url = img($image_url);
- } else {
- $image_url = $this->getDefaultShareIcon();
- }
- $exchange_condition = [];
- if ($exchange_detail[ 'point' ] > 0) $exchange_condition[] = "{$exchange_detail['point']}积分";
- if ($exchange_detail[ 'exchange_price' ] > 0) $exchange_condition[] = "¥{$exchange_detail['exchange_price']}";
- $desc = "仅需" . join("+", $exchange_condition) . "即可兑换";
- $link = $this->getShareLink($param);
-
- $data = [
- 'title' => $title,
- 'desc' => $desc,
- 'link' => $link,
- 'imgUrl' => $image_url,
- ];
- return [
- 'permission' => [
- 'hideOptionMenu' => false,
- 'hideMenuItems' => [],
- ],
- 'data' => $data,//分享内容
- ];
- }
- }
- }
-}
+ '积分商城',
+ 'config_key' => 'WCHAT_SHARE_CONFIG_POINTEXCHANGE_LIST',
+ 'path' => [ '/pages_promotion/point/list' ],
+ 'method_prefix' => 'goodsList',
+ ],
+ [
+ 'title' => '积分商品',
+ 'config_key' => 'WCHAT_SHARE_CONFIG_POINTEXCHANGE_DETAIL',
+ 'path' => [ '/pages_promotion/point/detail' ],
+ 'method_prefix' => 'goodsDetail',
+ ],
+ ];
+
+ protected $sort = 6;
+
+ /**
+ * 积分商城列表
+ * @param $param
+ * @return array
+ */
+ protected function goodsListShareData($param)
+ {
+ //跳转路径
+ $link = $this->getShareLink($param);
+ $config_data = $this->goodsListShareConfig($param)[ 'value' ];
+
+ $data = [
+ 'link' => $link,
+ 'desc' => $config_data[ 'desc' ],
+ 'imgUrl' => $config_data[ 'imgUrl' ],
+ 'title' => $config_data[ 'title' ]
+ ];
+ return [
+ 'permission' => [
+ 'hideOptionMenu' => false,
+ 'hideMenuItems' => [],
+ ],
+ 'data' => $data,//分享内容
+ ];
+ }
+
+ /**
+ * 积分商城列表分享配置
+ * @param $param
+ * @return array
+ */
+ public function goodsListShareConfig($param)
+ {
+ $site_id = $param[ 'site_id' ];
+ $config = $param[ 'config' ];
+
+ $config_model = new ConfigModel();
+ $data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
+ if (empty($data[ 'value' ])) {
+ $data[ 'value' ] = [
+ 'title' => "积分商城",
+ 'desc' => "积分兑换更优惠哦",
+ 'imgUrl' => ''
+ ];
+ }
+ if (empty($data[ 'value' ][ 'imgUrl' ])) {
+ $data[ 'value' ][ 'imgUrl' ] = img('addon/pointexchange/icon.png');
+ }
+ return [
+ 'value' => $data[ 'value' ],
+ ];
+ }
+
+ /**
+ * 积分商城详情
+ * @param $param
+ * @return array
+ */
+ protected function goodsDetailShareData($param)
+ {
+ $site_id = $param[ 'site_id' ] ?? 0;
+ parse_str(parse_url($param[ 'url' ])[ 'query' ] ?? '', $query);
+
+ if (isset($query[ 'id' ])) {
+ $id = $query[ 'id' ];
+ $exchange_model = new ExchangeModel();
+ $exchange_info = $exchange_model->getExchangeInfo($id, 'type, type_id');
+ $exchange_info = $exchange_info[ 'data' ];
+ $condition = [
+ [ 'peg.id', '=', $id ],
+ [ 'peg.site_id', '=', $site_id ],
+ [ 'peg.state', '=', 1 ],
+ ];
+ $exchange_detail = $exchange_model->getExchangeDetail($condition, $exchange_info[ 'type' ])[ 'data' ];
+ if (!empty($exchange_detail)) {
+ $image_url = '';
+ $title = '';
+ switch ( $exchange_detail[ 'type' ] ) {
+ case 1://商品
+ $title = $exchange_detail[ 'sku_name' ];
+ $image_url = $exchange_detail[ 'sku_image' ];
+ break;
+ case 2://优惠券
+ case 3://红包
+ $title = $exchange_detail[ 'name' ];
+ $image_url = $exchange_detail[ 'image' ];
+ break;
+ }
+ if ($image_url) {
+ $image_url = img($image_url);
+ } else {
+ $image_url = $this->getDefaultShareIcon();
+ }
+ $exchange_condition = [];
+ if ($exchange_detail[ 'point' ] > 0) $exchange_condition[] = "{$exchange_detail['point']}积分";
+ if ($exchange_detail[ 'exchange_price' ] > 0) $exchange_condition[] = "¥{$exchange_detail['exchange_price']}";
+ $desc = "仅需" . join("+", $exchange_condition) . "即可兑换";
+ $link = $this->getShareLink($param);
+
+ $data = [
+ 'title' => $title,
+ 'desc' => $desc,
+ 'link' => $link,
+ 'imgUrl' => $image_url,
+ ];
+ return [
+ 'permission' => [
+ 'hideOptionMenu' => false,
+ 'hideMenuItems' => [],
+ ],
+ 'data' => $data,//分享内容
+ ];
+ }
+ }
+ }
+}
diff --git a/src/addon/pointexchange/model/share/WeappShare.php b/src/addon/pointexchange/model/share/WeappShare.php
index 16b31fb8a..195f68125 100644
--- a/src/addon/pointexchange/model/share/WeappShare.php
+++ b/src/addon/pointexchange/model/share/WeappShare.php
@@ -1,15 +1,7 @@
isJson()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', '');
- $type = input('type', '');
- $state = input('state', '');
- $sort = input('sort', 'asc');
- $condition[] = [ 'peg.site_id', '=', $this->site_id ];
- if ($search_text) {
- $condition[] = [ 'peg.name', 'like', '%' . $search_text . '%' ];
- }
- if ($type) {
- $condition[] = [ 'peg.type', '=', $type ];
- }
- if ($state != '') {
- $condition[] = [ 'peg.state', '=', $state ];
- }
-
- $field = 'peg.*';
- $alias = 'peg';
- $join = [];
-
- //排序
- $order = input('order', 'create_time');
- $sort = input('sort', 'desc');
- if ($order == 'sort') {
- $order_by = 'peg.' . $order . ' ' . $sort;
- } else {
- $order_by = 'peg.' . $order . ' ' . $sort . ',peg.sort desc';
- }
-
- $exchange_model = new ExchangeModel();
- //兑换名称 兑换图片 兑换库存 兑换价格
- $lists = $exchange_model->getExchangeGoodsPageList($condition, $page, $page_size, $order_by, $field, $alias, $join);
- return $lists;
- }
-
- return $this->fetch("exchange/lists");
- }
-
- /**
- * 添加积分兑换
- */
- public function add()
- {
- if (request()->isJson()) {
- $type = input('type', '1');//兑换类型 1 商品 2 优惠券 3 红包
-
- $data = [
- 'site_id' => $this->site_id,
- 'type' => $type,//兑换类型 1 商品 2 优惠券 3 红包
- 'point' => input('point', ''),//积分
- 'state' => input('state', ''),
- 'is_free_shipping' => input('is_free_shipping', ''),
- 'delivery_type' => input('delivery_type', ''),
- 'delivery_price' => input('delivery_price', ''),
- 'shipping_template' => input('shipping_template', ''),
- ];
- if ($type == 1) {
- $data[ 'goods_data' ] = input('goods_data', '');
- $data[ 'rule' ] = input('content', '');
- $data[ 'type_name' ] = '商品';
- } elseif ($type == 2) {
- $data[ 'coupon_type_id' ] = input('coupon_type_id', '0');//优惠券id
- $data[ 'content' ] = input('content', '');
- $data[ 'type_name' ] = '优惠券';
- $data[ 'stock' ] = input('stock', '');
- } elseif ($type == 3) {
- $data[ 'name' ] = input('name', '');
- $data[ 'image' ] = input('image', '');
- $data[ 'stock' ] = input('stock', '');
- $data[ 'balance' ] = input('balance', '0');
- $data[ 'content' ] = input('content', '');
- $data[ 'type_name' ] = '红包';
- } else {
- return error(-1, '');
- }
- $exchange_model = new ExchangeModel();
- $res = $exchange_model->addExchange($data);
- return $res;
- } else {
- //获取运费模板
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
- $express_template_list = $express_template_list[ 'data' ];
- $this->assign("express_template_list", $express_template_list);
-
- return $this->fetch("exchange/add");
- }
- }
-
- /**
- * 编辑积分兑换
- */
- public function edit()
- {
- $id = input("id", 0);
- $exchange_model = new ExchangeModel();
- if (request()->isJson()) {
- $type = input('type', '1');//兑换类型 1 商品 2 优惠券 3 红包
- $data = [
- 'site_id' => $this->site_id,
- 'type' => $type,//兑换类型 1 商品 2 优惠券 3 红包
- 'point' => input('point', ''),//积分
- 'state' => input('state', ''),
- 'id' => $id,
- 'is_free_shipping' => input('is_free_shipping', ''),
- 'delivery_type' => input('delivery_type', ''),
- 'delivery_price' => input('delivery_price', ''),
- 'shipping_template' => input('shipping_template', ''),
- ];
- if ($type == 1) {
- $data[ 'goods_data' ] = input('goods_data', '');
- $data[ 'rule' ] = input('content', '');
- $data[ 'type_name' ] = '商品';
-
- } elseif ($type == 2) {
- $data[ 'coupon_type_id' ] = input('coupon_type_id', '0');//优惠券id
- $data[ 'content' ] = input('content', '');
- $data[ 'type_name' ] = '优惠券';
- $data[ 'stock' ] = input('stock', '');
- } elseif ($type == 3) {
- $data[ 'name' ] = input('name', '');
- $data[ 'image' ] = input('image', '');
- $data[ 'stock' ] = input('stock', '');
- $data[ 'balance' ] = input('balance', '0');
- $data[ 'content' ] = input('content', '');
- $data[ 'type_name' ] = '红包';
- } else {
- return error(-1, '');
- }
-
- $res = $exchange_model->editExchange($data);
- return $res;
- } else {
- $exchange_info = $exchange_model->getExchangeGoodsDetail($id, $this->site_id);
- if (empty($exchange_info[ 'data' ][ 'id' ])) {
- $this->error('对应的积分兑换活动商品/优惠券已经不存在了!');
- }
- $this->assign("exchange_info", $exchange_info[ 'data' ]);
-
- //获取运费模板
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
- $express_template_list = $express_template_list[ 'data' ];
- $this->assign("express_template_list", $express_template_list);
-
- return $this->fetch("exchange/edit");
- }
- }
-
- /**
- *关闭积分兑换
- */
- public function delete()
- {
- $id = input("id", 0);
- $exchange_model = new ExchangeModel();
- $res = $exchange_model->deleteExchange($id);
- return $res;
-
- }
-
- /**
- * 修改排序
- */
- public function modifySort()
- {
- $sort = input('sort', 0);
- $id = input('id', 0);
- $exchange_model = new ExchangeModel();
- return $exchange_model->modifyExchangeSort($sort, $id);
- }
-
-
- /**
- * 获取商品列表
- * @return array
- */
- public function getSkuList()
- {
- if (request()->isJson()) {
- $exchange_model = new ExchangeModel();
-
- $exchange_id = input('exchange_id', '');
-
- $field = 'pe.*,sku.sku_name,sku.price as market_price,sku.sku_image,sku.stock';
- $alias = 'pe';
- $join = [
- [
- 'promotion_exchange_goods peg',
- 'peg.id = pe.exchange_goods_id',
- 'inner'
- ],
- [
- 'goods_sku sku',
- 'sku.sku_id = pe.type_id',
- 'inner'
- ]
- ];
- $condition = [
- [ 'peg.id', '=', $exchange_id ],
- [ 'sku.is_delete', '=', 0 ],
- [ 'sku.goods_state', '=', 1 ],
- [ 'peg.state', '=', 1 ],
- ];
-
- $goods_list = $exchange_model->getExchangeList($condition, $field, '', null, $alias, $join);
- foreach ($goods_list[ 'data' ] as $k => $v) {
- $goods_list[ 'data' ][ $k ][ 'stock' ] = numberFormat($goods_list[ 'data' ][ $k ][ 'stock' ]);
- }
- return $goods_list;
- }
- }
-
- /**
- * 获取优惠券列表
- */
- public function getCouponList()
- {
- $coupon_type_model = new CouponTypeModel();
- if (request()->isJson()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $status = input('status', '');
-
- $condition = [];
- if ($status !== "") {
- $condition[] = [ 'status', '=', $status ];
- }
-
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $order = 'sort asc';
- $field = '*';
-
- $res = $coupon_type_model->getCouponTypePageList($condition, $page, $page_size, $order, $field);
- $exchange_model = new ExchangeModel();
- //兑换名称 兑换图片 兑换库存 兑换价格
- $exchange_list = $exchange_model->getExchangeList([ [ 'type', '=', 2 ] ], 'type_id')[ 'data' ] ?? [];
- if ($exchange_list) {
- $exchange_list = array_column($exchange_list, 'type_id');
- }
-
- if ($res[ 'data' ][ 'list' ]) {
- foreach ($res[ 'data' ][ 'list' ] as $key => $val) {
- if (in_array($val[ 'coupon_type_id' ], $exchange_list)) {
- $res[ 'data' ][ 'list' ][ $key ][ 'is_exit' ] = 1;
- } else {
- $res[ 'data' ][ 'list' ][ $key ][ 'is_exit' ] = 0;
- }
- }
- }
- return $res;
-
- }
- }
-
- /**
- *关闭积分兑换
- */
- public function deleteAll()
- {
- if (request()->isJson()) {
- $id = input("exchange_id", '');
- $exchange_model = new ExchangeModel();
- foreach ($id as $k => $v){
- $res = $exchange_model->deleteExchange($v);
- }
- return $res;
- }
- }
+isJson()) {
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $search_text = input('search_text', '');
+ $type = input('type', '');
+ $state = input('state', '');
+ $sort = input('sort', 'asc');
+ $condition[] = [ 'peg.site_id', '=', $this->site_id ];
+ if ($search_text) {
+ $condition[] = [ 'peg.name', 'like', '%' . $search_text . '%' ];
+ }
+ if ($type) {
+ $condition[] = [ 'peg.type', '=', $type ];
+ }
+ if ($state != '') {
+ $condition[] = [ 'peg.state', '=', $state ];
+ }
+
+ $field = 'peg.*';
+ $alias = 'peg';
+ $join = [];
+
+ //排序
+ $order = input('order', 'create_time');
+ $sort = input('sort', 'desc');
+ if ($order == 'sort') {
+ $order_by = 'peg.' . $order . ' ' . $sort;
+ } else {
+ $order_by = 'peg.' . $order . ' ' . $sort . ',peg.sort desc';
+ }
+
+ $exchange_model = new ExchangeModel();
+ //兑换名称 兑换图片 兑换库存 兑换价格
+ $lists = $exchange_model->getExchangeGoodsPageList($condition, $page, $page_size, $order_by, $field, $alias, $join);
+ return $lists;
+ }
+
+ return $this->fetch("exchange/lists");
+ }
+
+ /**
+ * 添加积分兑换
+ */
+ public function add()
+ {
+ if (request()->isJson()) {
+ $type = input('type', '1');//兑换类型 1 商品 2 优惠券 3 红包
+
+ $data = [
+ 'site_id' => $this->site_id,
+ 'type' => $type,//兑换类型 1 商品 2 优惠券 3 红包
+ 'point' => input('point', ''),//积分
+ 'state' => input('state', ''),
+ 'is_free_shipping' => input('is_free_shipping', ''),
+ 'delivery_type' => input('delivery_type', ''),
+ 'delivery_price' => input('delivery_price', ''),
+ 'shipping_template' => input('shipping_template', ''),
+ ];
+ if ($type == 1) {
+ $data[ 'goods_data' ] = input('goods_data', '');
+ $data[ 'rule' ] = input('content', '');
+ $data[ 'type_name' ] = '商品';
+ } elseif ($type == 2) {
+ $data[ 'coupon_type_id' ] = input('coupon_type_id', '0');//优惠券id
+ $data[ 'content' ] = input('content', '');
+ $data[ 'type_name' ] = '优惠券';
+ $data[ 'stock' ] = input('stock', '');
+ } elseif ($type == 3) {
+ $data[ 'name' ] = input('name', '');
+ $data[ 'image' ] = input('image', '');
+ $data[ 'stock' ] = input('stock', '');
+ $data[ 'balance' ] = input('balance', '0');
+ $data[ 'content' ] = input('content', '');
+ $data[ 'type_name' ] = '红包';
+ } else {
+ return error(-1, '');
+ }
+ $exchange_model = new ExchangeModel();
+ $res = $exchange_model->addExchange($data);
+ return $res;
+ } else {
+ //获取运费模板
+ $express_template_model = new ExpressTemplateModel();
+ $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
+ $express_template_list = $express_template_list[ 'data' ];
+ $this->assign("express_template_list", $express_template_list);
+
+ return $this->fetch("exchange/add");
+ }
+ }
+
+ /**
+ * 编辑积分兑换
+ */
+ public function edit()
+ {
+ $id = input("id", 0);
+ $exchange_model = new ExchangeModel();
+ if (request()->isJson()) {
+ $type = input('type', '1');//兑换类型 1 商品 2 优惠券 3 红包
+ $data = [
+ 'site_id' => $this->site_id,
+ 'type' => $type,//兑换类型 1 商品 2 优惠券 3 红包
+ 'point' => input('point', ''),//积分
+ 'state' => input('state', ''),
+ 'id' => $id,
+ 'is_free_shipping' => input('is_free_shipping', ''),
+ 'delivery_type' => input('delivery_type', ''),
+ 'delivery_price' => input('delivery_price', ''),
+ 'shipping_template' => input('shipping_template', ''),
+ ];
+ if ($type == 1) {
+ $data[ 'goods_data' ] = input('goods_data', '');
+ $data[ 'rule' ] = input('content', '');
+ $data[ 'type_name' ] = '商品';
+
+ } elseif ($type == 2) {
+ $data[ 'coupon_type_id' ] = input('coupon_type_id', '0');//优惠券id
+ $data[ 'content' ] = input('content', '');
+ $data[ 'type_name' ] = '优惠券';
+ $data[ 'stock' ] = input('stock', '');
+ } elseif ($type == 3) {
+ $data[ 'name' ] = input('name', '');
+ $data[ 'image' ] = input('image', '');
+ $data[ 'stock' ] = input('stock', '');
+ $data[ 'balance' ] = input('balance', '0');
+ $data[ 'content' ] = input('content', '');
+ $data[ 'type_name' ] = '红包';
+ } else {
+ return error(-1, '');
+ }
+
+ $res = $exchange_model->editExchange($data);
+ return $res;
+ } else {
+ $exchange_info = $exchange_model->getExchangeGoodsDetail($id, $this->site_id);
+ if (empty($exchange_info[ 'data' ][ 'id' ])) {
+ $this->error('对应的积分兑换活动商品/优惠券已经不存在了!');
+ }
+ $this->assign("exchange_info", $exchange_info[ 'data' ]);
+
+ //获取运费模板
+ $express_template_model = new ExpressTemplateModel();
+ $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
+ $express_template_list = $express_template_list[ 'data' ];
+ $this->assign("express_template_list", $express_template_list);
+
+ return $this->fetch("exchange/edit");
+ }
+ }
+
+ /**
+ *关闭积分兑换
+ */
+ public function delete()
+ {
+ $id = input("id", 0);
+ $exchange_model = new ExchangeModel();
+ $res = $exchange_model->deleteExchange($id);
+ return $res;
+
+ }
+
+ /**
+ * 修改排序
+ */
+ public function modifySort()
+ {
+ $sort = input('sort', 0);
+ $id = input('id', 0);
+ $exchange_model = new ExchangeModel();
+ return $exchange_model->modifyExchangeSort($sort, $id);
+ }
+
+
+ /**
+ * 获取商品列表
+ * @return array
+ */
+ public function getSkuList()
+ {
+ if (request()->isJson()) {
+ $exchange_model = new ExchangeModel();
+
+ $exchange_id = input('exchange_id', '');
+
+ $field = 'pe.*,sku.sku_name,sku.price as market_price,sku.sku_image,sku.stock';
+ $alias = 'pe';
+ $join = [
+ [
+ 'promotion_exchange_goods peg',
+ 'peg.id = pe.exchange_goods_id',
+ 'inner'
+ ],
+ [
+ 'goods_sku sku',
+ 'sku.sku_id = pe.type_id',
+ 'inner'
+ ]
+ ];
+ $condition = [
+ [ 'peg.id', '=', $exchange_id ],
+ [ 'sku.is_delete', '=', 0 ],
+ [ 'sku.goods_state', '=', 1 ],
+ [ 'peg.state', '=', 1 ],
+ ];
+
+ $goods_list = $exchange_model->getExchangeList($condition, $field, '', null, $alias, $join);
+ foreach ($goods_list[ 'data' ] as $k => $v) {
+ $goods_list[ 'data' ][ $k ][ 'stock' ] = numberFormat($goods_list[ 'data' ][ $k ][ 'stock' ]);
+ }
+ return $goods_list;
+ }
+ }
+
+ /**
+ * 获取优惠券列表
+ */
+ public function getCouponList()
+ {
+ $coupon_type_model = new CouponTypeModel();
+ if (request()->isJson()) {
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $status = input('status', '');
+
+ $condition = [];
+ if ($status !== "") {
+ $condition[] = [ 'status', '=', $status ];
+ }
+
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $order = 'sort asc';
+ $field = '*';
+
+ $res = $coupon_type_model->getCouponTypePageList($condition, $page, $page_size, $order, $field);
+ $exchange_model = new ExchangeModel();
+ //兑换名称 兑换图片 兑换库存 兑换价格
+ $exchange_list = $exchange_model->getExchangeList([ [ 'type', '=', 2 ] ], 'type_id')[ 'data' ] ?? [];
+ if ($exchange_list) {
+ $exchange_list = array_column($exchange_list, 'type_id');
+ }
+
+ if ($res[ 'data' ][ 'list' ]) {
+ foreach ($res[ 'data' ][ 'list' ] as $key => $val) {
+ if (in_array($val[ 'coupon_type_id' ], $exchange_list)) {
+ $res[ 'data' ][ 'list' ][ $key ][ 'is_exit' ] = 1;
+ } else {
+ $res[ 'data' ][ 'list' ][ $key ][ 'is_exit' ] = 0;
+ }
+ }
+ }
+ return $res;
+
+ }
+ }
+
+ /**
+ *关闭积分兑换
+ */
+ public function deleteAll()
+ {
+ if (request()->isJson()) {
+ $id = input("exchange_id", '');
+ $exchange_model = new ExchangeModel();
+ foreach ($id as $k => $v){
+ $res = $exchange_model->deleteExchange($v);
+ }
+ return $res;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/pointexchange/shop/controller/Pointexchange.php b/src/addon/pointexchange/shop/controller/Pointexchange.php
index eccbed204..520bd614d 100644
--- a/src/addon/pointexchange/shop/controller/Pointexchange.php
+++ b/src/addon/pointexchange/shop/controller/Pointexchange.php
@@ -1,113 +1,105 @@
-replace = [
- 'POINTEXCHANGE_CSS' => __ROOT__ . '/addon/pointexchange/shop/view/public/css',
- 'POINTEXCHANGE_JS' => __ROOT__ . '/addon/pointexchange/shop/view/public/js',
- 'POINTEXCHANGE_IMG' => __ROOT__ . '/addon/pointexchange/shop/view/public/img',
- ];
- parent::__construct($app);
-
- }
-
- /**
- * 兑换订单列表
- * @return mixed
- */
- public function lists()
- {
-
- $exchange_id = input('exchange_id', '');
- if (request()->isJson()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', '');
- $condition = [
- ['eo.site_id','=',$this->site_id]
- ];
- if ($search_text) {
- $condition[] = [ 'eo.exchange_name', 'like', '%' . $search_text . '%' ];
- }
-
- $name = input('name', '');
- if (!empty($name)) {
- $condition[] = [ 'm.nickname', 'like', '%' . $name . '%' ];
- }
-
- $mobile = input('mobile', '');
- if (!empty($mobile)) {
- $condition[] = [ 'eo.mobile', 'like', '%' . $mobile . '%' ];
- }
-
- $type = input('type', '');
- if ($type) {
- $condition[] = [ 'eo.type', '=', $type ];
- }
-
- if ($exchange_id) {
- $condition[] = [ 'eo.exchange_goods_id', '=', $exchange_id ];
- }
-
- $start_time = input('start_time', '');
- $end_time = input('end_time', '');
-
- if ($start_time && !$end_time) {
- $condition[] = [ 'eo.pay_time', '>=', date_to_time($start_time) ];
- } elseif (!$start_time && $end_time) {
- $condition[] = [ 'eo.pay_time', '<=', date_to_time($end_time) ];
- } elseif ($start_time && $end_time) {
- $condition[] = [ 'eo.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
- }
-
- $order = 'eo.create_time desc';
- $field = 'eo.*,m.nickname';
-
- $exchange_order_model = new ExchangeOrderModel();
- $list = $exchange_order_model->getExchangePageList($condition, $page, $page_size, $order, $field, 'eo', [
- [ 'member m', 'm.member_id=eo.member_id', 'left' ]
- ]);
- // file_put_contents(__DIR__ . '/debug.txt', var_export($condition,true));
- return $list;
-
- } else {
- $this->assign('exchange_id', $exchange_id);
- return $this->fetch("exchange_order/lists");
- }
-
- }
-
- /**订单详情
- * @return mixed
- */
- public function detail()
- {
- $order_id = input('order_id', 0);
- $order_model = new ExchangeOrderModel();
- $order_info = $order_model->getOrderInfo([ [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', $order_id ] ]);
- $order_info = $order_info[ "data" ];
- if (empty($order_info)) $this->error('未获取到订单数据', href_url('pointexchange://shop/pointexchange/lists'));
- $this->assign("order_info", $order_info);
- return $this->fetch('exchange_order/detail');
- }
-
+replace = [
+ 'POINTEXCHANGE_CSS' => __ROOT__ . '/addon/pointexchange/shop/view/public/css',
+ 'POINTEXCHANGE_JS' => __ROOT__ . '/addon/pointexchange/shop/view/public/js',
+ 'POINTEXCHANGE_IMG' => __ROOT__ . '/addon/pointexchange/shop/view/public/img',
+ ];
+ parent::__construct($app);
+
+ }
+
+ /**
+ * 兑换订单列表
+ * @return mixed
+ */
+ public function lists()
+ {
+
+ $exchange_id = input('exchange_id', '');
+ if (request()->isJson()) {
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $search_text = input('search_text', '');
+ $condition = [
+ ['eo.site_id','=',$this->site_id]
+ ];
+ if ($search_text) {
+ $condition[] = [ 'eo.exchange_name', 'like', '%' . $search_text . '%' ];
+ }
+
+ $name = input('name', '');
+ if (!empty($name)) {
+ $condition[] = [ 'm.nickname', 'like', '%' . $name . '%' ];
+ }
+
+ $mobile = input('mobile', '');
+ if (!empty($mobile)) {
+ $condition[] = [ 'eo.mobile', 'like', '%' . $mobile . '%' ];
+ }
+
+ $type = input('type', '');
+ if ($type) {
+ $condition[] = [ 'eo.type', '=', $type ];
+ }
+
+ if ($exchange_id) {
+ $condition[] = [ 'eo.exchange_goods_id', '=', $exchange_id ];
+ }
+
+ $start_time = input('start_time', '');
+ $end_time = input('end_time', '');
+
+ if ($start_time && !$end_time) {
+ $condition[] = [ 'eo.pay_time', '>=', date_to_time($start_time) ];
+ } elseif (!$start_time && $end_time) {
+ $condition[] = [ 'eo.pay_time', '<=', date_to_time($end_time) ];
+ } elseif ($start_time && $end_time) {
+ $condition[] = [ 'eo.pay_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
+ }
+
+ $order = 'eo.create_time desc';
+ $field = 'eo.*,m.nickname';
+
+ $exchange_order_model = new ExchangeOrderModel();
+ $list = $exchange_order_model->getExchangePageList($condition, $page, $page_size, $order, $field, 'eo', [
+ [ 'member m', 'm.member_id=eo.member_id', 'left' ]
+ ]);
+ // file_put_contents(__DIR__ . '/debug.txt', var_export($condition,true));
+ return $list;
+
+ } else {
+ $this->assign('exchange_id', $exchange_id);
+ return $this->fetch("exchange_order/lists");
+ }
+
+ }
+
+ /**订单详情
+ * @return mixed
+ */
+ public function detail()
+ {
+ $order_id = input('order_id', 0);
+ $order_model = new ExchangeOrderModel();
+ $order_info = $order_model->getOrderInfo([ [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', $order_id ] ]);
+ $order_info = $order_info[ "data" ];
+ if (empty($order_info)) $this->error('未获取到订单数据', href_url('pointexchange://shop/pointexchange/lists'));
+ $this->assign("order_info", $order_info);
+ return $this->fetch('exchange_order/detail');
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/printer/config/diy_view.php b/src/addon/printer/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/printer/config/diy_view.php
+++ b/src/addon/printer/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/printer/config/info.php b/src/addon/printer/config/info.php
index c0be5f4b4..225ff13f1 100644
--- a/src/addon/printer/config/info.php
+++ b/src/addon/printer/config/info.php
@@ -1,20 +1,12 @@
- 'printer',
- 'title' => '小票打印',
- 'description' => '小票打印',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'printer',
+ 'title' => '小票打印',
+ 'description' => '小票打印',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/printer/event/Install.php b/src/addon/printer/event/Install.php
index 390616650..d65ded2e5 100644
--- a/src/addon/printer/event/Install.php
+++ b/src/addon/printer/event/Install.php
@@ -1,25 +1,17 @@
-addCron(1, 0, "充值小票打印", "MemberRechargeOrderPayPrinter", time(), $param[ 'order_id' ]);
- }
+addCron(1, 0, "充值小票打印", "MemberRechargeOrderPayPrinter", time(), $param[ 'order_id' ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/MemberRechargeOrderPayPrinter.php b/src/addon/printer/event/MemberRechargeOrderPayPrinter.php
index e678d0d11..28a02ba0e 100644
--- a/src/addon/printer/event/MemberRechargeOrderPayPrinter.php
+++ b/src/addon/printer/event/MemberRechargeOrderPayPrinter.php
@@ -1,29 +1,20 @@
-printer([
- 'order_id' => $param['relate_id'],
- 'type' => 'recharge',
- ]);
- }
+printer([
+ 'order_id' => $param['relate_id'],
+ 'type' => 'recharge',
+ ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/OrderPay.php b/src/addon/printer/event/OrderPay.php
index db7eb690c..b7eb047a1 100644
--- a/src/addon/printer/event/OrderPay.php
+++ b/src/addon/printer/event/OrderPay.php
@@ -1,28 +1,20 @@
-addCron(1, 0, "订单小票打印", "OrderPayPrinter", time(), $param[ 'order_id' ]);
- }
+addCron(1, 0, "订单小票打印", "OrderPayPrinter", time(), $param[ 'order_id' ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/OrderPayPrinter.php b/src/addon/printer/event/OrderPayPrinter.php
index d075205a1..735c028f3 100644
--- a/src/addon/printer/event/OrderPayPrinter.php
+++ b/src/addon/printer/event/OrderPayPrinter.php
@@ -1,30 +1,22 @@
-printer([
- 'order_id' => $param[ 'relate_id' ],
- 'type' => 'goodsorder',
- 'printer_type' => 'order_pay',
- ]);
- }
+printer([
+ 'order_id' => $param[ 'relate_id' ],
+ 'type' => 'goodsorder',
+ 'printer_type' => 'order_pay',
+ ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/OrderTakeDeliveryAfter.php b/src/addon/printer/event/OrderTakeDeliveryAfter.php
index dd9834695..17b498db0 100644
--- a/src/addon/printer/event/OrderTakeDeliveryAfter.php
+++ b/src/addon/printer/event/OrderTakeDeliveryAfter.php
@@ -1,28 +1,20 @@
-addCron(1, 0, "订单收货小票打印", "OrderTakeDeliveryPrinter", time(), $param[ 'order_id' ]);
- }
+addCron(1, 0, "订单收货小票打印", "OrderTakeDeliveryPrinter", time(), $param[ 'order_id' ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/OrderTakeDeliveryPrinter.php b/src/addon/printer/event/OrderTakeDeliveryPrinter.php
index 28511e008..54cb47c84 100644
--- a/src/addon/printer/event/OrderTakeDeliveryPrinter.php
+++ b/src/addon/printer/event/OrderTakeDeliveryPrinter.php
@@ -1,32 +1,24 @@
-printer([
- 'order_id' => $param[ 'relate_id' ],
- 'type' => 'goodsorder',
- 'printer_type' => 'take_delivery',
- ]);
- }
+printer([
+ 'order_id' => $param[ 'relate_id' ],
+ 'type' => 'goodsorder',
+ 'printer_type' => 'take_delivery',
+ ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/PrintOrder.php b/src/addon/printer/event/PrintOrder.php
index e90d75f91..5dfe98be3 100644
--- a/src/addon/printer/event/PrintOrder.php
+++ b/src/addon/printer/event/PrintOrder.php
@@ -1,26 +1,18 @@
-printer($params);
- }
+printer($params);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/PrinterContent.php b/src/addon/printer/event/PrinterContent.php
index 8c567a0de..288dc5db7 100644
--- a/src/addon/printer/event/PrinterContent.php
+++ b/src/addon/printer/event/PrinterContent.php
@@ -1,320 +1,312 @@
-getOrderDetail($order_id)[ 'data' ];
- $site_id = $order_info[ 'site_id' ];
- $store_id = $order_info[ 'store_id' ];
-
- //获取店铺信息
- $shop_model = new Shop();
- $shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $site_id ] ])[ 'data' ];
-
- $site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $site_id ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
-
- //获取打印机列表
- $print_model = new Printer();
- $printer_condition = [
- [ 'site_id', '=', $site_id ]
- ];
- if (addon_is_exit('store', $site_id)) $printer_condition[] = [ 'store_id', '=', $store_id ];
-
- switch ( $stage ) {
- case 'order_pay':
- $printer_condition[] = [ 'order_pay_open', '=', 1 ];
- $printer_condition[] = [ 'order_pay_order_type', 'like', '%,' . $order_info[ 'order_type' ] . ',%' ];
- break;
- case 'take_delivery':
- $printer_condition[] = [ 'take_delivery_open', '=', 1 ];
- $printer_condition[] = [ 'take_delivery_order_type', 'like', '%,' . $order_info[ 'order_type' ] . ',%' ];
- break;
- case 'manual':
- $printer_condition[] = [ 'manual_open', '=', 1 ];
- break;
- }
-
- $printer_data = $print_model->getPrinterList($printer_condition)[ 'data' ] ?? [];
- $res_data = [];
-
- foreach ($printer_data as $k => $v) {
- //此处应该根据打印机不同分别设置返回不同的数据。当前为易联云
- $array = [];
- $array[ 'printer_info' ] = $v;
- $print_template_model = new PrinterTemplate();
-
- $template_id = 0;
- $print_num = 1;
- switch ( $stage ) {
- case 'order_pay':
- //支付
- $template_id = $v[ 'order_pay_template_id' ];
- $print_num = $v[ 'order_pay_print_num' ];
- break;
- case 'take_delivery':
- //收货
- $template_id = $v[ 'take_delivery_template_id' ];
- $print_num = $v[ 'take_delivery_print_num' ];
- break;
- case 'manual':
- //手动打印
- $template_id = $v[ 'template_id' ];
- $print_num = $v[ 'print_num' ];
- break;
- }
-
- $print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ] ])[ 'data' ];
-
- $array[ 'printer_code' ] = $v[ 'printer_code' ]; //商户授权机器码
- $array[ 'origin_id' ] = $order_info[ 'order_no' ]; //内部订单号(32位以内)
- /**文本接口开始**/
- $content = "" . $print_num . "";
- //小票名称
- if ($print_template[ 'title' ] != '') {
- $content .= "" . $print_template[ 'title' ] . "";
- $content .= str_repeat('.', 32);
- }
- //商城名称
- if ($print_template[ 'head' ] == 1) {
- $content .= "" . $site_name . "";
- $content .= str_repeat('.', 32);
- }
-
- if (!empty($order_info[ 'pay_time' ])) {
- $content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
- } else {
- $content .= "订单时间:" . date("Y-m-d H:i", time()) . "\n";
- }
- $content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
- $content .= "支付方式:" . $order_info[ 'pay_type_name' ] . "\n";
-
- switch ( $order_info[ 'order_type' ] ) {
- case 1 :
- // 物流订单
- break;
- case 2 :
- // 自提订单
- if ($order_info[ 'buyer_ask_delivery_time' ] == 0) {
- $buyer_ask_delivery_time_str = '立即自提';
- } elseif (strpos($order_info[ 'buyer_ask_delivery_time' ], '-') !== false) {
- $buyer_ask_delivery_time_str = $order_info[ 'buyer_ask_delivery_time' ];
- } else {
- $buyer_ask_delivery_time_str = date("H:i:s", $order_info[ 'buyer_ask_delivery_time' ]);
- }
- $content .= "要求自提时间:" . $buyer_ask_delivery_time_str . "\n";
- break;
- case 3 :
- // 外卖订单
- if ($order_info[ 'buyer_ask_delivery_time' ] == 0) {
- $buyer_ask_delivery_time_str = '立即送达';
- } elseif (strpos($order_info[ 'buyer_ask_delivery_time' ], '-') !== false) {
- $buyer_ask_delivery_time_str = $order_info[ 'buyer_ask_delivery_time' ];
- } else {
- $buyer_ask_delivery_time_str = date("H:i:s", $order_info[ 'buyer_ask_delivery_time' ]);
- }
- $content .= "要求送达时间:" . $buyer_ask_delivery_time_str . "\n";
- break;
- case 4 :
- // 虚拟订单
- break;
- case 5 :
- // 收银订单
- break;
- }
-
- $content .= str_repeat('.', 32);
- $content .= "";
- $content .= "";
- if ($print_template[ 'goods_price_show' ]) {
- $content .= "| 商品名称 | | 数量 | 金额 | ";
- } else {
- $content .= "商品名称 | | | 数量 | ";
- }
- $content .= "
";
- $content .= "
";
- $content .= str_repeat('.', 32);
- $content .= "";
- foreach ($order_info[ 'order_goods' ] as $goods) {
- //显示售价或卖价
- $price = $print_template[ 'goods_price_type' ] == 'price' ? $goods[ 'price' ] : $goods[ 'real_goods_money' ];
- if ($print_template[ 'goods_price_show' ]) {
- $content .= "| " . $goods[ 'sku_name' ] . " | | x" . $goods[ 'num' ] . " | ¥" . $price . " |
";
- } else {
- $content .= "| " . $goods[ 'sku_name' ] . " | | | x" . $goods[ 'num' ] . " |
";
- }
-
- //商品编码
- if ($print_template[ 'goods_code_show' ] && !empty($goods[ 'sku_no' ])) {
- $content .= "| [" . $goods[ 'sku_no' ] . "] | | | |
";
- }
-
- }
- $content .= "
";
- $content .= str_repeat('.', 32);
- if ($order_info[ "goods_money" ] > 0) {
- $content .= "商品总额:¥" . $order_info[ "goods_money" ] . "\n";
- }
- if ($order_info[ "coupon_money" ] > 0) {
- $content .= "店铺优惠券:¥" . $order_info[ "coupon_money" ] . "\n";
- }
- if ($order_info[ "promotion_money" ] > 0) {
- $content .= "店铺优惠:¥" . $order_info[ "promotion_money" ] . "\n";
- }
- if ($order_info[ "point_money" ] > 0) {
- $content .= "积分抵扣:¥" . $order_info[ "point_money" ] . "\n";
- }
- if ($order_info[ "adjust_money" ] > 0) {
- $content .= "订单调价:¥" . $order_info[ "adjust_money" ] . "\n";
- }
- if ($order_info[ 'reduction' ] > 0) {
- $content .= "订单减免:¥" . $order_info[ "reduction" ] . "\n";
- }
- if ($order_info[ "balance_money" ] > 0) {
- $content .= "余额抵扣:¥" . $order_info[ "balance_money" ] . "\n";
- }
- if ($order_info[ "delivery_money" ] > 0) {
- $content .= "配送费用:¥" . $order_info[ "delivery_money" ] . "\n";
- }
- if ($order_info[ "invoice_money" ] > 0) {
- $content .= "发票费用:¥" . $order_info[ "invoice_money" ] . "\n";
- }
- if ($order_info[ "invoice_delivery_money" ] > 0) {
- $content .= "发票邮寄费用:¥" . $order_info[ "invoice_delivery_money" ] . "\n";
- }
- if ($order_info[ "goods_num" ] > 0) {
- $content .= "订单共" . $order_info[ 'goods_num' ] . "件商品,总计: ¥" . $order_info[ 'order_money' ] . " \n";
- }
- $content .= str_repeat('.', 32);
-
- /******************** 备注信息 **************************/
- //买家留言
- if ($print_template[ 'buy_notes' ] == 1) {
- $order_info[ "buyer_message" ] = $order_info[ "buyer_message" ] ? $order_info[ "buyer_message" ] : '无';
- $content .= "买家留言:" . $order_info[ "buyer_message" ] . "\n";
- $content .= str_repeat('.', 32);
- }
- //卖家留言
- if ($print_template[ 'seller_notes' ] == 1) {
- $order_info[ "remark" ] = $order_info[ "remark" ] ? $order_info[ "remark" ] : '无';
- $content .= "卖家留言:" . $order_info[ "remark" ] . "\n";
- $content .= str_repeat('.', 32);
- }
-
- //表单
- if ($print_template[ 'form_show' ] == 1 && addon_is_exit('form')) {
- $form_info = model('form_data')->getInfo([ [ 'site_id', '=', $site_id ], [ 'scene', '=', 'order' ], [ 'relation_id', '=', $order_id ] ]);
- if (!empty($form_info) && !empty($form_info[ 'form_data' ])) {
- $form_data = json_decode($form_info[ 'form_data' ], true);
- foreach ($form_data as $item) {
- $content .= "" . $item[ 'title' ] . ":" . $item[ "val" ] . "\n";
- $content .= str_repeat('.', 32);
- }
- }
- }
-
- /******************** 买家信息 **************************/
- if ($order_info[ 'member_id' ]) {
- $member_info = model('member')->getInfo([['member_id', '=', $order_info[ 'member_id' ]]]);
- //买家姓名
- if ($print_template[ 'buy_name' ] == 1) {
- if($order_info[ 'order_type' ] == 2){
- $content .= "" . $member_info[ "nickname" ] . "\n";
- }else{
- $content .= "" . $order_info[ "name" ] . "\n";
- }
-
- }
- //联系方式
- if ($print_template[ 'buy_mobile' ] == 1) {
- if($order_info[ 'order_type' ] == 2){
- $content .= "" . $member_info[ "mobile" ] . "\n";
- }else{
- $content .= "" . $order_info[ "mobile" ] . "\n";
- }
-
- }
- //地址
- if ($print_template[ 'buy_address' ] == 1) {
- if($order_info[ 'order_type' ] == 2){
- $content .= "自提门店:" . $order_info[ 'delivery_store_name' ] . "\n";
- }else{
- $content .= "" . $order_info[ 'full_address' ] . "-" . $order_info[ 'address' ] . "\n";
- }
-
- }
- if ($print_template[ 'buy_name' ] == 1 || $print_template[ 'buy_mobile' ] == 1 || $print_template[ 'buy_address' ] == 1) {
- $content .= str_repeat('.', 32);
- }
- }
- /******************** 商城信息 **************************/
- //联系方式
- if ($print_template[ 'shop_mobile' ] == 1) {
- $content .= "" . $shop_info[ "mobile" ] . "\n";
- }
-
- //地址
- if ($print_template[ 'shop_address' ] == 1) {
- $content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
- }
-
- if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
- $content .= str_repeat('.', 32);
- }
-
- //二维码
- if ($print_template[ 'shop_qrcode' ] == 1) {
- $content .= "" . $print_template[ 'qrcode_url' ] . "";
- $content .= str_repeat('.', 32);
- }
-
- /******************** 门店信息 **************************/
- if ($order_info[ 'store_id' ] > 0) {
- $store_info = ( new Store() )->getStoreInfo([ [ 'store_id', '=', $order_info[ 'store_id' ] ] ], 'store_name,telphone,full_address')[ 'data' ];
- $content .= "" . $order_info[ "store_name" ] . "\n";//门店名称
- $content .= "" . $store_info[ "telphone" ] . "\n";//门店电话
- $content .= "" . $store_info[ "full_address" ] . "\n";//门店地址
- $content .= str_repeat('.', 32);
- }
-
- //底部内容
- if (!empty($print_template[ 'bottom' ])) {
- $content .= "" . $print_template[ 'bottom' ] . "";
- }
- $array[ 'content' ] = $content;
-
- $res_data[] = $array;
- }
- return $res_data;
-
- }
- }
+getOrderDetail($order_id)[ 'data' ];
+ $site_id = $order_info[ 'site_id' ];
+ $store_id = $order_info[ 'store_id' ];
+
+ //获取店铺信息
+ $shop_model = new Shop();
+ $shop_info = $shop_model->getShopInfo([ [ 'site_id', '=', $site_id ] ])[ 'data' ];
+
+ $site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $site_id ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
+
+ //获取打印机列表
+ $print_model = new Printer();
+ $printer_condition = [
+ [ 'site_id', '=', $site_id ]
+ ];
+ if (addon_is_exit('store', $site_id)) $printer_condition[] = [ 'store_id', '=', $store_id ];
+
+ switch ( $stage ) {
+ case 'order_pay':
+ $printer_condition[] = [ 'order_pay_open', '=', 1 ];
+ $printer_condition[] = [ 'order_pay_order_type', 'like', '%,' . $order_info[ 'order_type' ] . ',%' ];
+ break;
+ case 'take_delivery':
+ $printer_condition[] = [ 'take_delivery_open', '=', 1 ];
+ $printer_condition[] = [ 'take_delivery_order_type', 'like', '%,' . $order_info[ 'order_type' ] . ',%' ];
+ break;
+ case 'manual':
+ $printer_condition[] = [ 'manual_open', '=', 1 ];
+ break;
+ }
+
+ $printer_data = $print_model->getPrinterList($printer_condition)[ 'data' ] ?? [];
+ $res_data = [];
+
+ foreach ($printer_data as $k => $v) {
+ //此处应该根据打印机不同分别设置返回不同的数据。当前为易联云
+ $array = [];
+ $array[ 'printer_info' ] = $v;
+ $print_template_model = new PrinterTemplate();
+
+ $template_id = 0;
+ $print_num = 1;
+ switch ( $stage ) {
+ case 'order_pay':
+ //支付
+ $template_id = $v[ 'order_pay_template_id' ];
+ $print_num = $v[ 'order_pay_print_num' ];
+ break;
+ case 'take_delivery':
+ //收货
+ $template_id = $v[ 'take_delivery_template_id' ];
+ $print_num = $v[ 'take_delivery_print_num' ];
+ break;
+ case 'manual':
+ //手动打印
+ $template_id = $v[ 'template_id' ];
+ $print_num = $v[ 'print_num' ];
+ break;
+ }
+
+ $print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ] ])[ 'data' ];
+
+ $array[ 'printer_code' ] = $v[ 'printer_code' ]; //商户授权机器码
+ $array[ 'origin_id' ] = $order_info[ 'order_no' ]; //内部订单号(32位以内)
+ /**文本接口开始**/
+ $content = "" . $print_num . "";
+ //小票名称
+ if ($print_template[ 'title' ] != '') {
+ $content .= "" . $print_template[ 'title' ] . "";
+ $content .= str_repeat('.', 32);
+ }
+ //商城名称
+ if ($print_template[ 'head' ] == 1) {
+ $content .= "" . $site_name . "";
+ $content .= str_repeat('.', 32);
+ }
+
+ if (!empty($order_info[ 'pay_time' ])) {
+ $content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
+ } else {
+ $content .= "订单时间:" . date("Y-m-d H:i", time()) . "\n";
+ }
+ $content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
+ $content .= "支付方式:" . $order_info[ 'pay_type_name' ] . "\n";
+
+ switch ( $order_info[ 'order_type' ] ) {
+ case 1 :
+ // 物流订单
+ break;
+ case 2 :
+ // 自提订单
+ if ($order_info[ 'buyer_ask_delivery_time' ] == 0) {
+ $buyer_ask_delivery_time_str = '立即自提';
+ } elseif (strpos($order_info[ 'buyer_ask_delivery_time' ], '-') !== false) {
+ $buyer_ask_delivery_time_str = $order_info[ 'buyer_ask_delivery_time' ];
+ } else {
+ $buyer_ask_delivery_time_str = date("H:i:s", $order_info[ 'buyer_ask_delivery_time' ]);
+ }
+ $content .= "要求自提时间:" . $buyer_ask_delivery_time_str . "\n";
+ break;
+ case 3 :
+ // 外卖订单
+ if ($order_info[ 'buyer_ask_delivery_time' ] == 0) {
+ $buyer_ask_delivery_time_str = '立即送达';
+ } elseif (strpos($order_info[ 'buyer_ask_delivery_time' ], '-') !== false) {
+ $buyer_ask_delivery_time_str = $order_info[ 'buyer_ask_delivery_time' ];
+ } else {
+ $buyer_ask_delivery_time_str = date("H:i:s", $order_info[ 'buyer_ask_delivery_time' ]);
+ }
+ $content .= "要求送达时间:" . $buyer_ask_delivery_time_str . "\n";
+ break;
+ case 4 :
+ // 虚拟订单
+ break;
+ case 5 :
+ // 收银订单
+ break;
+ }
+
+ $content .= str_repeat('.', 32);
+ $content .= "";
+ $content .= "";
+ if ($print_template[ 'goods_price_show' ]) {
+ $content .= "| 商品名称 | | 数量 | 金额 | ";
+ } else {
+ $content .= "商品名称 | | | 数量 | ";
+ }
+ $content .= "
";
+ $content .= "
";
+ $content .= str_repeat('.', 32);
+ $content .= "";
+ foreach ($order_info[ 'order_goods' ] as $goods) {
+ //显示售价或卖价
+ $price = $print_template[ 'goods_price_type' ] == 'price' ? $goods[ 'price' ] : $goods[ 'real_goods_money' ];
+ if ($print_template[ 'goods_price_show' ]) {
+ $content .= "| " . $goods[ 'sku_name' ] . " | | x" . $goods[ 'num' ] . " | ¥" . $price . " |
";
+ } else {
+ $content .= "| " . $goods[ 'sku_name' ] . " | | | x" . $goods[ 'num' ] . " |
";
+ }
+
+ //商品编码
+ if ($print_template[ 'goods_code_show' ] && !empty($goods[ 'sku_no' ])) {
+ $content .= "| [" . $goods[ 'sku_no' ] . "] | | | |
";
+ }
+
+ }
+ $content .= "
";
+ $content .= str_repeat('.', 32);
+ if ($order_info[ "goods_money" ] > 0) {
+ $content .= "商品总额:¥" . $order_info[ "goods_money" ] . "\n";
+ }
+ if ($order_info[ "coupon_money" ] > 0) {
+ $content .= "店铺优惠券:¥" . $order_info[ "coupon_money" ] . "\n";
+ }
+ if ($order_info[ "promotion_money" ] > 0) {
+ $content .= "店铺优惠:¥" . $order_info[ "promotion_money" ] . "\n";
+ }
+ if ($order_info[ "point_money" ] > 0) {
+ $content .= "积分抵扣:¥" . $order_info[ "point_money" ] . "\n";
+ }
+ if ($order_info[ "adjust_money" ] > 0) {
+ $content .= "订单调价:¥" . $order_info[ "adjust_money" ] . "\n";
+ }
+ if ($order_info[ 'reduction' ] > 0) {
+ $content .= "订单减免:¥" . $order_info[ "reduction" ] . "\n";
+ }
+ if ($order_info[ "balance_money" ] > 0) {
+ $content .= "余额抵扣:¥" . $order_info[ "balance_money" ] . "\n";
+ }
+ if ($order_info[ "delivery_money" ] > 0) {
+ $content .= "配送费用:¥" . $order_info[ "delivery_money" ] . "\n";
+ }
+ if ($order_info[ "invoice_money" ] > 0) {
+ $content .= "发票费用:¥" . $order_info[ "invoice_money" ] . "\n";
+ }
+ if ($order_info[ "invoice_delivery_money" ] > 0) {
+ $content .= "发票邮寄费用:¥" . $order_info[ "invoice_delivery_money" ] . "\n";
+ }
+ if ($order_info[ "goods_num" ] > 0) {
+ $content .= "订单共" . $order_info[ 'goods_num' ] . "件商品,总计: ¥" . $order_info[ 'order_money' ] . " \n";
+ }
+ $content .= str_repeat('.', 32);
+
+ /******************** 备注信息 **************************/
+ //买家留言
+ if ($print_template[ 'buy_notes' ] == 1) {
+ $order_info[ "buyer_message" ] = $order_info[ "buyer_message" ] ? $order_info[ "buyer_message" ] : '无';
+ $content .= "买家留言:" . $order_info[ "buyer_message" ] . "\n";
+ $content .= str_repeat('.', 32);
+ }
+ //卖家留言
+ if ($print_template[ 'seller_notes' ] == 1) {
+ $order_info[ "remark" ] = $order_info[ "remark" ] ? $order_info[ "remark" ] : '无';
+ $content .= "卖家留言:" . $order_info[ "remark" ] . "\n";
+ $content .= str_repeat('.', 32);
+ }
+
+ //表单
+ if ($print_template[ 'form_show' ] == 1 && addon_is_exit('form')) {
+ $form_info = model('form_data')->getInfo([ [ 'site_id', '=', $site_id ], [ 'scene', '=', 'order' ], [ 'relation_id', '=', $order_id ] ]);
+ if (!empty($form_info) && !empty($form_info[ 'form_data' ])) {
+ $form_data = json_decode($form_info[ 'form_data' ], true);
+ foreach ($form_data as $item) {
+ $content .= "" . $item[ 'title' ] . ":" . $item[ "val" ] . "\n";
+ $content .= str_repeat('.', 32);
+ }
+ }
+ }
+
+ /******************** 买家信息 **************************/
+ if ($order_info[ 'member_id' ]) {
+ $member_info = model('member')->getInfo([['member_id', '=', $order_info[ 'member_id' ]]]);
+ //买家姓名
+ if ($print_template[ 'buy_name' ] == 1) {
+ if($order_info[ 'order_type' ] == 2){
+ $content .= "" . $member_info[ "nickname" ] . "\n";
+ }else{
+ $content .= "" . $order_info[ "name" ] . "\n";
+ }
+
+ }
+ //联系方式
+ if ($print_template[ 'buy_mobile' ] == 1) {
+ if($order_info[ 'order_type' ] == 2){
+ $content .= "" . $member_info[ "mobile" ] . "\n";
+ }else{
+ $content .= "" . $order_info[ "mobile" ] . "\n";
+ }
+
+ }
+ //地址
+ if ($print_template[ 'buy_address' ] == 1) {
+ if($order_info[ 'order_type' ] == 2){
+ $content .= "自提门店:" . $order_info[ 'delivery_store_name' ] . "\n";
+ }else{
+ $content .= "" . $order_info[ 'full_address' ] . "-" . $order_info[ 'address' ] . "\n";
+ }
+
+ }
+ if ($print_template[ 'buy_name' ] == 1 || $print_template[ 'buy_mobile' ] == 1 || $print_template[ 'buy_address' ] == 1) {
+ $content .= str_repeat('.', 32);
+ }
+ }
+ /******************** 商城信息 **************************/
+ //联系方式
+ if ($print_template[ 'shop_mobile' ] == 1) {
+ $content .= "" . $shop_info[ "mobile" ] . "\n";
+ }
+
+ //地址
+ if ($print_template[ 'shop_address' ] == 1) {
+ $content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
+ }
+
+ if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
+ $content .= str_repeat('.', 32);
+ }
+
+ //二维码
+ if ($print_template[ 'shop_qrcode' ] == 1) {
+ $content .= "" . $print_template[ 'qrcode_url' ] . "";
+ $content .= str_repeat('.', 32);
+ }
+
+ /******************** 门店信息 **************************/
+ if ($order_info[ 'store_id' ] > 0) {
+ $store_info = ( new Store() )->getStoreInfo([ [ 'store_id', '=', $order_info[ 'store_id' ] ] ], 'store_name,telphone,full_address')[ 'data' ];
+ $content .= "" . $order_info[ "store_name" ] . "\n";//门店名称
+ $content .= "" . $store_info[ "telphone" ] . "\n";//门店电话
+ $content .= "" . $store_info[ "full_address" ] . "\n";//门店地址
+ $content .= str_repeat('.', 32);
+ }
+
+ //底部内容
+ if (!empty($print_template[ 'bottom' ])) {
+ $content .= "" . $print_template[ 'bottom' ] . "";
+ }
+ $array[ 'content' ] = $content;
+
+ $res_data[] = $array;
+ }
+ return $res_data;
+
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/PrinterTemplate.php b/src/addon/printer/event/PrinterTemplate.php
index 34364ced0..7e48ca82d 100644
--- a/src/addon/printer/event/PrinterTemplate.php
+++ b/src/addon/printer/event/PrinterTemplate.php
@@ -1,28 +1,20 @@
-fetch($model->getTemplateType()[ $params[ 'type' ] ][ $action_type ]);
- }
+fetch($model->getTemplateType()[ $params[ 'type' ] ][ $action_type ]);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/PromotionType.php b/src/addon/printer/event/PromotionType.php
index 735e18d5e..73f2a361b 100644
--- a/src/addon/printer/event/PromotionType.php
+++ b/src/addon/printer/event/PromotionType.php
@@ -1,27 +1,19 @@
- "小票打印", "type" => "printer" ];
- }
+ "小票打印", "type" => "printer" ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/ShowPromotion.php b/src/addon/printer/event/ShowPromotion.php
index af1adb405..6bd7969c8 100644
--- a/src/addon/printer/event/ShowPromotion.php
+++ b/src/addon/printer/event/ShowPromotion.php
@@ -1,46 +1,38 @@
- [
- [
- //插件名称
- 'name' => 'printer',
- //店铺端展示分类 shop:营销活动 member:互动营销
- 'show_type' => 'tool',
- //展示主题
- 'title' => '小票打印',
- //展示介绍
- 'description' => '客户下单自动打印订单小票',
- //展示图标
- 'icon' => 'addon/printer/icon.png',
- //跳转链接
- 'url' => 'printer://shop/printer/lists',
- ]
- ]
-
- ];
- return $data;
- }
+ [
+ [
+ //插件名称
+ 'name' => 'printer',
+ //店铺端展示分类 shop:营销活动 member:互动营销
+ 'show_type' => 'tool',
+ //展示主题
+ 'title' => '小票打印',
+ //展示介绍
+ 'description' => '客户下单自动打印订单小票',
+ //展示图标
+ 'icon' => 'addon/printer/icon.png',
+ //跳转链接
+ 'url' => 'printer://shop/printer/lists',
+ ]
+ ]
+
+ ];
+ return $data;
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/event/UnInstall.php b/src/addon/printer/event/UnInstall.php
index 3b184937c..342ba138f 100644
--- a/src/addon/printer/event/UnInstall.php
+++ b/src/addon/printer/event/UnInstall.php
@@ -1,25 +1,17 @@
- '365','name' => '365'],
-// ['brand' => 'feie','name' => '飞鹅'],
- [ 'brand' => 'yilianyun', 'name' => '易联云' ],
- ];
-
- /**
- * 获取打印机品牌
- * @return array
- */
- public function getPrinterBrand()
- {
- return $this->brand;
- }
-
- /**
- * 添加小票打印
- * @param $data
- * @return array
- */
- public function addPrinter($data)
- {
-
- model('printer')->startTrans();
- try {
- $data[ 'create_time' ] = time();
- $res = model('printer')->add($data);
-
- //易联云
- if ($data[ 'printer_type' ] == 'cloud' && $data[ 'brand' ] == 'yilianyun') {
- $data[ 'printer_id' ] = $res;
- $result = $this->addPrinterYly($data);
-
- if ($result[ 'code' ] < 0) {
- model('printer')->rollback();
- return $result;
- }
- }
- model('printer')->commit();
- return $this->success($res);
- } catch (\Exception $e) {
- model('printer')->rollback();
- return $this->error('', '添加失败 ' . $e->getMessage());
- }
- }
-
- /**
- * 编辑小票打印
- * @param $data
- * @return array
- */
- public function editPrinter($data)
- {
- $data[ 'update_time' ] = time();
- $res = model('printer')->update($data, [ [ 'printer_id', '=', $data[ 'printer_id' ] ] ]);
- return $this->success($res);
- }
-
- /**
- * 删除
- * @param $condition
- * @return array
- */
- public function deletePrinter($condition)
- {
- model('printer')->startTrans();
- try {
- $printer_info = model('printer')->getInfo($condition, '*');
-
- $res = model('printer')->delete($condition);
- //易联云
- if ($printer_info[ 'printer_type' ] == 'cloud' && $printer_info[ 'brand' ] == 'yilianyun') {
-
- $result = $this->deletePrinterYly($printer_info);
- if ($result[ 'code' ] < 0) {
- model('printer')->rollback();
- return $result;
- }
- }
- model('printer')->commit();
- return $this->success($res);
- } catch (\Exception $e) {
- model('printer')->rollback();
- return $this->error('', $e->getMessage());
- }
- }
-
- /**
- * 获取小票打印信息
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getPrinterInfo($condition = [], $field = '*')
- {
- $res = model('printer')->getInfo($condition, $field);
- return $this->success($res);
- }
-
- /**
- * 获取小票打印列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @return array
- */
- public function getPrinterList($condition = [], $field = '*', $order = '', $limit = null)
- {
- $list = model('printer')->getList($condition, $field, $order, '', '', '', $limit);
- return $this->success($list);
- }
-
- /**
- * 获取小票打印分页列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getPrinterPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
- {
- $list = model('printer')->pageList($condition, $field, $order, $page, $page_size);
- return $this->success($list);
- }
-
- /**************************************************** 打印机管理(第三方) *********************************************************/
-
- /******************** 易联云 start ************************/
-
- /**
- * 设置易联云配置
- * @param $data
- * @return array
- */
- public function setYlyTokenConfig($data)
- {
- $config = new Config();
- $res = $config->setConfig($data, '易联云小票打印token', 1, [ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'PRINTER_YLYTOKEN' ] ]);
- return $this->success($res);
- }
-
- /**
- * 获取易联云配置
- * @param $site_id
- * @return array
- */
- public function getYlyTokenConfig($site_id)
- {
- $config = new Config();
- $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'PRINTER_YLYTOKEN' ] ]);
- if (empty($res[ 'data' ][ 'value' ])) {
- $res[ 'data' ][ 'value' ] = [
- 'access_token' => '',
- 'end_time' => '0'//token有效期
- ];
- }
- return $res;
- }
-
- /**
- * 获取易联云token
- * @param $yly_config
- * @param $site_id
- * @param int $type
- * @return mixed
- */
- public function getYlyToken($yly_config, $site_id, $type = 0)
- {
- //token配置
- $config_data = $this->getYlyTokenConfig($site_id);
- $config = $config_data[ 'data' ][ 'value' ];
-
- if ($config[ 'end_time' ] == 0 || $config[ 'end_time' ] < time() || $type == 1) {
- $client = new YlyOauthClient($yly_config);
- $token = $client->getToken(); //若是开放型应用请传授权码code
- $access_token = $token->access_token; //调用API凭证AccessToken
-
- //更新token
- $expires_in = $token->expires_in;
- $end_time = time() + $expires_in;
- $token_data = [
- 'site_id' => $site_id,
- 'access_token' => $token->access_token,
- 'end_time' => $end_time
- ];
- $this->setYlyTokenConfig($token_data);
- } else {
- $access_token = $config[ 'access_token' ];
- }
- return $access_token;
- }
-
- /**
- * 添加易联云打印机授权
- * @param $param
- * @return array|mixed
- */
- public function addPrinterYly($param)
- {
- $yly_config = new YlyConfig($param[ 'open_id' ], $param[ 'apikey' ]);
-
- $access_token = $this->getYlyToken($yly_config, $param[ 'printer_id' ]);
-
- //添加打印机
- $printer = new PrinterService($access_token, $yly_config);
- $data = $printer->addPrinter($param[ 'printer_code' ], $param[ 'printer_key' ], '', '');
-
- if (isset($data->error) && $data->error == 0) {
- return $this->success();
- } else {
- return $data;
- }
- }
-
- /**
- * 删除易联云打印机授权
- * @param $param
- * @return array|mixed
- */
- public function deletePrinterYly($param)
- {
-
- $yly_config = new YlyConfig($param[ 'open_id' ], $param[ 'apikey' ]);
- $access_token = $this->getYlyToken($yly_config, $param[ 'printer_id' ]);
-
- //添加打印机
- $printer = new PrinterService($access_token, $yly_config);
- $data = $printer->deletePrinter($param[ 'printer_code' ]);
- if (isset($data->error) && $data->error == 0) {
- return $this->success();
- } else {
- return $data;
- }
- }
-
- /**
- * 重新获取易联云token
- * @param $site_id
- * @return mixed
- */
- public function refreshToken($printer_id, $site_id)
- {
- model('config')->startTrans();
- try {
- //token配置
- $printer_info = model('printer')->getInfo([ [ 'site_id', '=', $site_id ], [ 'printer_id', '=', $printer_id ] ], '*');
- $yly_config = new YlyConfig($printer_info[ 'open_id' ], $printer_info[ 'apikey' ]);
- $client = new YlyOauthClient($yly_config);
-
- $token = $client->getToken(); // 若是开放型应用请传授权码code
-
- //更新token
- $expires_in = $token->expires_in;
- $end_time = strtotime('+' . $expires_in / 86400 . 'day');
- $token_data = [
- 'site_id' => $printer_id,
- 'access_token' => $token->access_token,
- 'end_time' => $end_time
- ];
- $this->setYlyTokenConfig($token_data);
-
- model('config')->commit();
- return $this->success();
- } catch (\Exception $e) {
- model('config')->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
- /******************** 易联云 end ************************/
-
+ '365','name' => '365'],
+// ['brand' => 'feie','name' => '飞鹅'],
+ [ 'brand' => 'yilianyun', 'name' => '易联云' ],
+ ];
+
+ /**
+ * 获取打印机品牌
+ * @return array
+ */
+ public function getPrinterBrand()
+ {
+ return $this->brand;
+ }
+
+ /**
+ * 添加小票打印
+ * @param $data
+ * @return array
+ */
+ public function addPrinter($data)
+ {
+
+ model('printer')->startTrans();
+ try {
+ $data[ 'create_time' ] = time();
+ $res = model('printer')->add($data);
+
+ //易联云
+ if ($data[ 'printer_type' ] == 'cloud' && $data[ 'brand' ] == 'yilianyun') {
+ $data[ 'printer_id' ] = $res;
+ $result = $this->addPrinterYly($data);
+
+ if ($result[ 'code' ] < 0) {
+ model('printer')->rollback();
+ return $result;
+ }
+ }
+ model('printer')->commit();
+ return $this->success($res);
+ } catch (\Exception $e) {
+ model('printer')->rollback();
+ return $this->error('', '添加失败 ' . $e->getMessage());
+ }
+ }
+
+ /**
+ * 编辑小票打印
+ * @param $data
+ * @return array
+ */
+ public function editPrinter($data)
+ {
+ $data[ 'update_time' ] = time();
+ $res = model('printer')->update($data, [ [ 'printer_id', '=', $data[ 'printer_id' ] ] ]);
+ return $this->success($res);
+ }
+
+ /**
+ * 删除
+ * @param $condition
+ * @return array
+ */
+ public function deletePrinter($condition)
+ {
+ model('printer')->startTrans();
+ try {
+ $printer_info = model('printer')->getInfo($condition, '*');
+
+ $res = model('printer')->delete($condition);
+ //易联云
+ if ($printer_info[ 'printer_type' ] == 'cloud' && $printer_info[ 'brand' ] == 'yilianyun') {
+
+ $result = $this->deletePrinterYly($printer_info);
+ if ($result[ 'code' ] < 0) {
+ model('printer')->rollback();
+ return $result;
+ }
+ }
+ model('printer')->commit();
+ return $this->success($res);
+ } catch (\Exception $e) {
+ model('printer')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+ }
+
+ /**
+ * 获取小票打印信息
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getPrinterInfo($condition = [], $field = '*')
+ {
+ $res = model('printer')->getInfo($condition, $field);
+ return $this->success($res);
+ }
+
+ /**
+ * 获取小票打印列表
+ * @param array $condition
+ * @param string $field
+ * @param string $order
+ * @param null $limit
+ * @return array
+ */
+ public function getPrinterList($condition = [], $field = '*', $order = '', $limit = null)
+ {
+ $list = model('printer')->getList($condition, $field, $order, '', '', '', $limit);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取小票打印分页列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @return array
+ */
+ public function getPrinterPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
+ {
+ $list = model('printer')->pageList($condition, $field, $order, $page, $page_size);
+ return $this->success($list);
+ }
+
+ /**************************************************** 打印机管理(第三方) *********************************************************/
+
+ /******************** 易联云 start ************************/
+
+ /**
+ * 设置易联云配置
+ * @param $data
+ * @return array
+ */
+ public function setYlyTokenConfig($data)
+ {
+ $config = new Config();
+ $res = $config->setConfig($data, '易联云小票打印token', 1, [ [ 'site_id', '=', $data[ 'site_id' ] ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'PRINTER_YLYTOKEN' ] ]);
+ return $this->success($res);
+ }
+
+ /**
+ * 获取易联云配置
+ * @param $site_id
+ * @return array
+ */
+ public function getYlyTokenConfig($site_id)
+ {
+ $config = new Config();
+ $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'PRINTER_YLYTOKEN' ] ]);
+ if (empty($res[ 'data' ][ 'value' ])) {
+ $res[ 'data' ][ 'value' ] = [
+ 'access_token' => '',
+ 'end_time' => '0'//token有效期
+ ];
+ }
+ return $res;
+ }
+
+ /**
+ * 获取易联云token
+ * @param $yly_config
+ * @param $site_id
+ * @param int $type
+ * @return mixed
+ */
+ public function getYlyToken($yly_config, $site_id, $type = 0)
+ {
+ //token配置
+ $config_data = $this->getYlyTokenConfig($site_id);
+ $config = $config_data[ 'data' ][ 'value' ];
+
+ if ($config[ 'end_time' ] == 0 || $config[ 'end_time' ] < time() || $type == 1) {
+ $client = new YlyOauthClient($yly_config);
+ $token = $client->getToken(); //若是开放型应用请传授权码code
+ $access_token = $token->access_token; //调用API凭证AccessToken
+
+ //更新token
+ $expires_in = $token->expires_in;
+ $end_time = time() + $expires_in;
+ $token_data = [
+ 'site_id' => $site_id,
+ 'access_token' => $token->access_token,
+ 'end_time' => $end_time
+ ];
+ $this->setYlyTokenConfig($token_data);
+ } else {
+ $access_token = $config[ 'access_token' ];
+ }
+ return $access_token;
+ }
+
+ /**
+ * 添加易联云打印机授权
+ * @param $param
+ * @return array|mixed
+ */
+ public function addPrinterYly($param)
+ {
+ $yly_config = new YlyConfig($param[ 'open_id' ], $param[ 'apikey' ]);
+
+ $access_token = $this->getYlyToken($yly_config, $param[ 'printer_id' ]);
+
+ //添加打印机
+ $printer = new PrinterService($access_token, $yly_config);
+ $data = $printer->addPrinter($param[ 'printer_code' ], $param[ 'printer_key' ], '', '');
+
+ if (isset($data->error) && $data->error == 0) {
+ return $this->success();
+ } else {
+ return $data;
+ }
+ }
+
+ /**
+ * 删除易联云打印机授权
+ * @param $param
+ * @return array|mixed
+ */
+ public function deletePrinterYly($param)
+ {
+
+ $yly_config = new YlyConfig($param[ 'open_id' ], $param[ 'apikey' ]);
+ $access_token = $this->getYlyToken($yly_config, $param[ 'printer_id' ]);
+
+ //添加打印机
+ $printer = new PrinterService($access_token, $yly_config);
+ $data = $printer->deletePrinter($param[ 'printer_code' ]);
+ if (isset($data->error) && $data->error == 0) {
+ return $this->success();
+ } else {
+ return $data;
+ }
+ }
+
+ /**
+ * 重新获取易联云token
+ * @param $site_id
+ * @return mixed
+ */
+ public function refreshToken($printer_id, $site_id)
+ {
+ model('config')->startTrans();
+ try {
+ //token配置
+ $printer_info = model('printer')->getInfo([ [ 'site_id', '=', $site_id ], [ 'printer_id', '=', $printer_id ] ], '*');
+ $yly_config = new YlyConfig($printer_info[ 'open_id' ], $printer_info[ 'apikey' ]);
+ $client = new YlyOauthClient($yly_config);
+
+ $token = $client->getToken(); // 若是开放型应用请传授权码code
+
+ //更新token
+ $expires_in = $token->expires_in;
+ $end_time = strtotime('+' . $expires_in / 86400 . 'day');
+ $token_data = [
+ 'site_id' => $printer_id,
+ 'access_token' => $token->access_token,
+ 'end_time' => $end_time
+ ];
+ $this->setYlyTokenConfig($token_data);
+
+ model('config')->commit();
+ return $this->success();
+ } catch (\Exception $e) {
+ model('config')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
+ /******************** 易联云 end ************************/
+
}
\ No newline at end of file
diff --git a/src/addon/printer/model/PrinterOrder.php b/src/addon/printer/model/PrinterOrder.php
index 658822169..c83d66d91 100644
--- a/src/addon/printer/model/PrinterOrder.php
+++ b/src/addon/printer/model/PrinterOrder.php
@@ -1,411 +1,403 @@
-error('', '没有可用的打印机');
- if (isset($items[ 'code' ]) && $items[ 'code' ] != 0) return $items;
- $printer_model = new Printer();
- foreach ($items as $k => $v) {
- $printer = $v[ 'printer_info' ] ?? [];
-
- switch ( $printer[ 'brand' ] ) {
- case '365'://365打印机
- break;
- case 'feie'://飞鹅打印机
- break;
- case 'yilianyun'://易联云打印机
- try {
- $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]);
- $access_token = $printer_model->getYlyToken($config, $printer[ 'printer_id' ]);
- $machine_code = $v[ 'printer_code' ];//商户授权机器码
- $origin_id = $v[ 'origin_id' ]; //内部订单号(32位以内)
- $print = new PrintService($access_token, $config);
- $content = $v[ 'content' ];
- $print->index($machine_code, $content, $origin_id, $printer);
- } catch (\Exception $e) {
-// return $this->error('', $e->getMessage());
- }
- break;
- }
-
- }
-
- return $this->success($items);
- }
-
- /**
- * 订单打印
- */
- public function printOrder($data)
- {
-
-// //获取订单详情
-// $order_common_model = new OrderCommonModel();
-// $order_detail_result = $order_common_model->getOrderDetail($order_id);
-// $order_info = $order_detail_result['data'];
-//
-// if (empty($order_info)) {
-// return $this->success();
-// }
-//
-// //获取店铺信息
-// $shop_model = new Shop();
-// $shop = $shop_model->getShopInfo([['site_id', '=', $order_info['site_id']]]);
-// $shop_info = $shop['data'];
-//
-// //获取打印机列表
-// $print_model = new Printer();
-// $printer_data = $print_model->getPrinterList([['site_id', '=', $order_info['site_id']],['store_id','=',0]]);
-//
-// if($order_info['delivery_store_id'] == 0){
-// $store_printer_data['data'] = [];
-// }else{
-// $store_printer_data = $print_model->getPrinterList([['site_id', '=', $order_info['site_id']], ['order_type', 'like', '%,' . $order_info['order_type'] . ',%'],['store_id','=',$order_info['delivery_store_id']]]);
-// }
-// if (empty($printer_data['data']) && empty($store_printer_data['data'])) {
-// return $this->success();
-// }
-//
-// $printer_list = array_merge($printer_data['data'],$store_printer_data['data']);
-// foreach ($printer_list as $v) {
-//
-// switch ($v['brand']) {
-//
-// case '365'://365打印机
-//
-// break;
-// case 'feie'://飞鹅打印机
-//
-// break;
-// case 'yilianyun'://易联云打印机
-//
-// $this->Ylyprint($order_info, $v, $shop_info);
-// break;
-// }
-// }
-// return $this->success();
- }
-
- /**
- * 【测试】易联云打印
- * @param $order_info
- * @param $printer
- * @param $shop_info
- */
- public function Ylyprint($order_info, $printer, $shop_info)
- {
- //打印模板
- $print_template_model = new PrinterTemplate();
- $print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $printer[ 'template_id' ] ] ])['data'];
-
- $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]);
- $printer_model = new Printer();
- $access_token = $printer_model->getYlyToken($config, $printer[ 'printer_id' ]);
- $machine_code = $printer[ 'printer_code' ]; //商户授权机器码
- $origin_id = $order_info[ 'order_no' ]; //内部订单号(32位以内)
-
- $site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $printer[ 'site_id' ] ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
-
- /**文本接口开始**/
- $print = new PrintService($access_token, $config);
- $content = "" . $printer[ 'print_num' ] . "";
- //小票名称
- if ($print_template[ 'title' ] != '') {
- $content .= "" . $print_template[ 'title' ] . "";
- $content .= str_repeat('.', 32);
- }
- //商城名称
- if ($print_template[ 'head' ] == 1) {
- $content .= "" . $site_name . "";
- $content .= str_repeat('.', 32);
- }
- if (!empty($order_info[ 'pay_time' ])) {
- $content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
- } else {
- $content .= "订单时间:" . date("Y-m-d H:i", time()) . "\n";
- }
- $content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
-
- $content .= str_repeat('.', 32);
- $content .= "";
- $content .= "| 商品名称 | | 数量 | 金额 |
";
- $content .= "
";
- $content .= str_repeat('.', 32);
- $content .= "";
- foreach ($order_info[ 'order_goods' ] as $goods) {
-
- $sku_name_list = $this->r_str_pad_1($goods[ 'sku_name' ], 7);
- foreach ($sku_name_list as $index => $value) {
- if ($index == 0) {
- $content .= "| " . $value . " | | x" . numberFormat($goods[ 'num' ]) . " | ¥" . $goods[ 'price' ] . " |
";
- } else {
- $content .= "| " . $value . " |
";
- }
- }
- }
- $content .= "
";
- $content .= str_repeat('.', 32);
- if ($order_info[ "goods_money" ] > 0) {
- $content .= "商品总额:¥" . $order_info[ "goods_money" ] . "\n";
- }
- if ($order_info[ "coupon_money" ] > 0) {
- $content .= "店铺优惠券:¥" . $order_info[ "coupon_money" ] . "\n";
- }
- if ($order_info[ "promotion_money" ] > 0) {
- $content .= "店铺优惠:¥" . $order_info[ "promotion_money" ] . "\n";
- }
- if ($order_info[ "point_money" ] > 0) {
- $content .= "积分抵扣:¥" . $order_info[ "point_money" ] . "\n";
- }
- if ($order_info[ "adjust_money" ] > 0) {
- $content .= "订单调价:¥" . $order_info[ "adjust_money" ] . "\n";
- }
- if ($order_info[ 'reduction' ] > 0) {
- $content .= "订单减免:¥" . $order_info[ "reduction" ] . "\n";
- }
- if ($order_info[ "balance_money" ] > 0) {
- $content .= "余额抵扣:¥" . $order_info[ "balance_money" ] . "\n";
- }
- if ($order_info[ "delivery_money" ] > 0) {
- $content .= "配送费用:¥" . $order_info[ "delivery_money" ] . "\n";
- }
- if ($order_info[ "invoice_money" ] > 0) {
- $content .= "发票费用:¥" . $order_info[ "invoice_money" ] . "\n";
- }
- if ($order_info[ "invoice_delivery_money" ] > 0) {
- $content .= "发票邮寄费用:¥" . $order_info[ "invoice_delivery_money" ] . "\n";
- }
- if ($order_info[ "goods_num" ] > 0) {
- $content .= "订单共" . numberFormat($order_info[ 'goods_num' ]) . "件商品,总计: ¥" . $order_info[ 'order_money' ] . " \n";
- }
- $content .= str_repeat('.', 32);
-
- /******************** 备注信息 **************************/
- //买家留言
- if ($print_template[ 'buy_notes' ] == 1) {
- $content .= "买家留言:" . $order_info[ "buyer_message" ] . "\n";
- $content .= str_repeat('.', 32);
- }
- //卖家留言
- if ($print_template[ 'seller_notes' ] == 1) {
- $content .= "卖家留言:" . $order_info[ "remark" ] . "\n";
- $content .= str_repeat('.', 32);
- }
-
- /******************** 买家信息 **************************/
- //买家姓名
- if ($print_template[ 'buy_name' ] == 1) {
- $content .= "" . $order_info[ "name" ] . "\n";
- }
- //联系方式
- if ($print_template[ 'buy_mobile' ] == 1) {
- $content .= "" . $order_info[ "mobile" ] . "\n";
- }
- //地址
- if ($print_template[ 'buy_address' ] == 1) {
- $content .= "" . $order_info[ 'full_address' ] . "-" . $order_info[ 'address' ] . "\n";
- }
- if ($print_template[ 'buy_name' ] == 1 || $print_template[ 'buy_mobile' ] == 1 || $print_template[ 'buy_address' ] == 1) {
- $content .= str_repeat('.', 32);
- }
- /******************** 商城信息 **************************/
- //联系方式
- if ($print_template[ 'shop_mobile' ] == 1) {
- $content .= "" . $shop_info[ "mobile" ] . "\n";
- }
- //地址
- if ($print_template[ 'shop_address' ] == 1) {
-
- $content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
- }
- if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
- $content .= str_repeat('.', 32);
- }
- //二维码
- if ($print_template[ 'shop_qrcode' ] == 1) {
- $content .= "" . $print_template[ 'qrcode_url' ] . "";
- $content .= str_repeat('.', 32);
- }
-
- /******************** 门店信息 **************************/
- if ($order_info[ 'delivery_store_id' ] > 0 && !empty($order_info[ 'delivery_store_name' ]) && !empty($order_info[ 'delivery_store_info' ])) {
- $store_info = json_decode($order_info[ 'delivery_store_info' ], true);
-
- $content .= "" . $order_info[ "delivery_store_name" ] . "\n";//门店名称
- $content .= "" . $store_info[ "telphone" ] . "\n";//门店电话
- $content .= "" . $store_info[ "full_address" ] . "\n";//门店地址
- $content .= str_repeat('.', 32);
- }
-
- //底部内容
- if (!empty($print_template[ 'bottom' ])) {
- $content .= "" . $print_template[ 'bottom' ] . "";
- }
-
- try {
- $print->index($machine_code, $content, $origin_id);
- } catch (\Exception $e) {
- echo $e->getMessage();
- }
- }
-
- /**
- * 补齐空格,每n个中文字符长度为一个数组元素
- * @param $input
- * @param int $n
- * @return array
- */
- public function r_str_pad_1($input, $n = 7)
- {
- $string = "";
- $count = 0;
- $c_count = 0;
- $arr = array ();
- for ($i = 0; $i < mb_strlen($input, 'UTF-8'); $i++) {
- $char = mb_substr($input, $i, 1, 'UTF-8');
- $string .= $char;
- if (strlen($char) == 3) {
- $count += 2;
- $c_count++;
- } else {
- $count += 1;
- }
- if ($count >= $n * 2) {
- $arr[] = $string;
- $string = '';
- $count = 0;
- $c_count = 0;
- }
- }
- if ($count < $n * 2) {
- $string = str_pad($string, $n * 2 + $c_count);
- $arr[] = $string;
- }
- return $arr;
- }
-
- /************************************************ 正式打印 end ******************************************************************/
-
-
- /************************************************ 测试打印 start ******************************************************************/
-
- /**
- * 测试打印
- * @param $printer_id
- * @param $site_id
- * @return array
- */
- public function testPrint($printer_id, $site_id)
- {
- //获取打印机列表
- $printer_info = model('printer')->getInfo([ [ 'site_id', '=', $site_id ], [ 'printer_id', '=', $printer_id ] ]);
- if (empty($printer_info)) {
- return $this->success();
- }
-
- switch ( $printer_info[ 'brand' ] ) {
- case '365':
- // 365打印机
- break;
- case 'feie':
- // 飞鹅打印机
- break;
- case 'yilianyun':
- // 易联云打印机
- $res = $this->testYlyprint($printer_info);
- break;
- }
- return $res;
- }
-
- /**
- * 测试打印
- * @param $printer
- * @return array
- */
- public function testYlyprint($printer)
- {
- $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]);
-
- $printer_model = new Printer();
- $access_token = $printer_model->getYlyToken($config, $printer[ 'printer_id' ]);
- $machine_code = $printer[ 'printer_code' ]; //商户授权机器码
- $origin_id = date('YmdHis') . rand(1, 999); //内部订单号(32位以内)
-
- /**文本接口开始**/
- $print = new PrintService($access_token, $config);
-
- $content = "" . $printer[ 'print_num' ] . "";
-
- $content .= "小票名称";
- $content .= str_repeat('.', 32);
- $content .= "商城名称";
- $content .= str_repeat('.', 32);
-
- $content .= "订单时间:" . date("Y-m-d H:i") . "\n";
- $content .= "订单编号:" . $origin_id . "\n";
-
- $content .= str_repeat('.', 32);
- $content .= "";
- $content .= "| 商品名称 | | 数量 | 金额 |
";
- $content .= "
";
- $content .= str_repeat('.', 32);
-
- $content .= "";
- $content .= "| 烤土豆(超级辣) | | x3 | 5 |
";
- $content .= "| 烤豆干(超级辣) | | x2 | 10 |
";
- $content .= "| 烤鸡翅(超级辣) | | x3 | 15 |
";
- $content .= "
";
- $content .= str_repeat('.', 32);
-
- $content .= "商品总额:¥30 \n";
- $content .= "订单共8件商品,总计: ¥30 \n";
- $content .= str_repeat('.', 32);
-
- /******************** 备注信息 **************************/
- //买家留言
-
- $content .= "买家留言:微辣,多放孜然\n";
- $content .= str_repeat('.', 32);
-
- $content .= "谢谢惠顾,欢迎下次光临";
-
- try {
-
- $res = $print->index($machine_code, $content, $origin_id);
- if ($res->error == 0) {
- return $this->success();
- } else {
- return $this->error('', $res->error_description);
- }
- } catch (\Exception $e) {
- return $this->error('', $e->getMessage());
- }
- }
-
+error('', '没有可用的打印机');
+ if (isset($items[ 'code' ]) && $items[ 'code' ] != 0) return $items;
+ $printer_model = new Printer();
+ foreach ($items as $k => $v) {
+ $printer = $v[ 'printer_info' ] ?? [];
+
+ switch ( $printer[ 'brand' ] ) {
+ case '365'://365打印机
+ break;
+ case 'feie'://飞鹅打印机
+ break;
+ case 'yilianyun'://易联云打印机
+ try {
+ $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]);
+ $access_token = $printer_model->getYlyToken($config, $printer[ 'printer_id' ]);
+ $machine_code = $v[ 'printer_code' ];//商户授权机器码
+ $origin_id = $v[ 'origin_id' ]; //内部订单号(32位以内)
+ $print = new PrintService($access_token, $config);
+ $content = $v[ 'content' ];
+ $print->index($machine_code, $content, $origin_id, $printer);
+ } catch (\Exception $e) {
+// return $this->error('', $e->getMessage());
+ }
+ break;
+ }
+
+ }
+
+ return $this->success($items);
+ }
+
+ /**
+ * 订单打印
+ */
+ public function printOrder($data)
+ {
+
+// //获取订单详情
+// $order_common_model = new OrderCommonModel();
+// $order_detail_result = $order_common_model->getOrderDetail($order_id);
+// $order_info = $order_detail_result['data'];
+//
+// if (empty($order_info)) {
+// return $this->success();
+// }
+//
+// //获取店铺信息
+// $shop_model = new Shop();
+// $shop = $shop_model->getShopInfo([['site_id', '=', $order_info['site_id']]]);
+// $shop_info = $shop['data'];
+//
+// //获取打印机列表
+// $print_model = new Printer();
+// $printer_data = $print_model->getPrinterList([['site_id', '=', $order_info['site_id']],['store_id','=',0]]);
+//
+// if($order_info['delivery_store_id'] == 0){
+// $store_printer_data['data'] = [];
+// }else{
+// $store_printer_data = $print_model->getPrinterList([['site_id', '=', $order_info['site_id']], ['order_type', 'like', '%,' . $order_info['order_type'] . ',%'],['store_id','=',$order_info['delivery_store_id']]]);
+// }
+// if (empty($printer_data['data']) && empty($store_printer_data['data'])) {
+// return $this->success();
+// }
+//
+// $printer_list = array_merge($printer_data['data'],$store_printer_data['data']);
+// foreach ($printer_list as $v) {
+//
+// switch ($v['brand']) {
+//
+// case '365'://365打印机
+//
+// break;
+// case 'feie'://飞鹅打印机
+//
+// break;
+// case 'yilianyun'://易联云打印机
+//
+// $this->Ylyprint($order_info, $v, $shop_info);
+// break;
+// }
+// }
+// return $this->success();
+ }
+
+ /**
+ * 【测试】易联云打印
+ * @param $order_info
+ * @param $printer
+ * @param $shop_info
+ */
+ public function Ylyprint($order_info, $printer, $shop_info)
+ {
+ //打印模板
+ $print_template_model = new PrinterTemplate();
+ $print_template = $print_template_model->getPrinterTemplateInfo([ [ 'template_id', '=', $printer[ 'template_id' ] ] ])['data'];
+
+ $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]);
+ $printer_model = new Printer();
+ $access_token = $printer_model->getYlyToken($config, $printer[ 'printer_id' ]);
+ $machine_code = $printer[ 'printer_code' ]; //商户授权机器码
+ $origin_id = $order_info[ 'order_no' ]; //内部订单号(32位以内)
+
+ $site_name = ( new Site() )->getSiteInfo([ [ 'site_id', '=', $printer[ 'site_id' ] ] ], 'site_name')[ 'data' ][ 'site_name' ] ?? '';
+
+ /**文本接口开始**/
+ $print = new PrintService($access_token, $config);
+ $content = "" . $printer[ 'print_num' ] . "";
+ //小票名称
+ if ($print_template[ 'title' ] != '') {
+ $content .= "" . $print_template[ 'title' ] . "";
+ $content .= str_repeat('.', 32);
+ }
+ //商城名称
+ if ($print_template[ 'head' ] == 1) {
+ $content .= "" . $site_name . "";
+ $content .= str_repeat('.', 32);
+ }
+ if (!empty($order_info[ 'pay_time' ])) {
+ $content .= "订单时间:" . date("Y-m-d H:i", $order_info[ 'pay_time' ]) . "\n";
+ } else {
+ $content .= "订单时间:" . date("Y-m-d H:i", time()) . "\n";
+ }
+ $content .= "订单编号:" . $order_info[ 'order_no' ] . "\n";
+
+ $content .= str_repeat('.', 32);
+ $content .= "";
+ $content .= "| 商品名称 | | 数量 | 金额 |
";
+ $content .= "
";
+ $content .= str_repeat('.', 32);
+ $content .= "";
+ foreach ($order_info[ 'order_goods' ] as $goods) {
+
+ $sku_name_list = $this->r_str_pad_1($goods[ 'sku_name' ], 7);
+ foreach ($sku_name_list as $index => $value) {
+ if ($index == 0) {
+ $content .= "| " . $value . " | | x" . numberFormat($goods[ 'num' ]) . " | ¥" . $goods[ 'price' ] . " |
";
+ } else {
+ $content .= "| " . $value . " |
";
+ }
+ }
+ }
+ $content .= "
";
+ $content .= str_repeat('.', 32);
+ if ($order_info[ "goods_money" ] > 0) {
+ $content .= "商品总额:¥" . $order_info[ "goods_money" ] . "\n";
+ }
+ if ($order_info[ "coupon_money" ] > 0) {
+ $content .= "店铺优惠券:¥" . $order_info[ "coupon_money" ] . "\n";
+ }
+ if ($order_info[ "promotion_money" ] > 0) {
+ $content .= "店铺优惠:¥" . $order_info[ "promotion_money" ] . "\n";
+ }
+ if ($order_info[ "point_money" ] > 0) {
+ $content .= "积分抵扣:¥" . $order_info[ "point_money" ] . "\n";
+ }
+ if ($order_info[ "adjust_money" ] > 0) {
+ $content .= "订单调价:¥" . $order_info[ "adjust_money" ] . "\n";
+ }
+ if ($order_info[ 'reduction' ] > 0) {
+ $content .= "订单减免:¥" . $order_info[ "reduction" ] . "\n";
+ }
+ if ($order_info[ "balance_money" ] > 0) {
+ $content .= "余额抵扣:¥" . $order_info[ "balance_money" ] . "\n";
+ }
+ if ($order_info[ "delivery_money" ] > 0) {
+ $content .= "配送费用:¥" . $order_info[ "delivery_money" ] . "\n";
+ }
+ if ($order_info[ "invoice_money" ] > 0) {
+ $content .= "发票费用:¥" . $order_info[ "invoice_money" ] . "\n";
+ }
+ if ($order_info[ "invoice_delivery_money" ] > 0) {
+ $content .= "发票邮寄费用:¥" . $order_info[ "invoice_delivery_money" ] . "\n";
+ }
+ if ($order_info[ "goods_num" ] > 0) {
+ $content .= "订单共" . numberFormat($order_info[ 'goods_num' ]) . "件商品,总计: ¥" . $order_info[ 'order_money' ] . " \n";
+ }
+ $content .= str_repeat('.', 32);
+
+ /******************** 备注信息 **************************/
+ //买家留言
+ if ($print_template[ 'buy_notes' ] == 1) {
+ $content .= "买家留言:" . $order_info[ "buyer_message" ] . "\n";
+ $content .= str_repeat('.', 32);
+ }
+ //卖家留言
+ if ($print_template[ 'seller_notes' ] == 1) {
+ $content .= "卖家留言:" . $order_info[ "remark" ] . "\n";
+ $content .= str_repeat('.', 32);
+ }
+
+ /******************** 买家信息 **************************/
+ //买家姓名
+ if ($print_template[ 'buy_name' ] == 1) {
+ $content .= "" . $order_info[ "name" ] . "\n";
+ }
+ //联系方式
+ if ($print_template[ 'buy_mobile' ] == 1) {
+ $content .= "" . $order_info[ "mobile" ] . "\n";
+ }
+ //地址
+ if ($print_template[ 'buy_address' ] == 1) {
+ $content .= "" . $order_info[ 'full_address' ] . "-" . $order_info[ 'address' ] . "\n";
+ }
+ if ($print_template[ 'buy_name' ] == 1 || $print_template[ 'buy_mobile' ] == 1 || $print_template[ 'buy_address' ] == 1) {
+ $content .= str_repeat('.', 32);
+ }
+ /******************** 商城信息 **************************/
+ //联系方式
+ if ($print_template[ 'shop_mobile' ] == 1) {
+ $content .= "" . $shop_info[ "mobile" ] . "\n";
+ }
+ //地址
+ if ($print_template[ 'shop_address' ] == 1) {
+
+ $content .= "" . $shop_info[ 'province_name' ] . $shop_info[ 'city_name' ] . $shop_info[ 'district_name' ] . $shop_info[ 'address' ] . "\n";
+ }
+ if ($print_template[ 'shop_mobile' ] == 1 || $print_template[ 'shop_address' ] == 1) {
+ $content .= str_repeat('.', 32);
+ }
+ //二维码
+ if ($print_template[ 'shop_qrcode' ] == 1) {
+ $content .= "" . $print_template[ 'qrcode_url' ] . "";
+ $content .= str_repeat('.', 32);
+ }
+
+ /******************** 门店信息 **************************/
+ if ($order_info[ 'delivery_store_id' ] > 0 && !empty($order_info[ 'delivery_store_name' ]) && !empty($order_info[ 'delivery_store_info' ])) {
+ $store_info = json_decode($order_info[ 'delivery_store_info' ], true);
+
+ $content .= "" . $order_info[ "delivery_store_name" ] . "\n";//门店名称
+ $content .= "" . $store_info[ "telphone" ] . "\n";//门店电话
+ $content .= "" . $store_info[ "full_address" ] . "\n";//门店地址
+ $content .= str_repeat('.', 32);
+ }
+
+ //底部内容
+ if (!empty($print_template[ 'bottom' ])) {
+ $content .= "" . $print_template[ 'bottom' ] . "";
+ }
+
+ try {
+ $print->index($machine_code, $content, $origin_id);
+ } catch (\Exception $e) {
+ echo $e->getMessage();
+ }
+ }
+
+ /**
+ * 补齐空格,每n个中文字符长度为一个数组元素
+ * @param $input
+ * @param int $n
+ * @return array
+ */
+ public function r_str_pad_1($input, $n = 7)
+ {
+ $string = "";
+ $count = 0;
+ $c_count = 0;
+ $arr = array ();
+ for ($i = 0; $i < mb_strlen($input, 'UTF-8'); $i++) {
+ $char = mb_substr($input, $i, 1, 'UTF-8');
+ $string .= $char;
+ if (strlen($char) == 3) {
+ $count += 2;
+ $c_count++;
+ } else {
+ $count += 1;
+ }
+ if ($count >= $n * 2) {
+ $arr[] = $string;
+ $string = '';
+ $count = 0;
+ $c_count = 0;
+ }
+ }
+ if ($count < $n * 2) {
+ $string = str_pad($string, $n * 2 + $c_count);
+ $arr[] = $string;
+ }
+ return $arr;
+ }
+
+ /************************************************ 正式打印 end ******************************************************************/
+
+
+ /************************************************ 测试打印 start ******************************************************************/
+
+ /**
+ * 测试打印
+ * @param $printer_id
+ * @param $site_id
+ * @return array
+ */
+ public function testPrint($printer_id, $site_id)
+ {
+ //获取打印机列表
+ $printer_info = model('printer')->getInfo([ [ 'site_id', '=', $site_id ], [ 'printer_id', '=', $printer_id ] ]);
+ if (empty($printer_info)) {
+ return $this->success();
+ }
+
+ switch ( $printer_info[ 'brand' ] ) {
+ case '365':
+ // 365打印机
+ break;
+ case 'feie':
+ // 飞鹅打印机
+ break;
+ case 'yilianyun':
+ // 易联云打印机
+ $res = $this->testYlyprint($printer_info);
+ break;
+ }
+ return $res;
+ }
+
+ /**
+ * 测试打印
+ * @param $printer
+ * @return array
+ */
+ public function testYlyprint($printer)
+ {
+ $config = new YlyConfig($printer[ 'open_id' ], $printer[ 'apikey' ]);
+
+ $printer_model = new Printer();
+ $access_token = $printer_model->getYlyToken($config, $printer[ 'printer_id' ]);
+ $machine_code = $printer[ 'printer_code' ]; //商户授权机器码
+ $origin_id = date('YmdHis') . rand(1, 999); //内部订单号(32位以内)
+
+ /**文本接口开始**/
+ $print = new PrintService($access_token, $config);
+
+ $content = "" . $printer[ 'print_num' ] . "";
+
+ $content .= "小票名称";
+ $content .= str_repeat('.', 32);
+ $content .= "商城名称";
+ $content .= str_repeat('.', 32);
+
+ $content .= "订单时间:" . date("Y-m-d H:i") . "\n";
+ $content .= "订单编号:" . $origin_id . "\n";
+
+ $content .= str_repeat('.', 32);
+ $content .= "";
+ $content .= "| 商品名称 | | 数量 | 金额 |
";
+ $content .= "
";
+ $content .= str_repeat('.', 32);
+
+ $content .= "";
+ $content .= "| 烤土豆(超级辣) | | x3 | 5 |
";
+ $content .= "| 烤豆干(超级辣) | | x2 | 10 |
";
+ $content .= "| 烤鸡翅(超级辣) | | x3 | 15 |
";
+ $content .= "
";
+ $content .= str_repeat('.', 32);
+
+ $content .= "商品总额:¥30 \n";
+ $content .= "订单共8件商品,总计: ¥30 \n";
+ $content .= str_repeat('.', 32);
+
+ /******************** 备注信息 **************************/
+ //买家留言
+
+ $content .= "买家留言:微辣,多放孜然\n";
+ $content .= str_repeat('.', 32);
+
+ $content .= "谢谢惠顾,欢迎下次光临";
+
+ try {
+
+ $res = $print->index($machine_code, $content, $origin_id);
+ if ($res->error == 0) {
+ return $this->success();
+ } else {
+ return $this->error('', $res->error_description);
+ }
+ } catch (\Exception $e) {
+ return $this->error('', $e->getMessage());
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/printer/model/PrinterTemplate.php b/src/addon/printer/model/PrinterTemplate.php
index 4148259c5..11b6f7758 100644
--- a/src/addon/printer/model/PrinterTemplate.php
+++ b/src/addon/printer/model/PrinterTemplate.php
@@ -1,114 +1,106 @@
- [
- 'type' => 'goodsorder',
- 'type_name' => '商品订单',
- 'edit' => 'addon/printer/shop/view/template/goodsorder_template.html',
- 'add' => 'addon/printer/shop/view/template/goodsorder_template.html',
- ]
- ];
-
- public function getTemplateType()
- {
- $type = $this->type;
- $other_type = event('PrinterTemplateType', []);
- foreach ($other_type as $k => $v) {
- foreach ($v as $val) {
- $type[ $val[ 'type' ] ] = $val;
- }
- }
- return $type;
- }
-
- /**
- * 添加打印模板
- * @param $data
- * @return array
- */
- public function addPrinterTemplate($data)
- {
- $data[ 'create_time' ] = time();
- $res = model('printer_template')->add($data);
- return $this->success($res);
- }
-
- /**
- * 编辑打印模板
- * @param $data
- * @return array
- */
- public function editPrinterTemplate($data)
- {
- $data[ 'update_time' ] = time();
- $res = model('printer_template')->update($data, [ [ 'template_id', '=', $data[ 'template_id' ] ] ]);
- return $this->success($res);
- }
-
- /**
- * 删除
- * @param $condition
- * @return array
- */
- public function deletePrinterTemplate($condition)
- {
- $res = model('printer_template')->delete($condition);
- return $this->success($res);
- }
-
- /**
- * 获取打印模板信息
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getPrinterTemplateInfo($condition = [], $field = '*')
- {
- $res = model('printer_template')->getInfo($condition, $field);
- return $this->success($res);
- }
-
- /**
- * 获取打印模板列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @return array
- */
- public function getPrinterTemplateList($condition = [], $field = '*', $order = '', $limit = null)
- {
- $list = model('printer_template')->getList($condition, $field, $order, '', '', '', $limit);
- return $this->success($list);
- }
-
- /**
- * 获取打印模板分页列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return array
- */
- public function getPrinterTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
- {
- $list = model('printer_template')->pageList($condition, $field, $order, $page, $page_size);
- return $this->success($list);
- }
-
+ [
+ 'type' => 'goodsorder',
+ 'type_name' => '商品订单',
+ 'edit' => 'addon/printer/shop/view/template/goodsorder_template.html',
+ 'add' => 'addon/printer/shop/view/template/goodsorder_template.html',
+ ]
+ ];
+
+ public function getTemplateType()
+ {
+ $type = $this->type;
+ $other_type = event('PrinterTemplateType', []);
+ foreach ($other_type as $k => $v) {
+ foreach ($v as $val) {
+ $type[ $val[ 'type' ] ] = $val;
+ }
+ }
+ return $type;
+ }
+
+ /**
+ * 添加打印模板
+ * @param $data
+ * @return array
+ */
+ public function addPrinterTemplate($data)
+ {
+ $data[ 'create_time' ] = time();
+ $res = model('printer_template')->add($data);
+ return $this->success($res);
+ }
+
+ /**
+ * 编辑打印模板
+ * @param $data
+ * @return array
+ */
+ public function editPrinterTemplate($data)
+ {
+ $data[ 'update_time' ] = time();
+ $res = model('printer_template')->update($data, [ [ 'template_id', '=', $data[ 'template_id' ] ] ]);
+ return $this->success($res);
+ }
+
+ /**
+ * 删除
+ * @param $condition
+ * @return array
+ */
+ public function deletePrinterTemplate($condition)
+ {
+ $res = model('printer_template')->delete($condition);
+ return $this->success($res);
+ }
+
+ /**
+ * 获取打印模板信息
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getPrinterTemplateInfo($condition = [], $field = '*')
+ {
+ $res = model('printer_template')->getInfo($condition, $field);
+ return $this->success($res);
+ }
+
+ /**
+ * 获取打印模板列表
+ * @param array $condition
+ * @param string $field
+ * @param string $order
+ * @param null $limit
+ * @return array
+ */
+ public function getPrinterTemplateList($condition = [], $field = '*', $order = '', $limit = null)
+ {
+ $list = model('printer_template')->getList($condition, $field, $order, '', '', '', $limit);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取打印模板分页列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @return array
+ */
+ public function getPrinterTemplatePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
+ {
+ $list = model('printer_template')->pageList($condition, $field, $order, $page, $page_size);
+ return $this->success($list);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/printer/shop/controller/BaseController.php b/src/addon/printer/shop/controller/BaseController.php
index bb44f2522..7c4ffeed5 100644
--- a/src/addon/printer/shop/controller/BaseController.php
+++ b/src/addon/printer/shop/controller/BaseController.php
@@ -1,27 +1,19 @@
- __ROOT__ . '/addon/printer/shop/view/public/css',
- 'SHOP_ADDON_IMG' => __ROOT__ . '/addon/printer/shop/view/public/img',
- 'SHOP_ADDON_JS' => __ROOT__ . '/addon/printer/shop/view/public/js',
- ]);
- return parent::fetch($template, $replace, $config);
- }
+ __ROOT__ . '/addon/printer/shop/view/public/css',
+ 'SHOP_ADDON_IMG' => __ROOT__ . '/addon/printer/shop/view/public/img',
+ 'SHOP_ADDON_JS' => __ROOT__ . '/addon/printer/shop/view/public/js',
+ ]);
+ return parent::fetch($template, $replace, $config);
+ }
}
\ No newline at end of file
diff --git a/src/addon/printer/shop/controller/Printer.php b/src/addon/printer/shop/controller/Printer.php
index 665857d5d..a371420de 100644
--- a/src/addon/printer/shop/controller/Printer.php
+++ b/src/addon/printer/shop/controller/Printer.php
@@ -1,269 +1,261 @@
-isJson()) {
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $list = $model->getPrinterPageList($condition, $page, $page_size, 'printer_id desc');
- return $list;
- }
- return $this->fetch("printer/lists");
- }
-
- /**
- * 添加小票打印
- */
- public function add()
- {
- $model = new PrinterModel();
- if (request()->isJson()) {
- $data = [
- 'site_id' => $this->site_id,
- 'printer_name' => input('printer_name', ''),
- 'brand' => input('brand', ''),
- 'printer_code' => input('printer_code', ''),
- 'printer_key' => input('printer_key', ''),
- 'open_id' => input('open_id', ''),
- 'apikey' => input('apikey', ''),
- 'store_id' => input('store_id', ''),
- 'printer_type' => input('printer_type', ''),
-
- //订单
- 'order_pay_open' => input('order_pay_open', 0),
- 'order_pay_template_id' => input('order_pay_template_id', 0),
- 'order_pay_print_num' => input('order_pay_print_num', 1),
- 'order_pay_order_type' => input('order_pay_order_type', ''),
-
- 'take_delivery_open' => input('take_delivery_open', 0),
- 'take_delivery_template_id' => input('take_delivery_template_id', 0),
- 'take_delivery_print_num' => input('take_delivery_print_num', 1),
- 'take_delivery_order_type' => input('take_delivery_order_type', ''),
-
- 'manual_open' => input('manual_open', 0),
- 'template_id' => input('template_id', 0),
- 'print_num' => input('print_num', 1),
-
- //充值
- 'recharge_open' => input('recharge_open', 0),
- 'recharge_template_id' => input('recharge_template_id', 0),
- 'recharge_print_num' => input('recharge_print_num', 1),
-
- 'change_shifts_open' => input('change_shifts_open', 0),
- 'change_shifts_template_id' => input('change_shifts_template_id', 0),
- 'change_shifts_print_num' => input('change_shifts_print_num', 1),
-
- 'host' => input('host', ''),
- 'ip' => input('ip', ''),
- 'port' => input('port', ''),
- 'print_width' => input('print_width', '58mm')
-
- ];
- if ($data[ 'order_pay_order_type' ]) $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
- if ($data[ 'take_delivery_order_type' ]) $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
- return $model->addPrinter($data);
-
- } else {
- //模板列表
- $template_model = new PrinterTemplate();
- $condition = [
- [ 'site_id', '=', $this->site_id ],
- ];
- $template_list = $template_model->getPrinterTemplateList($condition, 'template_id,template_name,type', 'template_id desc');
- $this->assign('template_list', $template_list[ 'data' ]);
-
- //打印机品牌
- $brand = $model->getPrinterBrand();
- $this->assign('brand', $brand);
-
- //订单类型
- $order_common_model = new OrderCommonModel();
- $order_type_list = $order_common_model->getOrderTypeStatusList();
- unset($order_type_list[ 'all' ]);
- $this->assign("order_type_list", $order_type_list);
-
- $is_exit_store = addon_is_exit('store');
- if ($is_exit_store == 1) {
- $store_model = new Store();
- $store_field = 'store_id,store_name';
- $store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ], $store_field);
- $this->assign('store_list', $store_list[ 'data' ]);
- }
- $this->assign('is_exit_store', $is_exit_store);
- return $this->fetch("printer/add");
- }
- }
-
- /**
- * 编辑小票打印
- */
- public function edit()
- {
- $model = new PrinterModel();
- $printer_id = input('printer_id', 0);
- if (request()->isJson()) {
- $data = [
- 'printer_id' => $printer_id,
-
- 'site_id' => $this->site_id,
- 'printer_name' => input('printer_name', ''),
- 'brand' => input('brand', ''),
- 'printer_code' => input('printer_code', ''),
- 'printer_key' => input('printer_key', ''),
- 'open_id' => input('open_id', ''),
- 'apikey' => input('apikey', ''),
- 'store_id' => input('store_id', ''),
- 'printer_type' => input('printer_type', ''),
-
- //订单
- 'order_pay_open' => input('order_pay_open', 0),
- 'order_pay_template_id' => input('order_pay_template_id', 0),
- 'order_pay_print_num' => input('order_pay_print_num', 1),
- 'order_pay_order_type' => input('order_pay_order_type', ''),
-
- 'take_delivery_open' => input('take_delivery_open', 0),
- 'take_delivery_template_id' => input('take_delivery_template_id', 0),
- 'take_delivery_print_num' => input('take_delivery_print_num', 1),
- 'take_delivery_order_type' => input('take_delivery_order_type', ''),
-
- 'manual_open' => input('manual_open', 0),
- 'template_id' => input('template_id', 0),
- 'print_num' => input('print_num', 1),
-
- //充值
- 'recharge_open' => input('recharge_open', 0),
- 'recharge_template_id' => input('recharge_template_id', 0),
- 'recharge_print_num' => input('recharge_print_num', 1),
-
- 'change_shifts_open' => input('change_shifts_open', 0),
- 'change_shifts_template_id' => input('change_shifts_template_id', 0),
- 'change_shifts_print_num' => input('change_shifts_print_num', 1),
-
- 'host' => input('host', ''),
- 'ip' => input('ip', ''),
- 'port' => input('port', ''),
- 'print_width' => input('print_width', '58mm')
- ];
-
- if ($data[ 'order_pay_order_type' ]) $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
- if ($data[ 'take_delivery_order_type' ]) $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
-
- return $model->editPrinter($data);
- } else {
-
- $info = $model->getPrinterInfo([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $this->site_id ] ]);
- $info[ 'data' ][ 'take_delivery_order_type' ] = explode(',', $info[ 'data' ][ 'take_delivery_order_type' ]);
- $info[ 'data' ][ 'order_pay_order_type' ] = explode(',', $info[ 'data' ][ 'order_pay_order_type' ]);
- $this->assign('printer_info', $info[ 'data' ]);
-
- //模板列表
- $template_model = new PrinterTemplate();
- $condition = [
- [ 'site_id', '=', $this->site_id ],
- ];
- $template_list = $template_model->getPrinterTemplateList($condition, 'template_id,template_name,type', 'template_id desc');
- $this->assign('template_list', $template_list[ 'data' ]);
-
- //打印机品牌
- $brand = $model->getPrinterBrand();
- $this->assign('brand', $brand);
-
- //订单类型
- $order_common_model = new OrderCommonModel();
- $order_type_list = $order_common_model->getOrderTypeStatusList();
- unset($order_type_list[ 'all' ]);
- $this->assign("order_type_list", $order_type_list);
-
- //是否存在门店
- $is_exit_store = addon_is_exit('store');
- if ($is_exit_store == 1) {
- $store_model = new Store();
- $store_field = 'store_id,store_name';
- $store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ], $store_field);
- $this->assign('store_list', $store_list[ 'data' ]);
- }
- $this->assign('is_exit_store', $is_exit_store);
- return $this->fetch("printer/edit");
- }
- }
-
- /*
- * 删除
- */
- public function delete()
- {
- $printer_id = input('printer_id', '');
-
- $printer_model = new PrinterModel();
- return $printer_model->deletePrinter([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $this->site_id ] ]);
- }
-
- /**
- * 测试打印
- */
- public function testPrint()
- {
- $printer_id = input('printer_id', '');
- $print_model = new PrinterOrder();
- $res = $print_model->testPrint($printer_id, $this->site_id);
- return $res;
- }
-
- /**
- * 刷新token
- */
- public function refreshToken()
- {
- $printer_id = input('printer_id', '');
- $print_model = new PrinterModel();
- $res = $print_model->refreshToken($printer_id, $this->site_id);
- return $res;
- }
-
- /**
- * 测试打印
- */
- public function test()
- {
-// $print_model = new PrinterOrder();
-// $res = $print_model->printer([
-//// 'order_id' => '5630',
-//// 'type' => 'goodsorder',
-//// 'printer_type' => 'order_pay',
-//// 'site_id' => $this->site_id
-// 'order_id' => '32',
-// 'type' => 'recharge',
-// 'site_id' => $this->site_id
-// ]);
-// return $res;
- $res = event('MemberRechargeOrderPayPrinter', [
- 'relate_id' => 66
- ]);
- }
-
+isJson()) {
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $list = $model->getPrinterPageList($condition, $page, $page_size, 'printer_id desc');
+ return $list;
+ }
+ return $this->fetch("printer/lists");
+ }
+
+ /**
+ * 添加小票打印
+ */
+ public function add()
+ {
+ $model = new PrinterModel();
+ if (request()->isJson()) {
+ $data = [
+ 'site_id' => $this->site_id,
+ 'printer_name' => input('printer_name', ''),
+ 'brand' => input('brand', ''),
+ 'printer_code' => input('printer_code', ''),
+ 'printer_key' => input('printer_key', ''),
+ 'open_id' => input('open_id', ''),
+ 'apikey' => input('apikey', ''),
+ 'store_id' => input('store_id', ''),
+ 'printer_type' => input('printer_type', ''),
+
+ //订单
+ 'order_pay_open' => input('order_pay_open', 0),
+ 'order_pay_template_id' => input('order_pay_template_id', 0),
+ 'order_pay_print_num' => input('order_pay_print_num', 1),
+ 'order_pay_order_type' => input('order_pay_order_type', ''),
+
+ 'take_delivery_open' => input('take_delivery_open', 0),
+ 'take_delivery_template_id' => input('take_delivery_template_id', 0),
+ 'take_delivery_print_num' => input('take_delivery_print_num', 1),
+ 'take_delivery_order_type' => input('take_delivery_order_type', ''),
+
+ 'manual_open' => input('manual_open', 0),
+ 'template_id' => input('template_id', 0),
+ 'print_num' => input('print_num', 1),
+
+ //充值
+ 'recharge_open' => input('recharge_open', 0),
+ 'recharge_template_id' => input('recharge_template_id', 0),
+ 'recharge_print_num' => input('recharge_print_num', 1),
+
+ 'change_shifts_open' => input('change_shifts_open', 0),
+ 'change_shifts_template_id' => input('change_shifts_template_id', 0),
+ 'change_shifts_print_num' => input('change_shifts_print_num', 1),
+
+ 'host' => input('host', ''),
+ 'ip' => input('ip', ''),
+ 'port' => input('port', ''),
+ 'print_width' => input('print_width', '58mm')
+
+ ];
+ if ($data[ 'order_pay_order_type' ]) $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
+ if ($data[ 'take_delivery_order_type' ]) $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
+ return $model->addPrinter($data);
+
+ } else {
+ //模板列表
+ $template_model = new PrinterTemplate();
+ $condition = [
+ [ 'site_id', '=', $this->site_id ],
+ ];
+ $template_list = $template_model->getPrinterTemplateList($condition, 'template_id,template_name,type', 'template_id desc');
+ $this->assign('template_list', $template_list[ 'data' ]);
+
+ //打印机品牌
+ $brand = $model->getPrinterBrand();
+ $this->assign('brand', $brand);
+
+ //订单类型
+ $order_common_model = new OrderCommonModel();
+ $order_type_list = $order_common_model->getOrderTypeStatusList();
+ unset($order_type_list[ 'all' ]);
+ $this->assign("order_type_list", $order_type_list);
+
+ $is_exit_store = addon_is_exit('store');
+ if ($is_exit_store == 1) {
+ $store_model = new Store();
+ $store_field = 'store_id,store_name';
+ $store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ], $store_field);
+ $this->assign('store_list', $store_list[ 'data' ]);
+ }
+ $this->assign('is_exit_store', $is_exit_store);
+ return $this->fetch("printer/add");
+ }
+ }
+
+ /**
+ * 编辑小票打印
+ */
+ public function edit()
+ {
+ $model = new PrinterModel();
+ $printer_id = input('printer_id', 0);
+ if (request()->isJson()) {
+ $data = [
+ 'printer_id' => $printer_id,
+
+ 'site_id' => $this->site_id,
+ 'printer_name' => input('printer_name', ''),
+ 'brand' => input('brand', ''),
+ 'printer_code' => input('printer_code', ''),
+ 'printer_key' => input('printer_key', ''),
+ 'open_id' => input('open_id', ''),
+ 'apikey' => input('apikey', ''),
+ 'store_id' => input('store_id', ''),
+ 'printer_type' => input('printer_type', ''),
+
+ //订单
+ 'order_pay_open' => input('order_pay_open', 0),
+ 'order_pay_template_id' => input('order_pay_template_id', 0),
+ 'order_pay_print_num' => input('order_pay_print_num', 1),
+ 'order_pay_order_type' => input('order_pay_order_type', ''),
+
+ 'take_delivery_open' => input('take_delivery_open', 0),
+ 'take_delivery_template_id' => input('take_delivery_template_id', 0),
+ 'take_delivery_print_num' => input('take_delivery_print_num', 1),
+ 'take_delivery_order_type' => input('take_delivery_order_type', ''),
+
+ 'manual_open' => input('manual_open', 0),
+ 'template_id' => input('template_id', 0),
+ 'print_num' => input('print_num', 1),
+
+ //充值
+ 'recharge_open' => input('recharge_open', 0),
+ 'recharge_template_id' => input('recharge_template_id', 0),
+ 'recharge_print_num' => input('recharge_print_num', 1),
+
+ 'change_shifts_open' => input('change_shifts_open', 0),
+ 'change_shifts_template_id' => input('change_shifts_template_id', 0),
+ 'change_shifts_print_num' => input('change_shifts_print_num', 1),
+
+ 'host' => input('host', ''),
+ 'ip' => input('ip', ''),
+ 'port' => input('port', ''),
+ 'print_width' => input('print_width', '58mm')
+ ];
+
+ if ($data[ 'order_pay_order_type' ]) $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
+ if ($data[ 'take_delivery_order_type' ]) $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
+
+ return $model->editPrinter($data);
+ } else {
+
+ $info = $model->getPrinterInfo([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $this->site_id ] ]);
+ $info[ 'data' ][ 'take_delivery_order_type' ] = explode(',', $info[ 'data' ][ 'take_delivery_order_type' ]);
+ $info[ 'data' ][ 'order_pay_order_type' ] = explode(',', $info[ 'data' ][ 'order_pay_order_type' ]);
+ $this->assign('printer_info', $info[ 'data' ]);
+
+ //模板列表
+ $template_model = new PrinterTemplate();
+ $condition = [
+ [ 'site_id', '=', $this->site_id ],
+ ];
+ $template_list = $template_model->getPrinterTemplateList($condition, 'template_id,template_name,type', 'template_id desc');
+ $this->assign('template_list', $template_list[ 'data' ]);
+
+ //打印机品牌
+ $brand = $model->getPrinterBrand();
+ $this->assign('brand', $brand);
+
+ //订单类型
+ $order_common_model = new OrderCommonModel();
+ $order_type_list = $order_common_model->getOrderTypeStatusList();
+ unset($order_type_list[ 'all' ]);
+ $this->assign("order_type_list", $order_type_list);
+
+ //是否存在门店
+ $is_exit_store = addon_is_exit('store');
+ if ($is_exit_store == 1) {
+ $store_model = new Store();
+ $store_field = 'store_id,store_name';
+ $store_list = $store_model->getStoreList([ [ 'site_id', '=', $this->site_id ] ], $store_field);
+ $this->assign('store_list', $store_list[ 'data' ]);
+ }
+ $this->assign('is_exit_store', $is_exit_store);
+ return $this->fetch("printer/edit");
+ }
+ }
+
+ /*
+ * 删除
+ */
+ public function delete()
+ {
+ $printer_id = input('printer_id', '');
+
+ $printer_model = new PrinterModel();
+ return $printer_model->deletePrinter([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $this->site_id ] ]);
+ }
+
+ /**
+ * 测试打印
+ */
+ public function testPrint()
+ {
+ $printer_id = input('printer_id', '');
+ $print_model = new PrinterOrder();
+ $res = $print_model->testPrint($printer_id, $this->site_id);
+ return $res;
+ }
+
+ /**
+ * 刷新token
+ */
+ public function refreshToken()
+ {
+ $printer_id = input('printer_id', '');
+ $print_model = new PrinterModel();
+ $res = $print_model->refreshToken($printer_id, $this->site_id);
+ return $res;
+ }
+
+ /**
+ * 测试打印
+ */
+ public function test()
+ {
+// $print_model = new PrinterOrder();
+// $res = $print_model->printer([
+//// 'order_id' => '5630',
+//// 'type' => 'goodsorder',
+//// 'printer_type' => 'order_pay',
+//// 'site_id' => $this->site_id
+// 'order_id' => '32',
+// 'type' => 'recharge',
+// 'site_id' => $this->site_id
+// ]);
+// return $res;
+ $res = event('MemberRechargeOrderPayPrinter', [
+ 'relate_id' => 66
+ ]);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/printer/shop/controller/Template.php b/src/addon/printer/shop/controller/Template.php
index 481752903..9eb0a5470 100644
--- a/src/addon/printer/shop/controller/Template.php
+++ b/src/addon/printer/shop/controller/Template.php
@@ -1,134 +1,126 @@
-isJson()) {
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $list = $model->getPrinterTemplatePageList($condition, $page, $page_size, 'template_id desc');
- return $list;
- }
- return $this->fetch("template/lists");
- }
-
- /**
- * 添加模板管理
- */
- public function add()
- {
- $model = new PrinterTemplate();
-
- $type = input('type', 'goodsorder');
- if (request()->isJson()) {
- $data = [
- 'site_id' => $this->site_id,
- 'site_name' => $this->shop_info[ 'site_name' ],
- 'template_type' => input('template_type', ''),
- 'template_name' => input('template_name', ''),
-
- 'title' => input('title', ''),
- 'head' => input('head', ''),
- 'buy_notes' => input('buy_notes', ''),
- 'seller_notes' => input('seller_notes', ''),
- 'buy_name' => input('buy_name', ''),
- 'buy_mobile' => input('buy_mobile', ''),
- 'buy_address' => input('buy_address', ''),
- 'shop_mobile' => input('shop_mobile', ''),
- 'shop_address' => input('shop_address', ''),
- 'shop_qrcode' => input('shop_qrcode', ''),
- 'qrcode_url' => input('qrcode_url', ''),
- 'bottom' => input('bottom', ''),
-
- 'type' => input('type', ''),
- 'type_name' => input('type_name', ''),
- 'goods_price_show' => input('goods_price_show', 0),
- 'goods_code_show' => input('goods_code_show', 0),
- 'form_show' => input('form_show', 0),
- 'goods_price_type' => input('goods_price_type', ''),
- ];
-
- return $model->addPrinterTemplate($data);
- } else {
- $this->assign('template_type', $model->getTemplateType());
- $this->assign('type', $type);
- return event('PrinterTemplate', [ 'type' => $type, 'action' => 'add' ], true);
- }
- }
-
- /**
- * 编辑模板管理
- */
- public function edit()
- {
- $model = new PrinterTemplate();
- $template_id = input('template_id', 0);
- if (request()->isJson()) {
- $data = [
- 'template_id' => $template_id,
- 'site_id' => $this->site_id,
- 'template_type' => input('template_type', ''),
- 'template_name' => input('template_name', ''),
-
- 'title' => input('title', ''),
- 'head' => input('head', ''),
- 'buy_notes' => input('buy_notes', ''),
- 'seller_notes' => input('seller_notes', ''),
- 'buy_name' => input('buy_name', ''),
- 'buy_mobile' => input('buy_mobile', ''),
- 'buy_address' => input('buy_address', ''),
- 'shop_mobile' => input('shop_mobile', ''),
- 'shop_address' => input('shop_address', ''),
- 'shop_qrcode' => input('shop_qrcode', ''),
- 'qrcode_url' => input('qrcode_url', ''),
- 'bottom' => input('bottom', ''),
-
- 'goods_price_show' => input('goods_price_show', 0),
- 'goods_code_show' => input('goods_code_show', 0),
- 'form_show' => input('form_show', 0),
- 'goods_price_type' => input('goods_price_type', ''),
-
- ];
- return $model->editPrinterTemplate($data);
-
- } else {
- $info = $model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ], [ 'site_id', '=', $this->site_id ] ]);
- $this->assign('info', $info[ 'data' ]);
-
- return event('PrinterTemplate', [ 'type' => $info[ 'data' ][ 'type' ], 'action' => 'edit' ], true);
- }
- }
-
- /*
- * 删除
- */
- public function delete()
- {
- $template_id = input('template_id', '');
-
- $printer_model = new PrinterTemplate();
- return $printer_model->deletePrinterTemplate([ [ 'template_id', '=', $template_id ], [ 'site_id', '=', $this->site_id ] ]);
- }
-
+isJson()) {
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $list = $model->getPrinterTemplatePageList($condition, $page, $page_size, 'template_id desc');
+ return $list;
+ }
+ return $this->fetch("template/lists");
+ }
+
+ /**
+ * 添加模板管理
+ */
+ public function add()
+ {
+ $model = new PrinterTemplate();
+
+ $type = input('type', 'goodsorder');
+ if (request()->isJson()) {
+ $data = [
+ 'site_id' => $this->site_id,
+ 'site_name' => $this->shop_info[ 'site_name' ],
+ 'template_type' => input('template_type', ''),
+ 'template_name' => input('template_name', ''),
+
+ 'title' => input('title', ''),
+ 'head' => input('head', ''),
+ 'buy_notes' => input('buy_notes', ''),
+ 'seller_notes' => input('seller_notes', ''),
+ 'buy_name' => input('buy_name', ''),
+ 'buy_mobile' => input('buy_mobile', ''),
+ 'buy_address' => input('buy_address', ''),
+ 'shop_mobile' => input('shop_mobile', ''),
+ 'shop_address' => input('shop_address', ''),
+ 'shop_qrcode' => input('shop_qrcode', ''),
+ 'qrcode_url' => input('qrcode_url', ''),
+ 'bottom' => input('bottom', ''),
+
+ 'type' => input('type', ''),
+ 'type_name' => input('type_name', ''),
+ 'goods_price_show' => input('goods_price_show', 0),
+ 'goods_code_show' => input('goods_code_show', 0),
+ 'form_show' => input('form_show', 0),
+ 'goods_price_type' => input('goods_price_type', ''),
+ ];
+
+ return $model->addPrinterTemplate($data);
+ } else {
+ $this->assign('template_type', $model->getTemplateType());
+ $this->assign('type', $type);
+ return event('PrinterTemplate', [ 'type' => $type, 'action' => 'add' ], true);
+ }
+ }
+
+ /**
+ * 编辑模板管理
+ */
+ public function edit()
+ {
+ $model = new PrinterTemplate();
+ $template_id = input('template_id', 0);
+ if (request()->isJson()) {
+ $data = [
+ 'template_id' => $template_id,
+ 'site_id' => $this->site_id,
+ 'template_type' => input('template_type', ''),
+ 'template_name' => input('template_name', ''),
+
+ 'title' => input('title', ''),
+ 'head' => input('head', ''),
+ 'buy_notes' => input('buy_notes', ''),
+ 'seller_notes' => input('seller_notes', ''),
+ 'buy_name' => input('buy_name', ''),
+ 'buy_mobile' => input('buy_mobile', ''),
+ 'buy_address' => input('buy_address', ''),
+ 'shop_mobile' => input('shop_mobile', ''),
+ 'shop_address' => input('shop_address', ''),
+ 'shop_qrcode' => input('shop_qrcode', ''),
+ 'qrcode_url' => input('qrcode_url', ''),
+ 'bottom' => input('bottom', ''),
+
+ 'goods_price_show' => input('goods_price_show', 0),
+ 'goods_code_show' => input('goods_code_show', 0),
+ 'form_show' => input('form_show', 0),
+ 'goods_price_type' => input('goods_price_type', ''),
+
+ ];
+ return $model->editPrinterTemplate($data);
+
+ } else {
+ $info = $model->getPrinterTemplateInfo([ [ 'template_id', '=', $template_id ], [ 'site_id', '=', $this->site_id ] ]);
+ $this->assign('info', $info[ 'data' ]);
+
+ return event('PrinterTemplate', [ 'type' => $info[ 'data' ][ 'type' ], 'action' => 'edit' ], true);
+ }
+ }
+
+ /*
+ * 删除
+ */
+ public function delete()
+ {
+ $template_id = input('template_id', '');
+
+ $printer_model = new PrinterTemplate();
+ return $printer_model->deletePrinterTemplate([ [ 'template_id', '=', $template_id ], [ 'site_id', '=', $this->site_id ] ]);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/printer/storeapi/controller/Printer.php b/src/addon/printer/storeapi/controller/Printer.php
index 3656728ab..4217dae3c 100644
--- a/src/addon/printer/storeapi/controller/Printer.php
+++ b/src/addon/printer/storeapi/controller/Printer.php
@@ -1,238 +1,230 @@
-params[ 'site_id' ] ?? 1;
- $store_id = $this->params[ 'store_id' ] ?? 1;
- $page = $this->params[ 'page' ] ?? 1;
- $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
- $condition[] = [ 'site_id', '=', $site_id ];
- $condition[] = [ 'store_id', '=', $store_id ];
- $list = $model->getPrinterPageList($condition, $page, $page_size, 'printer_id desc');
- return $this->response($list);
- }
-
- /**
- * 打印机信息
- * @return false|string
- */
- public function info()
- {
- $site_id = $this->params[ 'site_id' ] ?? 1;
- $store_id = $this->params[ 'store_id' ] ?? 1;
- $printer_id = $this->params[ 'printer_id' ] ?? 1;
- $model = new PrinterModel();
- $info = $model->getPrinterInfo([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $site_id ], [ 'store_id', '=', $store_id ] ]);
- $info[ 'data' ][ 'take_delivery_order_type' ] = explode(',', $info[ 'data' ][ 'take_delivery_order_type' ]);
- $info[ 'data' ][ 'order_pay_order_type' ] = explode(',', $info[ 'data' ][ 'order_pay_order_type' ]);
-
- $order_common_model = new OrderCommonModel();
- $order_type_list = $order_common_model->getOrderTypeStatusList();
- unset($order_type_list[ 'all' ]);
- $info[ 'data' ][ 'order_type_list' ] = $order_type_list;
- return $this->response($info);
- }
-
- public function getOrderType()
- {
- $order_common_model = new OrderCommonModel();
- $order_type_list = $order_common_model->getOrderTypeStatusList();
- unset($order_type_list[ 'all' ]);
- return $this->response($this->success($order_type_list));
- }
-
- /**
- * 打印机品牌
- * @return false|string
- */
- public function brand()
- {
- $model = new PrinterModel();
- $brand = $model->getPrinterBrand();
- return $this->response($brand);
- }
-
- /**
- * 打印模板
- */
- public function template()
- {
- $site_id = $this->params[ 'site_id' ] ?? 1;
- $template_model = new PrinterTemplate();
- $condition = [
- [ 'site_id', '=', $site_id ],
- ];
- $template_list = $template_model->getPrinterTemplateList($condition, 'template_id,template_name,type', 'template_id desc');
- return $this->response($template_list);
- }
-
- /**
- * 添加小票打印
- */
- public function add()
- {
- $model = new PrinterModel();
- $data = [
- 'site_id' => $this->params[ 'site_id' ] ?? 1,
- 'printer_name' => $this->params[ 'printer_name' ] ?? '',
- 'brand' => $this->params[ 'brand' ] ?? '',
- 'printer_code' => $this->params[ 'printer_code' ] ?? '',
- 'printer_key' => $this->params[ 'printer_key' ] ?? '',
- 'open_id' => $this->params[ 'open_id' ] ?? '',
- 'apikey' => $this->params[ 'apikey' ] ?? '',
- 'store_id' => $this->params[ 'store_id' ] ?? 1,
- 'printer_type' => $this->params[ 'printer_type' ] ?? 'cloud',
-
- //订单
- 'order_pay_open' => $this->params[ 'order_pay_open' ] ?? 0,
- 'order_pay_template_id' => $this->params[ 'order_pay_template_id' ] ?? 0,
- 'order_pay_print_num' => $this->params[ 'order_pay_print_num' ] ?? 1,
- 'order_pay_order_type' => $this->params[ 'order_pay_order_type' ] ?? '',
-
- 'take_delivery_open' => $this->params[ 'take_delivery_open' ] ?? 0,
- 'take_delivery_template_id' => $this->params[ 'take_delivery_template_id' ] ?? 0,
- 'take_delivery_print_num' => $this->params[ 'take_delivery_print_num' ] ?? 1,
- 'take_delivery_order_type' => $this->params[ 'take_delivery_order_type' ] ?? '',
-
- 'manual_open' => $this->params[ 'manual_open' ] ?? 0,
- 'template_id' => $this->params[ 'template_id' ] ?? 0,
- 'print_num' => $this->params[ 'print_num' ] ?? 1,
-
- //充值
- 'recharge_open' => $this->params[ 'recharge_open' ] ?? 0,
- 'recharge_template_id' => $this->params[ 'recharge_template_id' ] ?? 0,
- 'recharge_print_num' => $this->params[ 'recharge_print_num' ] ?? 1,
-
- 'change_shifts_open' => $this->params[ 'change_shifts_open' ] ?? 0,
- 'change_shifts_template_id' => $this->params[ 'change_shifts_template_id' ] ?? 0,
- 'change_shifts_print_num' => $this->params[ 'change_shifts_print_num' ] ?? 1,
-
- 'host' => $this->params[ 'host' ] ?? '',
- 'ip' => $this->params[ 'ip' ] ?? '',
- 'port' => $this->params[ 'port' ] ?? '',
- 'print_width' => $this->params[ 'print_width' ] ?? '58mm'
- ];
- if ($data[ 'order_pay_order_type' ]) $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
- if ($data[ 'take_delivery_order_type' ]) $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
- return $this->response($model->addPrinter($data));
-
- }
-
- /**
- * 编辑小票打印
- */
- public function edit()
- {
- $model = new PrinterModel();
- $data = [
- 'printer_id' => $this->params[ 'printer_id' ] ?? 1,
- 'site_id' => $this->params[ 'site_id' ] ?? 1,
- 'printer_name' => $this->params[ 'printer_name' ] ?? '',
- 'brand' => $this->params[ 'brand' ] ?? '',
- 'printer_code' => $this->params[ 'printer_code' ] ?? '',
- 'printer_key' => $this->params[ 'printer_key' ] ?? '',
- 'open_id' => $this->params[ 'open_id' ] ?? '',
- 'apikey' => $this->params[ 'apikey' ] ?? '',
- 'store_id' => $this->params[ 'store_id' ] ?? 1,
- 'printer_type' => $this->params[ 'printer_type' ] ?? 'cloud',
-
- //订单
- 'order_pay_open' => $this->params[ 'order_pay_open' ] ?? 0,
- 'order_pay_template_id' => $this->params[ 'order_pay_template_id' ] ?? 0,
- 'order_pay_print_num' => $this->params[ 'order_pay_print_num' ] ?? 1,
- 'order_pay_order_type' => $this->params[ 'order_pay_order_type' ] ?? '',
-
- 'take_delivery_open' => $this->params[ 'take_delivery_open' ] ?? 0,
- 'take_delivery_template_id' => $this->params[ 'take_delivery_template_id' ] ?? 0,
- 'take_delivery_print_num' => $this->params[ 'take_delivery_print_num' ] ?? 1,
- 'take_delivery_order_type' => $this->params[ 'take_delivery_order_type' ] ?? '',
-
- 'manual_open' => $this->params[ 'manual_open' ] ?? 0,
- 'template_id' => $this->params[ 'template_id' ] ?? 0,
- 'print_num' => $this->params[ 'print_num' ] ?? 1,
-
- //充值
- 'recharge_open' => $this->params[ 'recharge_open' ] ?? 0,
- 'recharge_template_id' => $this->params[ 'recharge_template_id' ] ?? 0,
- 'recharge_print_num' => $this->params[ 'recharge_print_num' ] ?? 1,
-
- 'change_shifts_open' => $this->params[ 'change_shifts_open' ] ?? 0,
- 'change_shifts_template_id' => $this->params[ 'change_shifts_template_id' ] ?? 0,
- 'change_shifts_print_num' => $this->params[ 'change_shifts_print_num' ] ?? 1,
-
- 'host' => $this->params[ 'host' ] ?? '',
- 'ip' => $this->params[ 'ip' ] ?? '',
- 'port' => $this->params[ 'port' ] ?? '',
- 'print_width' => $this->params[ 'print_width' ] ?? '58mm'
- ];
- if ($data[ 'order_pay_order_type' ]) {
- $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
- $data[ 'order_pay_order_type' ] = str_replace(',,', ',', $data[ 'order_pay_order_type' ]);
- }
- if ($data[ 'take_delivery_order_type' ]) {
- $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
- $data[ 'take_delivery_order_type' ] = str_replace(',,', ',', $data[ 'take_delivery_order_type' ]);
- }
- return $this->response($model->editPrinter($data));
- }
-
- /*
- * 删除
- */
- public function deletePrinter()
- {
- $printer_id = $this->params[ 'printer_id' ] ?? 0;
- $store_id = $this->params[ 'store_id' ] ?? 0;
-
- $printer_model = new PrinterModel();
- $res = $printer_model->deletePrinter([ [ 'printer_id', '=', $printer_id ], [ 'store_id', '=', $store_id ] ]);
- return $this->response($res);
- }
-
- /**
- * 测试打印
- */
- public function testPrint()
- {
- $printer_id = $this->params[ 'printer_id' ] ?? 0;
- $site_id = $this->params[ 'site_id' ] ?? 1;
- $print_model = new PrinterOrder();
- $res = $print_model->testPrint($printer_id, $site_id);
- return $this->response($res);
- }
-
- /**
- * 刷新token
- */
- public function refreshToken()
- {
- $printer_id = $this->params[ 'printer_id' ] ?? 0;
- $site_id = $this->params[ 'site_id' ] ?? 1;
- $print_model = new PrinterModel();
- $res = $print_model->refreshToken($printer_id, $site_id);
- return $this->response($res);
- }
-
+params[ 'site_id' ] ?? 1;
+ $store_id = $this->params[ 'store_id' ] ?? 1;
+ $page = $this->params[ 'page' ] ?? 1;
+ $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
+ $condition[] = [ 'site_id', '=', $site_id ];
+ $condition[] = [ 'store_id', '=', $store_id ];
+ $list = $model->getPrinterPageList($condition, $page, $page_size, 'printer_id desc');
+ return $this->response($list);
+ }
+
+ /**
+ * 打印机信息
+ * @return false|string
+ */
+ public function info()
+ {
+ $site_id = $this->params[ 'site_id' ] ?? 1;
+ $store_id = $this->params[ 'store_id' ] ?? 1;
+ $printer_id = $this->params[ 'printer_id' ] ?? 1;
+ $model = new PrinterModel();
+ $info = $model->getPrinterInfo([ [ 'printer_id', '=', $printer_id ], [ 'site_id', '=', $site_id ], [ 'store_id', '=', $store_id ] ]);
+ $info[ 'data' ][ 'take_delivery_order_type' ] = explode(',', $info[ 'data' ][ 'take_delivery_order_type' ]);
+ $info[ 'data' ][ 'order_pay_order_type' ] = explode(',', $info[ 'data' ][ 'order_pay_order_type' ]);
+
+ $order_common_model = new OrderCommonModel();
+ $order_type_list = $order_common_model->getOrderTypeStatusList();
+ unset($order_type_list[ 'all' ]);
+ $info[ 'data' ][ 'order_type_list' ] = $order_type_list;
+ return $this->response($info);
+ }
+
+ public function getOrderType()
+ {
+ $order_common_model = new OrderCommonModel();
+ $order_type_list = $order_common_model->getOrderTypeStatusList();
+ unset($order_type_list[ 'all' ]);
+ return $this->response($this->success($order_type_list));
+ }
+
+ /**
+ * 打印机品牌
+ * @return false|string
+ */
+ public function brand()
+ {
+ $model = new PrinterModel();
+ $brand = $model->getPrinterBrand();
+ return $this->response($brand);
+ }
+
+ /**
+ * 打印模板
+ */
+ public function template()
+ {
+ $site_id = $this->params[ 'site_id' ] ?? 1;
+ $template_model = new PrinterTemplate();
+ $condition = [
+ [ 'site_id', '=', $site_id ],
+ ];
+ $template_list = $template_model->getPrinterTemplateList($condition, 'template_id,template_name,type', 'template_id desc');
+ return $this->response($template_list);
+ }
+
+ /**
+ * 添加小票打印
+ */
+ public function add()
+ {
+ $model = new PrinterModel();
+ $data = [
+ 'site_id' => $this->params[ 'site_id' ] ?? 1,
+ 'printer_name' => $this->params[ 'printer_name' ] ?? '',
+ 'brand' => $this->params[ 'brand' ] ?? '',
+ 'printer_code' => $this->params[ 'printer_code' ] ?? '',
+ 'printer_key' => $this->params[ 'printer_key' ] ?? '',
+ 'open_id' => $this->params[ 'open_id' ] ?? '',
+ 'apikey' => $this->params[ 'apikey' ] ?? '',
+ 'store_id' => $this->params[ 'store_id' ] ?? 1,
+ 'printer_type' => $this->params[ 'printer_type' ] ?? 'cloud',
+
+ //订单
+ 'order_pay_open' => $this->params[ 'order_pay_open' ] ?? 0,
+ 'order_pay_template_id' => $this->params[ 'order_pay_template_id' ] ?? 0,
+ 'order_pay_print_num' => $this->params[ 'order_pay_print_num' ] ?? 1,
+ 'order_pay_order_type' => $this->params[ 'order_pay_order_type' ] ?? '',
+
+ 'take_delivery_open' => $this->params[ 'take_delivery_open' ] ?? 0,
+ 'take_delivery_template_id' => $this->params[ 'take_delivery_template_id' ] ?? 0,
+ 'take_delivery_print_num' => $this->params[ 'take_delivery_print_num' ] ?? 1,
+ 'take_delivery_order_type' => $this->params[ 'take_delivery_order_type' ] ?? '',
+
+ 'manual_open' => $this->params[ 'manual_open' ] ?? 0,
+ 'template_id' => $this->params[ 'template_id' ] ?? 0,
+ 'print_num' => $this->params[ 'print_num' ] ?? 1,
+
+ //充值
+ 'recharge_open' => $this->params[ 'recharge_open' ] ?? 0,
+ 'recharge_template_id' => $this->params[ 'recharge_template_id' ] ?? 0,
+ 'recharge_print_num' => $this->params[ 'recharge_print_num' ] ?? 1,
+
+ 'change_shifts_open' => $this->params[ 'change_shifts_open' ] ?? 0,
+ 'change_shifts_template_id' => $this->params[ 'change_shifts_template_id' ] ?? 0,
+ 'change_shifts_print_num' => $this->params[ 'change_shifts_print_num' ] ?? 1,
+
+ 'host' => $this->params[ 'host' ] ?? '',
+ 'ip' => $this->params[ 'ip' ] ?? '',
+ 'port' => $this->params[ 'port' ] ?? '',
+ 'print_width' => $this->params[ 'print_width' ] ?? '58mm'
+ ];
+ if ($data[ 'order_pay_order_type' ]) $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
+ if ($data[ 'take_delivery_order_type' ]) $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
+ return $this->response($model->addPrinter($data));
+
+ }
+
+ /**
+ * 编辑小票打印
+ */
+ public function edit()
+ {
+ $model = new PrinterModel();
+ $data = [
+ 'printer_id' => $this->params[ 'printer_id' ] ?? 1,
+ 'site_id' => $this->params[ 'site_id' ] ?? 1,
+ 'printer_name' => $this->params[ 'printer_name' ] ?? '',
+ 'brand' => $this->params[ 'brand' ] ?? '',
+ 'printer_code' => $this->params[ 'printer_code' ] ?? '',
+ 'printer_key' => $this->params[ 'printer_key' ] ?? '',
+ 'open_id' => $this->params[ 'open_id' ] ?? '',
+ 'apikey' => $this->params[ 'apikey' ] ?? '',
+ 'store_id' => $this->params[ 'store_id' ] ?? 1,
+ 'printer_type' => $this->params[ 'printer_type' ] ?? 'cloud',
+
+ //订单
+ 'order_pay_open' => $this->params[ 'order_pay_open' ] ?? 0,
+ 'order_pay_template_id' => $this->params[ 'order_pay_template_id' ] ?? 0,
+ 'order_pay_print_num' => $this->params[ 'order_pay_print_num' ] ?? 1,
+ 'order_pay_order_type' => $this->params[ 'order_pay_order_type' ] ?? '',
+
+ 'take_delivery_open' => $this->params[ 'take_delivery_open' ] ?? 0,
+ 'take_delivery_template_id' => $this->params[ 'take_delivery_template_id' ] ?? 0,
+ 'take_delivery_print_num' => $this->params[ 'take_delivery_print_num' ] ?? 1,
+ 'take_delivery_order_type' => $this->params[ 'take_delivery_order_type' ] ?? '',
+
+ 'manual_open' => $this->params[ 'manual_open' ] ?? 0,
+ 'template_id' => $this->params[ 'template_id' ] ?? 0,
+ 'print_num' => $this->params[ 'print_num' ] ?? 1,
+
+ //充值
+ 'recharge_open' => $this->params[ 'recharge_open' ] ?? 0,
+ 'recharge_template_id' => $this->params[ 'recharge_template_id' ] ?? 0,
+ 'recharge_print_num' => $this->params[ 'recharge_print_num' ] ?? 1,
+
+ 'change_shifts_open' => $this->params[ 'change_shifts_open' ] ?? 0,
+ 'change_shifts_template_id' => $this->params[ 'change_shifts_template_id' ] ?? 0,
+ 'change_shifts_print_num' => $this->params[ 'change_shifts_print_num' ] ?? 1,
+
+ 'host' => $this->params[ 'host' ] ?? '',
+ 'ip' => $this->params[ 'ip' ] ?? '',
+ 'port' => $this->params[ 'port' ] ?? '',
+ 'print_width' => $this->params[ 'print_width' ] ?? '58mm'
+ ];
+ if ($data[ 'order_pay_order_type' ]) {
+ $data[ 'order_pay_order_type' ] = ',' . $data[ 'order_pay_order_type' ] . ',';
+ $data[ 'order_pay_order_type' ] = str_replace(',,', ',', $data[ 'order_pay_order_type' ]);
+ }
+ if ($data[ 'take_delivery_order_type' ]) {
+ $data[ 'take_delivery_order_type' ] = ',' . $data[ 'take_delivery_order_type' ] . ',';
+ $data[ 'take_delivery_order_type' ] = str_replace(',,', ',', $data[ 'take_delivery_order_type' ]);
+ }
+ return $this->response($model->editPrinter($data));
+ }
+
+ /*
+ * 删除
+ */
+ public function deletePrinter()
+ {
+ $printer_id = $this->params[ 'printer_id' ] ?? 0;
+ $store_id = $this->params[ 'store_id' ] ?? 0;
+
+ $printer_model = new PrinterModel();
+ $res = $printer_model->deletePrinter([ [ 'printer_id', '=', $printer_id ], [ 'store_id', '=', $store_id ] ]);
+ return $this->response($res);
+ }
+
+ /**
+ * 测试打印
+ */
+ public function testPrint()
+ {
+ $printer_id = $this->params[ 'printer_id' ] ?? 0;
+ $site_id = $this->params[ 'site_id' ] ?? 1;
+ $print_model = new PrinterOrder();
+ $res = $print_model->testPrint($printer_id, $site_id);
+ return $this->response($res);
+ }
+
+ /**
+ * 刷新token
+ */
+ public function refreshToken()
+ {
+ $printer_id = $this->params[ 'printer_id' ] ?? 0;
+ $site_id = $this->params[ 'site_id' ] ?? 1;
+ $print_model = new PrinterModel();
+ $res = $print_model->refreshToken($printer_id, $site_id);
+ return $this->response($res);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/qiniu/config/diy_view.php b/src/addon/qiniu/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/qiniu/config/diy_view.php
+++ b/src/addon/qiniu/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/qiniu/config/info.php b/src/addon/qiniu/config/info.php
index d857b445c..c5ba9d1b3 100644
--- a/src/addon/qiniu/config/info.php
+++ b/src/addon/qiniu/config/info.php
@@ -1,21 +1,12 @@
- 'qiniu',
- 'title' => '七牛云上传',
- 'description' => '七牛云上传功能',
- 'type' => 'system', //插件类型 system :系统插件 promotion:营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'qiniu',
+ 'title' => '七牛云上传',
+ 'description' => '七牛云上传功能',
+ 'type' => 'system', //插件类型 system :系统插件 promotion:营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/qiniu/event/ClearAlbumPic.php b/src/addon/qiniu/event/ClearAlbumPic.php
index 040c3c160..5db0a5151 100644
--- a/src/addon/qiniu/event/ClearAlbumPic.php
+++ b/src/addon/qiniu/event/ClearAlbumPic.php
@@ -1,38 +1,30 @@
-getQiniuConfig($params[ 'site_id' ]);
-
- if (!empty($config[ 'data' ])) {
- if (!empty($config[ 'data' ][ 'value' ][ 'domain' ]) && strpos($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'domain' ]) === 0) {
- $result = $qiniu_model->deleteAlbumPic($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'domain' ]);
- return $result;
- }
- }
- }
-
+getQiniuConfig($params[ 'site_id' ]);
+
+ if (!empty($config[ 'data' ])) {
+ if (!empty($config[ 'data' ][ 'value' ][ 'domain' ]) && strpos($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'domain' ]) === 0) {
+ $result = $qiniu_model->deleteAlbumPic($params[ 'pic_path' ], $config[ 'data' ][ 'value' ][ 'domain' ]);
+ return $result;
+ }
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/qiniu/event/CloseOss.php b/src/addon/qiniu/event/CloseOss.php
index 5b9c0d26d..20726ebc8 100644
--- a/src/addon/qiniu/event/CloseOss.php
+++ b/src/addon/qiniu/event/CloseOss.php
@@ -1,27 +1,18 @@
-modifyConfigIsUse(0);
- return $result;
- }
+modifyConfigIsUse(0);
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/src/addon/qiniu/event/Install.php b/src/addon/qiniu/event/Install.php
index 5438e6238..5154ab1c6 100644
--- a/src/addon/qiniu/event/Install.php
+++ b/src/addon/qiniu/event/Install.php
@@ -1,26 +1,17 @@
- "qiniu",
- "sms_type_name" => "七牛云上传",
- "edit_url" => "qiniu://shop/config/config",
- "shop_url" => "qiniu://shop/config/config",
- "desc" => "七牛云上传,七牛提供10GB免费存储空间"
- );
- return $info;
- }
+ "qiniu",
+ "sms_type_name" => "七牛云上传",
+ "edit_url" => "qiniu://shop/config/config",
+ "shop_url" => "qiniu://shop/config/config",
+ "desc" => "七牛云上传,七牛提供10GB免费存储空间"
+ );
+ return $info;
+ }
}
\ No newline at end of file
diff --git a/src/addon/qiniu/event/Put.php b/src/addon/qiniu/event/Put.php
index b72a49c37..f5b14cae5 100644
--- a/src/addon/qiniu/event/Put.php
+++ b/src/addon/qiniu/event/Put.php
@@ -1,29 +1,21 @@
-putFile($param);
- return $result;
- }
+putFile($param);
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/src/addon/qiniu/event/UnInstall.php b/src/addon/qiniu/event/UnInstall.php
index 5b86ca48c..0bf9b89df 100644
--- a/src/addon/qiniu/event/UnInstall.php
+++ b/src/addon/qiniu/event/UnInstall.php
@@ -1,26 +1,17 @@
-setConfig($data, '七牛云上传配置', $status, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'QINIU_CONFIG']]);
- return $res;
- }
-
- /**
- * 获取七牛云上传配置
- */
- public function getQiniuConfig($site_id = 1, $app_module = 'shop')
- {
- $config = new ConfigModel();
- $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'QINIU_CONFIG']]);
- return $res;
- }
-
- /**
- * 配置七牛云开关状态
- * @param $status
- */
- public function modifyConfigIsUse($status)
- {
- $config = new ConfigModel();
- $res = $config->modifyConfigIsUse($status, [['site_id', '=', 1], ['app_module', '=', 'shop'], ['config_key', '=', 'QINIU_CONFIG']]);
- return $res;
- }
+setConfig($data, '七牛云上传配置', $status, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'QINIU_CONFIG']]);
+ return $res;
+ }
+
+ /**
+ * 获取七牛云上传配置
+ */
+ public function getQiniuConfig($site_id = 1, $app_module = 'shop')
+ {
+ $config = new ConfigModel();
+ $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'QINIU_CONFIG']]);
+ return $res;
+ }
+
+ /**
+ * 配置七牛云开关状态
+ * @param $status
+ */
+ public function modifyConfigIsUse($status)
+ {
+ $config = new ConfigModel();
+ $res = $config->modifyConfigIsUse($status, [['site_id', '=', 1], ['app_module', '=', 'shop'], ['config_key', '=', 'QINIU_CONFIG']]);
+ return $res;
+ }
}
\ No newline at end of file
diff --git a/src/addon/qiniu/model/Qiniu.php b/src/addon/qiniu/model/Qiniu.php
index 406533023..2207fd48d 100644
--- a/src/addon/qiniu/model/Qiniu.php
+++ b/src/addon/qiniu/model/Qiniu.php
@@ -1,131 +1,123 @@
-getQiniuConfig();
- $config = $config_result[ "data" ];
-
- if ($config[ "is_use" ] == 1) {
- $config = $config[ "value" ];
- $accessKey = $config[ "access_key" ];
- $secretKey = $config[ "secret_key" ];
- $bucket = $config[ "bucket" ];
- $auth = new Auth($accessKey, $secretKey);
- $token = $auth->uploadToken($bucket);
- ( new BucketManager($auth) )->delete($bucket, $key);
- $uploadMgr = new UploadManager();
- //----------------------------------------upload demo1 ----------------------------------------
- // 上传字符串到七牛
- list($ret, $err) = $uploadMgr->put($token, $key, $data);
- if ($err !== null) {
- return $this->error('', $err->getResponse()->error);
- } else {
- //返回图片的完整URL
- $domain = $config[ "domain" ];//自定义域名
- $data = array (
- "path" => $domain . "/" . $key,
- "domain" => $domain,
- "bucket" => $bucket
- );
- return $this->success($data);
- }
- }
- }
-
- /**
- * 设置七牛参数配置
- * @param unknown $filePath 上传图片路径
- * @param unknown $key 上传到七牛后保存的文件名
- */
- public function putFile($param)
- {
- $file_path = $param[ "file_path" ];
- $key = $param[ "key" ];
- $config_model = new Config();
- $config = $config_model->getQiniuConfig()[ "data" ];
- if ($config[ "is_use" ] == 1) {
- $config = $config[ "value" ];
- $accessKey = $config[ "access_key" ];
- $secretKey = $config[ "secret_key" ];
- $bucket = $config[ "bucket" ];
- $auth = new Auth($accessKey, $secretKey);
- ( new BucketManager($auth) )->delete($bucket, $key);
- //要上传的空间
- $token = $auth->uploadToken($bucket);
- // 初始化 UploadManager 对象并进行文件的上传
- $uploadMgr = new UploadManager();
- // 调用 UploadManager 的 putFile 方法进行文件的上传
- list($ret, $err) = $uploadMgr->putFile($token, $key, $file_path);
- if ($err !== null) {
- return $this->error('', $err->getResponse()->error);
- } else {
- //返回图片的完整URL
- $domain = $config[ "domain" ];//自定义域名
- $data = array (
- "path" => $domain . "/" . $key,
- "domain" => $domain,
- "bucket" => $bucket
- );
- return $this->success($data);
- }
- }
- }
-
- /**
- * @param $file_path
- * 删除七牛云图片
- */
- public function deleteAlbumPic($file_path, $prefix)
- {
- $config_model = new Config();
- $config_result = $config_model->getQiniuConfig();
- $config = $config_result[ "data" ];
- if (!empty($config)) {
- $config = $config[ "value" ];
- $accessKey = $config[ "access_key" ];
- $secretKey = $config[ "secret_key" ];
- $bucket = $config[ "bucket" ];
-
- $auth = new Auth($accessKey, $secretKey);
-// $prefix = substr($file_path,0,strripos($file_path, "/"));
-// dump(str_replace($prefix."/", "",$file_path));
- ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", $file_path));
- ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", img($file_path, 'big')));
- ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", img($file_path, 'mid')));
- ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", img($file_path, 'small')));
- }
- }
-
+getQiniuConfig();
+ $config = $config_result[ "data" ];
+
+ if ($config[ "is_use" ] == 1) {
+ $config = $config[ "value" ];
+ $accessKey = $config[ "access_key" ];
+ $secretKey = $config[ "secret_key" ];
+ $bucket = $config[ "bucket" ];
+ $auth = new Auth($accessKey, $secretKey);
+ $token = $auth->uploadToken($bucket);
+ ( new BucketManager($auth) )->delete($bucket, $key);
+ $uploadMgr = new UploadManager();
+ //----------------------------------------upload demo1 ----------------------------------------
+ // 上传字符串到七牛
+ list($ret, $err) = $uploadMgr->put($token, $key, $data);
+ if ($err !== null) {
+ return $this->error('', $err->getResponse()->error);
+ } else {
+ //返回图片的完整URL
+ $domain = $config[ "domain" ];//自定义域名
+ $data = array (
+ "path" => $domain . "/" . $key,
+ "domain" => $domain,
+ "bucket" => $bucket
+ );
+ return $this->success($data);
+ }
+ }
+ }
+
+ /**
+ * 设置七牛参数配置
+ * @param unknown $filePath 上传图片路径
+ * @param unknown $key 上传到七牛后保存的文件名
+ */
+ public function putFile($param)
+ {
+ $file_path = $param[ "file_path" ];
+ $key = $param[ "key" ];
+ $config_model = new Config();
+ $config = $config_model->getQiniuConfig()[ "data" ];
+ if ($config[ "is_use" ] == 1) {
+ $config = $config[ "value" ];
+ $accessKey = $config[ "access_key" ];
+ $secretKey = $config[ "secret_key" ];
+ $bucket = $config[ "bucket" ];
+ $auth = new Auth($accessKey, $secretKey);
+ ( new BucketManager($auth) )->delete($bucket, $key);
+ //要上传的空间
+ $token = $auth->uploadToken($bucket);
+ // 初始化 UploadManager 对象并进行文件的上传
+ $uploadMgr = new UploadManager();
+ // 调用 UploadManager 的 putFile 方法进行文件的上传
+ list($ret, $err) = $uploadMgr->putFile($token, $key, $file_path);
+ if ($err !== null) {
+ return $this->error('', $err->getResponse()->error);
+ } else {
+ //返回图片的完整URL
+ $domain = $config[ "domain" ];//自定义域名
+ $data = array (
+ "path" => $domain . "/" . $key,
+ "domain" => $domain,
+ "bucket" => $bucket
+ );
+ return $this->success($data);
+ }
+ }
+ }
+
+ /**
+ * @param $file_path
+ * 删除七牛云图片
+ */
+ public function deleteAlbumPic($file_path, $prefix)
+ {
+ $config_model = new Config();
+ $config_result = $config_model->getQiniuConfig();
+ $config = $config_result[ "data" ];
+ if (!empty($config)) {
+ $config = $config[ "value" ];
+ $accessKey = $config[ "access_key" ];
+ $secretKey = $config[ "secret_key" ];
+ $bucket = $config[ "bucket" ];
+
+ $auth = new Auth($accessKey, $secretKey);
+// $prefix = substr($file_path,0,strripos($file_path, "/"));
+// dump(str_replace($prefix."/", "",$file_path));
+ ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", $file_path));
+ ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", img($file_path, 'big')));
+ ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", img($file_path, 'mid')));
+ ( new BucketManager($auth) )->delete($bucket, str_replace($prefix . "/", "", img($file_path, 'small')));
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/qiniu/shop/controller/Config.php b/src/addon/qiniu/shop/controller/Config.php
index c69ef4ba8..4dd0b89b7 100644
--- a/src/addon/qiniu/shop/controller/Config.php
+++ b/src/addon/qiniu/shop/controller/Config.php
@@ -1,52 +1,43 @@
-isJson()) {
- $bucket = input('bucket', '');
- $access_key = input('access_key', '');
- $secret_key = input('secret_key', '');
- $domain = input('domain', '');
- $status = input('status', 0);
- $data = array(
- 'bucket' => $bucket,
- 'access_key' => $access_key,
- 'secret_key' => $secret_key,
- 'domain' => $domain,
- );
-
- $result = $config_model->setQiniuConfig($data, $status, $this->site_id, $this->app_module);
- return $result;
- } else {
- $info_result = $config_model->getQiniuConfig($this->site_id, $this->app_module);
- $info = $info_result['data'];
- $this->assign('info', $info);
- return $this->fetch('config/config');
- }
- }
+isJson()) {
+ $bucket = input('bucket', '');
+ $access_key = input('access_key', '');
+ $secret_key = input('secret_key', '');
+ $domain = input('domain', '');
+ $status = input('status', 0);
+ $data = array(
+ 'bucket' => $bucket,
+ 'access_key' => $access_key,
+ 'secret_key' => $secret_key,
+ 'domain' => $domain,
+ );
+
+ $result = $config_model->setQiniuConfig($data, $status, $this->site_id, $this->app_module);
+ return $result;
+ } else {
+ $info_result = $config_model->getQiniuConfig($this->site_id, $this->app_module);
+ $info = $info_result['data'];
+ $this->assign('info', $info);
+ return $this->fetch('config/config');
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/api/controller/Seckill.php b/src/addon/seckill/api/controller/Seckill.php
index d4850b0dd..bb0a4d547 100644
--- a/src/addon/seckill/api/controller/Seckill.php
+++ b/src/addon/seckill/api/controller/Seckill.php
@@ -1,68 +1,60 @@
-site_id ],
- [ 'seckill_end_time', '>=', $time ]
- ];
- $order = 'seckill_start_time asc';
- $field = 'id,name,seckill_start_time,seckill_end_time';
-
- $seckill_model = new SeckillModel();
- $today_list = $seckill_model->getGoodsSeckillTimeList($condition, $field, $order);
- $today_list = is_array($today_list[ 'data' ]) ? array_values($today_list[ 'data' ]) : [];
- foreach ($today_list as $key => $val) {
- $val = $seckill_model->transformSeckillTime($val);
- $today_list[ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
- $today_list[ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
- $today_list[ $key ][ 'type' ] = "today";
- }
-
- $condition = [
- [ 'site_id', '=', $this->site_id ],
- [ 'seckill_end_time', '<', $time ]
- ];
-
- $tomorrow_list = $seckill_model->getGoodsSeckillTimeList($condition, $field, $order);
- $tomorrow_list = is_array($tomorrow_list[ 'data' ]) ? array_values($tomorrow_list[ 'data' ]) : [];
- foreach ($tomorrow_list as $key => $val) {
- $val = $seckill_model->transformSeckillTime($val);
- $tomorrow_list[ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
- $tomorrow_list[ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
- $tomorrow_list[ $key ][ 'type' ] = "tomorrow";
- }
-
- $res = [
- 'list' => array_merge($today_list, $tomorrow_list)
- ];
- return $this->response($this->success($res));
- }
+site_id ],
+ [ 'seckill_end_time', '>=', $time ]
+ ];
+ $order = 'seckill_start_time asc';
+ $field = 'id,name,seckill_start_time,seckill_end_time';
+
+ $seckill_model = new SeckillModel();
+ $today_list = $seckill_model->getGoodsSeckillTimeList($condition, $field, $order);
+ $today_list = is_array($today_list[ 'data' ]) ? array_values($today_list[ 'data' ]) : [];
+ foreach ($today_list as $key => $val) {
+ $val = $seckill_model->transformSeckillTime($val);
+ $today_list[ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
+ $today_list[ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
+ $today_list[ $key ][ 'type' ] = "today";
+ }
+
+ $condition = [
+ [ 'site_id', '=', $this->site_id ],
+ [ 'seckill_end_time', '<', $time ]
+ ];
+
+ $tomorrow_list = $seckill_model->getGoodsSeckillTimeList($condition, $field, $order);
+ $tomorrow_list = is_array($tomorrow_list[ 'data' ]) ? array_values($tomorrow_list[ 'data' ]) : [];
+ foreach ($tomorrow_list as $key => $val) {
+ $val = $seckill_model->transformSeckillTime($val);
+ $tomorrow_list[ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
+ $tomorrow_list[ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
+ $tomorrow_list[ $key ][ 'type' ] = "tomorrow";
+ }
+
+ $res = [
+ 'list' => array_merge($today_list, $tomorrow_list)
+ ];
+ return $this->response($this->success($res));
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/api/controller/Seckillgoods.php b/src/addon/seckill/api/controller/Seckillgoods.php
index c3d62b56e..7809b281e 100644
--- a/src/addon/seckill/api/controller/Seckillgoods.php
+++ b/src/addon/seckill/api/controller/Seckillgoods.php
@@ -1,222 +1,214 @@
-params[ 'seckill_id' ] ?? 0;
- $sku_id = $this->params[ 'sku_id' ] ?? 0;
- if (empty($seckill_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- if (empty($sku_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- $seckill_model = new SeckillModel();
- $order_model = new SeckillOrder();
- $condition = [
- [ 'ps.id', '=', $seckill_id ],
- [ 'psg.sku_id', '=', $sku_id ],
- [ 'psg.site_id', '=', $this->site_id ],
- [ 'psg.status', '=', 1 ],
- [ 'ps.status', '=', 1 ],
- [ 'g.goods_state', '=', 1 ],
- [ 'g.is_delete', '=', 0 ]
- ];
- $goods_sku_detail = $seckill_model->getSeckillGoodsInfo($condition, '')[ 'data' ];
-
- $res[ 'goods_sku_detail' ] = $goods_sku_detail;
- if (!empty($goods_sku_detail)) {
- $num = $order_model->getGoodsSeckillNum($seckill_id);
- $time_data = $seckill_model->getSeckillInfo($seckill_id)[ 'data' ];
- $goods_sku_detail[ 'sale_num' ] = $num;
- $goods_sku_detail[ 'seckill_start_time' ] = $time_data[ 'seckill_start_time' ];
- $goods_sku_detail[ 'seckill_end_time' ] = $time_data[ 'seckill_end_time' ];
- //判断商品规格项
- $goods_spec_format = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
- $res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
- } else {
- $sku_id = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, '');
- $res = [ 'type' => 'again', 'sku_id' => $sku_id ];
- }
- return $this->response($this->success($res));
- }
-
- /**
- * 详情信息
- */
- public function detail()
- {
- $this->checkToken();
- $seckill_id = $this->params[ 'seckill_id' ] ?? 0;
- if (empty($seckill_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- $seckill_model = new SeckillModel();
- $condition = [
- [ 'ps.id', '=', $seckill_id ],
- [ 'psg.site_id', '=', $this->site_id ],
- [ 'psg.status', '=', 1 ],
- [ 'ps.status', '=', 1 ],
- [ 'g.goods_state', '=', 1 ],
- [ 'g.is_delete', '=', 0 ]
- ];
- $goods_sku_detail = $seckill_model->getSeckillGoodsInfo($condition)[ 'data' ];
-
- $time_data = $seckill_model->getSeckillInfo($seckill_id)[ 'data' ];
- $goods_sku_detail[ 'seckill_start_time' ] = $time_data[ 'seckill_start_time' ];
- $goods_sku_detail[ 'seckill_end_time' ] = $time_data[ 'seckill_end_time' ];
-
- $res[ 'goods_sku_detail' ] = $goods_sku_detail;
- if (empty($goods_sku_detail)) return $this->response($this->error($res));
-
- if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
- //判断商品规格项
- $goods_spec_format = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
- $res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
- }
-
- // 处理公共数据
- $goods_sku_api = new GoodsApi();
- $goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ], $this->member_id, $this->site_id);
-
- return $this->response($this->success($res));
- }
-
- /**
- * 查询商品SKU集合
- * @return false|string
- */
- public function goodsSku()
- {
- $goods_id = $this->params[ 'goods_id' ] ?? 0;
- $seckill_id = $this->params[ 'seckill_id' ] ?? 0;
- if (empty($goods_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- if (empty($seckill_id)) {
- return $this->response($this->error('', 'REQUEST_ID'));
- }
- $seckill_model = new SeckillModel();
- $condition = [
- [ 'ps.id', '=', $seckill_id ],
- [ 'psg.goods_id', '=', $goods_id ],
- [ 'psg.site_id', '=', $this->site_id ],
- [ 'psg.status', '=', 1 ],
- [ 'ps.status', '=', 1 ],
- [ 'g.goods_state', '=', 1 ],
- [ 'g.is_delete', '=', 0 ]
- ];
- $list = $seckill_model->getSeckillGoodsSkuList($condition);
- if (!empty($list[ 'data' ])) {
- foreach ($list[ 'data' ] as $k => $v) {
- if (!empty($v[ 'goods_spec_format' ])) {
- //判断商品规格项
- $goods_spec_format = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, $v[ 'goods_spec_format' ]);
- $list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
- }
- }
- }
- return $this->response($list);
- }
-
- public function page()
- {
- $seckill_time_id = $this->params[ 'seckill_time_id' ] ?? 0;
- $page = $this->params[ 'page' ] ?? 1;
- $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
- if (empty($seckill_time_id)) {
- return $this->response($this->error('', 'REQUEST_SECKILL_ID'));
- }
-
- $seckill_model = new SeckillModel();
- $res = $seckill_model->getSeckillGoodsPageList($seckill_time_id, $this->site_id, $page, $page_size);
- foreach ($res[ 'data' ][ 'list' ] as $key => $val) {
- if ($val[ 'price' ] != 0) {
- $discount_rate = floor($val[ 'seckill_price' ] / $val[ 'price' ] * 100);
- } else {
- $discount_rate = 100;
- }
- $res[ 'data' ][ 'list' ][ $key ][ 'discount_rate' ] = $discount_rate;
- }
- return $this->response($res);
- }
-
- public function lists()
- {
- $seckill_time_id = $this->params[ 'seckill_time_id' ] ?? 0;
- $num = $this->params[ 'num' ] ?? null;
-
- if (empty($seckill_time_id)) {
- return $this->response($this->error('', 'REQUEST_SECKILL_ID'));
- }
-
- $seckill_model = new SeckillModel();
- $res = $seckill_model->getSeckillList($seckill_time_id, $this->site_id, $num);
- $list = $res[ 'data' ];
- foreach ($list as $key => $val) {
- if ($val[ 'price' ] != 0) {
- $discount_rate = floor($val[ 'seckill_price' ] / $val[ 'price' ] * 100);
- } else {
- $discount_rate = 100;
- }
- $list[ $key ][ 'discount_rate' ] = $discount_rate;
- }
-
- return $this->response($this->success($list));
- }
-
- /**
- * 获取商品海报
- */
- public function poster()
- {
- $this->checkToken();
-
- $promotion_type = 'seckill';
- $qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
- $qrcode_param[ 'source_member' ] = $this->member_id;
- $poster = new Poster();
- $res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id);
- return $this->response($res);
- }
-
- /**
- * 分享图片
- * @return false|string
- */
- public function shareImg()
- {
- $qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
-
- $poster = new Poster();
- $res = $poster->shareImg($this->params[ 'page' ] ?? '', $qrcode_param, $this->site_id);
- return $this->response($res);
- }
+params[ 'seckill_id' ] ?? 0;
+ $sku_id = $this->params[ 'sku_id' ] ?? 0;
+ if (empty($seckill_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ if (empty($sku_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ $seckill_model = new SeckillModel();
+ $order_model = new SeckillOrder();
+ $condition = [
+ [ 'ps.id', '=', $seckill_id ],
+ [ 'psg.sku_id', '=', $sku_id ],
+ [ 'psg.site_id', '=', $this->site_id ],
+ [ 'psg.status', '=', 1 ],
+ [ 'ps.status', '=', 1 ],
+ [ 'g.goods_state', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ]
+ ];
+ $goods_sku_detail = $seckill_model->getSeckillGoodsInfo($condition, '')[ 'data' ];
+
+ $res[ 'goods_sku_detail' ] = $goods_sku_detail;
+ if (!empty($goods_sku_detail)) {
+ $num = $order_model->getGoodsSeckillNum($seckill_id);
+ $time_data = $seckill_model->getSeckillInfo($seckill_id)[ 'data' ];
+ $goods_sku_detail[ 'sale_num' ] = $num;
+ $goods_sku_detail[ 'seckill_start_time' ] = $time_data[ 'seckill_start_time' ];
+ $goods_sku_detail[ 'seckill_end_time' ] = $time_data[ 'seckill_end_time' ];
+ //判断商品规格项
+ $goods_spec_format = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
+ $res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
+ } else {
+ $sku_id = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, '');
+ $res = [ 'type' => 'again', 'sku_id' => $sku_id ];
+ }
+ return $this->response($this->success($res));
+ }
+
+ /**
+ * 详情信息
+ */
+ public function detail()
+ {
+ $this->checkToken();
+ $seckill_id = $this->params[ 'seckill_id' ] ?? 0;
+ if (empty($seckill_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ $seckill_model = new SeckillModel();
+ $condition = [
+ [ 'ps.id', '=', $seckill_id ],
+ [ 'psg.site_id', '=', $this->site_id ],
+ [ 'psg.status', '=', 1 ],
+ [ 'ps.status', '=', 1 ],
+ [ 'g.goods_state', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ]
+ ];
+ $goods_sku_detail = $seckill_model->getSeckillGoodsInfo($condition)[ 'data' ];
+
+ $time_data = $seckill_model->getSeckillInfo($seckill_id)[ 'data' ];
+ $goods_sku_detail[ 'seckill_start_time' ] = $time_data[ 'seckill_start_time' ];
+ $goods_sku_detail[ 'seckill_end_time' ] = $time_data[ 'seckill_end_time' ];
+
+ $res[ 'goods_sku_detail' ] = $goods_sku_detail;
+ if (empty($goods_sku_detail)) return $this->response($this->error($res));
+
+ if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
+ //判断商品规格项
+ $goods_spec_format = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
+ $res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
+ }
+
+ // 处理公共数据
+ $goods_sku_api = new GoodsApi();
+ $goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ], $this->member_id, $this->site_id);
+
+ return $this->response($this->success($res));
+ }
+
+ /**
+ * 查询商品SKU集合
+ * @return false|string
+ */
+ public function goodsSku()
+ {
+ $goods_id = $this->params[ 'goods_id' ] ?? 0;
+ $seckill_id = $this->params[ 'seckill_id' ] ?? 0;
+ if (empty($goods_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ if (empty($seckill_id)) {
+ return $this->response($this->error('', 'REQUEST_ID'));
+ }
+ $seckill_model = new SeckillModel();
+ $condition = [
+ [ 'ps.id', '=', $seckill_id ],
+ [ 'psg.goods_id', '=', $goods_id ],
+ [ 'psg.site_id', '=', $this->site_id ],
+ [ 'psg.status', '=', 1 ],
+ [ 'ps.status', '=', 1 ],
+ [ 'g.goods_state', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ]
+ ];
+ $list = $seckill_model->getSeckillGoodsSkuList($condition);
+ if (!empty($list[ 'data' ])) {
+ foreach ($list[ 'data' ] as $k => $v) {
+ if (!empty($v[ 'goods_spec_format' ])) {
+ //判断商品规格项
+ $goods_spec_format = $seckill_model->getGoodsSpecFormat($seckill_id, $this->site_id, $v[ 'goods_spec_format' ]);
+ $list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
+ }
+ }
+ }
+ return $this->response($list);
+ }
+
+ public function page()
+ {
+ $seckill_time_id = $this->params[ 'seckill_time_id' ] ?? 0;
+ $page = $this->params[ 'page' ] ?? 1;
+ $page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
+ if (empty($seckill_time_id)) {
+ return $this->response($this->error('', 'REQUEST_SECKILL_ID'));
+ }
+
+ $seckill_model = new SeckillModel();
+ $res = $seckill_model->getSeckillGoodsPageList($seckill_time_id, $this->site_id, $page, $page_size);
+ foreach ($res[ 'data' ][ 'list' ] as $key => $val) {
+ if ($val[ 'price' ] != 0) {
+ $discount_rate = floor($val[ 'seckill_price' ] / $val[ 'price' ] * 100);
+ } else {
+ $discount_rate = 100;
+ }
+ $res[ 'data' ][ 'list' ][ $key ][ 'discount_rate' ] = $discount_rate;
+ }
+ return $this->response($res);
+ }
+
+ public function lists()
+ {
+ $seckill_time_id = $this->params[ 'seckill_time_id' ] ?? 0;
+ $num = $this->params[ 'num' ] ?? null;
+
+ if (empty($seckill_time_id)) {
+ return $this->response($this->error('', 'REQUEST_SECKILL_ID'));
+ }
+
+ $seckill_model = new SeckillModel();
+ $res = $seckill_model->getSeckillList($seckill_time_id, $this->site_id, $num);
+ $list = $res[ 'data' ];
+ foreach ($list as $key => $val) {
+ if ($val[ 'price' ] != 0) {
+ $discount_rate = floor($val[ 'seckill_price' ] / $val[ 'price' ] * 100);
+ } else {
+ $discount_rate = 100;
+ }
+ $list[ $key ][ 'discount_rate' ] = $discount_rate;
+ }
+
+ return $this->response($this->success($list));
+ }
+
+ /**
+ * 获取商品海报
+ */
+ public function poster()
+ {
+ $this->checkToken();
+
+ $promotion_type = 'seckill';
+ $qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
+ $qrcode_param[ 'source_member' ] = $this->member_id;
+ $poster = new Poster();
+ $res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id);
+ return $this->response($res);
+ }
+
+ /**
+ * 分享图片
+ * @return false|string
+ */
+ public function shareImg()
+ {
+ $qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
+
+ $poster = new Poster();
+ $res = $poster->shareImg($this->params[ 'page' ] ?? '', $qrcode_param, $this->site_id);
+ return $this->response($res);
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/config/diy_view.php b/src/addon/seckill/config/diy_view.php
index 1aaa55c20..54667403e 100644
--- a/src/addon/seckill/config/diy_view.php
+++ b/src/addon/seckill/config/diy_view.php
@@ -1,68 +1,59 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [
- [
- 'name' => 'Seckill',
- 'title' => '秒杀',
- 'type' => 'PROMOTION',
- 'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"goodsMarginType":"default","goodsMarginNum":10,"ornament":{"type":"default","color":"#EDEDED"},"nameLineMode":"single","template":"row1-of1","btnStyle":{"text":"去秒杀","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":true,"support":true,"bgColorStart":"#FF7B1D","bgColorEnd":"#FF1544"},"imgAroundRadius":5,"saleStyle":{"color":"#999CA7","control":true,"support":true},"progressStyle":{"control":true,"support":true,"currColor":"#FDBE6C","bgColor":"#FCECD7"},"titleStyle":{"backgroundImage":"","isShow":true,"leftStyle":"text","leftImg":"","style":"style-1","styleName":"风格1","leftText":"限时秒杀","fontSize":16,"fontWeight":true,"textColor":"#303133","bgColorStart":"#FFFFFF","bgColorEnd":"#FFFFFF","more":"查看更多","moreColor":"#999999","moreFontSize":12,"timeBgColor":"","timeImageUrl":"","moreSupport":true,"colonColor":"#303133","numBgColorStart":"#303133","numBgColorEnd":"#303133","numTextColor":"#FFFFFF"},"slideMode":"scroll","theme":"default","priceStyle":{"mainColor":"#FF1745","mainControl":true,"lineColor":"#999CA7","lineControl":true,"lineSupport":true},"goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false}}',
- 'sort' => '30003',
- 'support_diy_view' => '',
- 'max_count' => 1,
- 'icon' => 'iconfont iconmiaosha1'
- ]
- ],
-
- // 自定义页面路径
- 'link' => [
- [
- 'name' => 'SECKILL',
- 'title' => '秒杀',
- 'parent' => 'MARKETING_LINK',
- 'wap_url' => '',
- 'web_url' => '',
- 'sort' => 0,
- 'child_list' => [
- [
- 'name' => 'SECKILL_PREFECTURE',
- 'title' => '秒杀抢购',
- 'wap_url' => '/pages_promotion/seckill/list',
- 'web_url' => '',
- 'sort' => 0
- ]
- ]
- ]
- ],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [
+ [
+ 'name' => 'Seckill',
+ 'title' => '秒杀',
+ 'type' => 'PROMOTION',
+ 'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"goodsMarginType":"default","goodsMarginNum":10,"ornament":{"type":"default","color":"#EDEDED"},"nameLineMode":"single","template":"row1-of1","btnStyle":{"text":"去秒杀","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":true,"support":true,"bgColorStart":"#FF7B1D","bgColorEnd":"#FF1544"},"imgAroundRadius":5,"saleStyle":{"color":"#999CA7","control":true,"support":true},"progressStyle":{"control":true,"support":true,"currColor":"#FDBE6C","bgColor":"#FCECD7"},"titleStyle":{"backgroundImage":"","isShow":true,"leftStyle":"text","leftImg":"","style":"style-1","styleName":"风格1","leftText":"限时秒杀","fontSize":16,"fontWeight":true,"textColor":"#303133","bgColorStart":"#FFFFFF","bgColorEnd":"#FFFFFF","more":"查看更多","moreColor":"#999999","moreFontSize":12,"timeBgColor":"","timeImageUrl":"","moreSupport":true,"colonColor":"#303133","numBgColorStart":"#303133","numBgColorEnd":"#303133","numTextColor":"#FFFFFF"},"slideMode":"scroll","theme":"default","priceStyle":{"mainColor":"#FF1745","mainControl":true,"lineColor":"#999CA7","lineControl":true,"lineSupport":true},"goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false}}',
+ 'sort' => '30003',
+ 'support_diy_view' => '',
+ 'max_count' => 1,
+ 'icon' => 'iconfont iconmiaosha1'
+ ]
+ ],
+
+ // 自定义页面路径
+ 'link' => [
+ [
+ 'name' => 'SECKILL',
+ 'title' => '秒杀',
+ 'parent' => 'MARKETING_LINK',
+ 'wap_url' => '',
+ 'web_url' => '',
+ 'sort' => 0,
+ 'child_list' => [
+ [
+ 'name' => 'SECKILL_PREFECTURE',
+ 'title' => '秒杀抢购',
+ 'wap_url' => '/pages_promotion/seckill/list',
+ 'web_url' => '',
+ 'sort' => 0
+ ]
+ ]
+ ]
+ ],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/seckill/config/info.php b/src/addon/seckill/config/info.php
index dfcb72c00..52b51dd42 100644
--- a/src/addon/seckill/config/info.php
+++ b/src/addon/seckill/config/info.php
@@ -1,20 +1,12 @@
- 'seckill',
- 'title' => '秒杀抢购',
- 'description' => '低价、限购,吸引更多会员',
- 'type' => 'promotion', //插件类型 system :系统插件 promotion:营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'seckill',
+ 'title' => '秒杀抢购',
+ 'description' => '低价、限购,吸引更多会员',
+ 'type' => 'promotion', //插件类型 system :系统插件 promotion:营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/seckill/event/CloseSeckill.php b/src/addon/seckill/event/CloseSeckill.php
index 918f7a957..66fd2e8c4 100644
--- a/src/addon/seckill/event/CloseSeckill.php
+++ b/src/addon/seckill/event/CloseSeckill.php
@@ -1,27 +1,19 @@
-cronCloseSeckill($params[ 'relate_id' ]);
- return $res;
- }
+cronCloseSeckill($params[ 'relate_id' ]);
+ return $res;
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/CronOrderClose.php b/src/addon/seckill/event/CronOrderClose.php
index ac59a05ea..b68b17f54 100644
--- a/src/addon/seckill/event/CronOrderClose.php
+++ b/src/addon/seckill/event/CronOrderClose.php
@@ -1,33 +1,25 @@
-cronOrderClose($params[ 'order_id' ]);
- return $res;
- }
-
+cronOrderClose($params[ 'order_id' ]);
+ return $res;
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/GoodsPromotion.php b/src/addon/seckill/event/GoodsPromotion.php
index 536a355b7..fe8602cfa 100644
--- a/src/addon/seckill/event/GoodsPromotion.php
+++ b/src/addon/seckill/event/GoodsPromotion.php
@@ -1,65 +1,56 @@
- 'seckill',
- 'promotion_name' => '限时秒杀',
- 'id' => $promotion_addon['seckill']
- ];
- }
- }
-
- } else {
- if (empty($param['goods_id'])) return [];
- $goods_model = new GoodsModel();
- $goods_info = $goods_model->getGoodsInfo([['goods_id', '=', $param['goods_id']]], 'promotion_addon')['data'];
- if (!empty($goods_info['promotion_addon'])) {
- $promotion_addon = json_decode($goods_info['promotion_addon'], true);
- if (!empty($promotion_addon['seckill'])) {
- $seckill_model = new Seckill();
- $goods_detail = $seckill_model->getSeckillInfo($promotion_addon['seckill'])['data'];
- if (!empty($goods_detail)) {
- $time = time() - strtotime(date('Y-m-d'), time());
- if ($time > $goods_detail['seckill_start_time'] && $time < $goods_detail['seckill_end_time']) {
- $goods_detail['promotion_type'] = 'seckill';
- $goods_detail['promotion_name'] = '限时秒杀';
- return $goods_detail;
- }
- }
- }
- }
- return [];
- }
- }
+ 'seckill',
+ 'promotion_name' => '限时秒杀',
+ 'id' => $promotion_addon['seckill']
+ ];
+ }
+ }
+
+ } else {
+ if (empty($param['goods_id'])) return [];
+ $goods_model = new GoodsModel();
+ $goods_info = $goods_model->getGoodsInfo([['goods_id', '=', $param['goods_id']]], 'promotion_addon')['data'];
+ if (!empty($goods_info['promotion_addon'])) {
+ $promotion_addon = json_decode($goods_info['promotion_addon'], true);
+ if (!empty($promotion_addon['seckill'])) {
+ $seckill_model = new Seckill();
+ $goods_detail = $seckill_model->getSeckillInfo($promotion_addon['seckill'])['data'];
+ if (!empty($goods_detail)) {
+ $time = time() - strtotime(date('Y-m-d'), time());
+ if ($time > $goods_detail['seckill_start_time'] && $time < $goods_detail['seckill_end_time']) {
+ $goods_detail['promotion_type'] = 'seckill';
+ $goods_detail['promotion_name'] = '限时秒杀';
+ return $goods_detail;
+ }
+ }
+ }
+ }
+ return [];
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/GoodsPromotionType.php b/src/addon/seckill/event/GoodsPromotionType.php
index bd151c100..236f0e035 100644
--- a/src/addon/seckill/event/GoodsPromotionType.php
+++ b/src/addon/seckill/event/GoodsPromotionType.php
@@ -1,28 +1,19 @@
- '限时秒杀', 'short' => '秒', 'type' => 'seckill', 'color' => '#89689D', 'url' => 'seckill://shop/seckill/goodslist'];
- }
+ '限时秒杀', 'short' => '秒', 'type' => 'seckill', 'color' => '#89689D', 'url' => 'seckill://shop/seckill/goodslist'];
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/Install.php b/src/addon/seckill/event/Install.php
index 31c4e9355..a934f3b73 100644
--- a/src/addon/seckill/event/Install.php
+++ b/src/addon/seckill/event/Install.php
@@ -1,32 +1,24 @@
-getMessage());
- } */
- return success();
- }
+getMessage());
+ } */
+ return success();
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/OpenSeckill.php b/src/addon/seckill/event/OpenSeckill.php
index 80d0aba4c..4690311e7 100644
--- a/src/addon/seckill/event/OpenSeckill.php
+++ b/src/addon/seckill/event/OpenSeckill.php
@@ -1,27 +1,19 @@
-cronOpenSeckill($params[ 'relate_id' ]);
- return $res;
- }
+cronOpenSeckill($params[ 'relate_id' ]);
+ return $res;
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/OrderPromotionType.php b/src/addon/seckill/event/OrderPromotionType.php
index 9974b15a9..38d4dffcd 100644
--- a/src/addon/seckill/event/OrderPromotionType.php
+++ b/src/addon/seckill/event/OrderPromotionType.php
@@ -1,27 +1,19 @@
- "秒杀", "type" => "seckill" ];
- }
+ "秒杀", "type" => "seckill" ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/PromotionType.php b/src/addon/seckill/event/PromotionType.php
index 2c7cb54d4..c14fbc4dc 100644
--- a/src/addon/seckill/event/PromotionType.php
+++ b/src/addon/seckill/event/PromotionType.php
@@ -1,27 +1,19 @@
- "秒杀", "type" => "seckill" ];
- }
+ "秒杀", "type" => "seckill" ];
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/SeckillZoneConfig.php b/src/addon/seckill/event/SeckillZoneConfig.php
index de7e80aa7..1976fc825 100644
--- a/src/addon/seckill/event/SeckillZoneConfig.php
+++ b/src/addon/seckill/event/SeckillZoneConfig.php
@@ -1,37 +1,29 @@
- 'seckill', // 标识
- 'title' => '限时秒杀', // 名称
- 'url' => 'shop/adv/lists?keyword=NS_SECKILL', // 自定义跳转链接
- 'preview' => 'addon/seckill/shop/view/public/img/zone_preview.png', // 预览图
- // 页面配置
- 'value' => [
- 'bg_color' => '#F83530'
- ],
- ];
- return $data;
- }
- }
-
+ 'seckill', // 标识
+ 'title' => '限时秒杀', // 名称
+ 'url' => 'shop/adv/lists?keyword=NS_SECKILL', // 自定义跳转链接
+ 'preview' => 'addon/seckill/shop/view/public/img/zone_preview.png', // 预览图
+ // 页面配置
+ 'value' => [
+ 'bg_color' => '#F83530'
+ ],
+ ];
+ return $data;
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/ShowPromotion.php b/src/addon/seckill/event/ShowPromotion.php
index d6a9c0dcc..f95847aea 100644
--- a/src/addon/seckill/event/ShowPromotion.php
+++ b/src/addon/seckill/event/ShowPromotion.php
@@ -1,91 +1,83 @@
- [
- [
- //插件名称
- 'name' => 'seckill',
- //展示分类(根据平台端设置,shop:店铺营销,member:会员营销, tool:应用工具)
- 'show_type' => 'shop',
- //展示主题
- 'title' => '限时秒杀',
- //展示介绍
- 'description' => '限时抢购引导客户快速下单',
- //展示图标
- 'icon' => 'addon/seckill/icon.png',
- //跳转链接
- 'url' => 'seckill://shop/seckill/goodslist',
- 'summary' => $this->summary($params)
- ]
- ]
-
- ];
- return $data;
- }
-
- /**
- * 营销活动概况
- * @param $params
- * @return array
- */
- private function summary($params)
- {
- if (empty($params)) {
- return [];
- }
-
- if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
- return [];
- }
-
- //获取活动数量
- if (isset($params[ 'count' ])) {
- $count = model("promotion_seckill")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
- return [
- 'count' => $count
- ];
- }
- //获取活动概况,需要获取开始时间与结束时间
- if (isset($params[ 'summary' ])) {
- $list = model("promotion_seckill")->getList([
- [ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
- [ 'site_id', '=', $params[ 'site_id' ] ],
- [ 'status', '<>', 2 ],
- [ 'status', '<>', -1 ]
- ], 'seckill_name as promotion_name,id as promotion_id,start_time,end_time', '', 'a', null, 'seckill_name');
- return !empty($list) ? [
- 'time_limit' => [
- 'count' => count($list),
- 'detail' => $list,
- 'color' => '#6D66FF'
- ]
- ] : [];
- }
- }
+ [
+ [
+ //插件名称
+ 'name' => 'seckill',
+ //展示分类(根据平台端设置,shop:店铺营销,member:会员营销, tool:应用工具)
+ 'show_type' => 'shop',
+ //展示主题
+ 'title' => '限时秒杀',
+ //展示介绍
+ 'description' => '限时抢购引导客户快速下单',
+ //展示图标
+ 'icon' => 'addon/seckill/icon.png',
+ //跳转链接
+ 'url' => 'seckill://shop/seckill/goodslist',
+ 'summary' => $this->summary($params)
+ ]
+ ]
+
+ ];
+ return $data;
+ }
+
+ /**
+ * 营销活动概况
+ * @param $params
+ * @return array
+ */
+ private function summary($params)
+ {
+ if (empty($params)) {
+ return [];
+ }
+
+ if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
+ return [];
+ }
+
+ //获取活动数量
+ if (isset($params[ 'count' ])) {
+ $count = model("promotion_seckill")->getCount([ [ 'site_id', '=', $params[ 'site_id' ] ] ]);
+ return [
+ 'count' => $count
+ ];
+ }
+ //获取活动概况,需要获取开始时间与结束时间
+ if (isset($params[ 'summary' ])) {
+ $list = model("promotion_seckill")->getList([
+ [ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
+ [ 'site_id', '=', $params[ 'site_id' ] ],
+ [ 'status', '<>', 2 ],
+ [ 'status', '<>', -1 ]
+ ], 'seckill_name as promotion_name,id as promotion_id,start_time,end_time', '', 'a', null, 'seckill_name');
+ return !empty($list) ? [
+ 'time_limit' => [
+ 'count' => count($list),
+ 'detail' => $list,
+ 'color' => '#6D66FF'
+ ]
+ ] : [];
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/event/UnInstall.php b/src/addon/seckill/event/UnInstall.php
index 40ec89811..0d86455bd 100644
--- a/src/addon/seckill/event/UnInstall.php
+++ b/src/addon/seckill/event/UnInstall.php
@@ -1,32 +1,24 @@
-getMessage());
- } */
- return error("系统插件不能删除");
- }
+getMessage());
+ } */
+ return error("系统插件不能删除");
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/model/Poster.php b/src/addon/seckill/model/Poster.php
index 5d7282941..1917af2fc 100644
--- a/src/addon/seckill/model/Poster.php
+++ b/src/addon/seckill/model/Poster.php
@@ -1,618 +1,610 @@
-getGoodsInfo($qrcode_param[ 'id' ]);
- if (empty($goods_info)) return $this->error('未获取到商品信息');
-
- $qrcode_param[ 'id' ] = $qrcode_param[ 'seckillId' ];
- unset($qrcode_param[ 'seckillId' ]);
-
- $qrcode_info = $this->getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id);
- if ($qrcode_info[ 'code' ] < 0) return $qrcode_info;
- //判断海报是否存在或停用
- $template_info = $this->getTemplateInfo($goods_info[ 'template_id' ]);
- if (!empty($qrcode_param[ 'source_member' ])) {
- $member_info = $this->getMemberInfo($qrcode_param[ 'source_member' ]);
- }
-
- $upload_config_model = new Config();
- $upload_config_result = $upload_config_model->getDefaultImg($site_id);
-
- $site_model = new Site();
- $condition = array (
- [ "site_id", "=", $site_id ]
- );
- $site_info = $site_model->getSiteInfo($condition);
-
- if (empty($goods_info[ 'template_id' ]) || empty($template_info) || $template_info[ 'template_status' ] == 0) {
- $poster_width = 720;
- $poster_height = 1150;
-
- $poster = new PosterExtend($poster_width, $poster_height);
-
- $option = [
- [
- 'action' => 'setBackground', // 设背景色
- 'data' => [ 255, 255, 255 ]
- ],
- [
- 'action' => 'imageCopy', // 写入商品图
- 'data' => [
- explode(',', $goods_info[ 'sku_image' ])[ 0 ] ?? '',
- 50,
- 165,
- 620,
- 620,
- 'square',
- true,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品名称
- 'data' => [
- $goods_info[ 'sku_name' ],
- 22,
- [ 35, 35, 35 ],
- 50,
- 915,
- 360,
- 2,
- true,
- 1
- ]
- ],
- [
- 'action' => 'imageCopy', // 写入商品二维码
- 'data' => [
- $qrcode_info[ 'data' ][ 'path' ],
- 435,
- 825,
- 240,
- 240,
- 'square',
- 0,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入提示
- 'data' => [
- '长按识别二维码',
- 19,
- [ 102, 102, 102 ],
- 465,
- 1110,
- 490,
- 1,
- 1,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品价格单位
- 'data' => [
- '秒杀价:¥',
- 22,
- [ 255, 0, 0 ],
- 50,
- 860,
- 490,
- 2,
- true,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品价格
- 'data' => [
- $goods_info[ 'seckill_price' ],
- 30,
- [ 255, 0, 0 ],
- 188,
- 862,
- 490,
- 2,
- true,
- 1
- ]
- ],
- ];
- if (!empty($member_info)) {
- $member_option = [
- [
- 'action' => 'imageCircularCopy', // 写入用户头像
- 'data' => [
- !empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
- 50,
- 30,
- 100,
- 100
- ]
- ],
- [
- 'action' => 'imageText', // 写入分享人昵称
- 'data' => [
- $member_info[ 'nickname' ],
- 22,
- [ 10, 10, 10 ],
- 170,
- 80,
- 580,
- 1,
- 1,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入分享人昵称
- 'data' => [
- '限时秒杀,抢到就是赚到',
- 18,
- [ 102, 102, 102 ],
- 170,
- 115,
- 580,
- 1,
- 1,
- 1
- ]
- ]
- ];
- $option = array_merge($option, $member_option);
- }
- } else {
- $condition = [
- [ 'template_id', '=', $goods_info[ 'template_id' ] ],
- [ 'site_id', '=', $site_id ]
- ];
- $poster_template_model = new PosterTemplateModel();
- $poster_data = $poster_template_model->getPosterTemplateInfo($condition);
- $poster_data[ 'data' ][ 'template_json' ] = json_decode($poster_data[ 'data' ][ 'template_json' ], true);
- $poster_width = 720;
- $poster_height = 1280;
- $poster = new PosterExtend($poster_width, $poster_height);
- $fontRate = 0.725; // 20px 等于 14.5磅,换算比率 1px = 0.725磅
- if (!empty($poster_data[ 'data' ][ 'background' ])) {
- list($width, $height, $type, $attr) = getimagesize(img($poster_data[ 'data' ][ 'background' ]));
- $height = 720 * $height / $width;
- $back_ground = [
- 'action' => 'imageCopy', // 写入背景图
- 'data' => [
- img($poster_data[ 'data' ][ 'background' ]),
- 0,
- 0,
- $poster_width,
- $height,
- 'square',
- true,
- 1
- ]
- ];
- } else {
- $back_ground = [
- 'action' => 'setBackground', // 设背景色
- 'data' => [ 255, 255, 255 ]
- ];
- }
- $ground = [
- [
- 'action' => 'setBackground',
- 'data' => [ 255, 255, 255 ]
- ]
- ];
- $option = [
- $back_ground,
- [
- 'action' => 'imageText', // 写入店铺名称
- 'data' => [
- $site_info[ 'data' ][ 'site_name' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] * $fontRate * 2,
- hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'store_name_color' ]),
- $poster_data[ 'data' ][ 'template_json' ][ 'store_name_left' ] * 2,
- ( $poster_data[ 'data' ][ 'template_json' ][ 'store_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] ) * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_name_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_name_height' ] * 2,
- true,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_name_is_show' ]
- ]
- ],
- [
- 'action' => 'imageCopy', // 店铺logo
- 'data' => [
- !empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : getUrl() . '/app/shop/view/public/img/shop_logo.png',
- $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_left' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_top' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_height' ] * 2,
- 'square',
- true,
- $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_is_show' ]
- ]
- ],
- [
- 'action' => 'imageCopy', // 写入商品图
- 'data' => [
- $goods_info[ 'sku_image' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_left' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_top' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_height' ] * 2,
- !empty($poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ] : 'square',
- 0,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_is_show' ]
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品名称
- 'data' => [
- $goods_info[ 'sku_name' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] * $fontRate * 2,
- hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_name_color' ]),
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_left' ] * 2,
- ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] ) * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_width' ] * 2,
- 1,//文本行数 $poster_data['data']['template_json']['goods_name_height']*2,
- true,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_is_show' ]
- ]
- ],
- [
- 'action' => 'imageCopy', // 写入商品二维码
- 'data' => [
- $qrcode_info[ 'data' ][ 'path' ],
- $poster_data[ 'data' ][ 'qrcode_left' ] * 2,
- $poster_data[ 'data' ][ 'qrcode_top' ] * 2,
- $poster_data[ 'data' ][ 'qrcode_width' ] * 2,
- $poster_data[ 'data' ][ 'qrcode_height' ] * 2,
- 'square',
- 0,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品价格
- 'data' => [
- '¥' . $goods_info[ 'seckill_price' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] * $fontRate * 2,
- hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_price_color' ]),
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_left' ] * 2,
- ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] ) * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_height' ] * 2,
- true,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_is_show' ]
- ]
- ],
- ];
-
- if ($goods_info[ 'price' ] == 0) {
- $line = '一一一';
- } else {
- $line = '一一一一';
- }
- $market_price = [
- [
- 'action' => 'imageText', // 写入商品划线价格
- 'data' => [
- '¥' . $goods_info[ 'price' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
- hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2,
- ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] ) * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
- true,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ] ?? 0
- ]
- ],
- [
- 'action' => 'imageText', // 写入线
- 'data' => [
- $line,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
- hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2 - 5,
- ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] ) * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
- true,
- $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ]
- ]
- ],
- ];
- $option = array_merge($option, $market_price);
-
- if (!empty($member_info)) {
- $member_option = [
- [
- 'action' => 'imageCopy', // 写入用户头像
- 'data' => [
- !empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'headimg_left' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'headimg_top' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'headimg_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'headimg_height' ] * 2,
- !empty($poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ] : 'square',
- 0,
- $poster_data[ 'data' ][ 'template_json' ][ 'headimg_is_show' ]
- ]
- ],
- [
- 'action' => 'imageText', // 写入分享人昵称
- 'data' => [
- $member_info[ 'nickname' ],
- $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] * $fontRate * 2,
- hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]),
- $poster_data[ 'data' ][ 'template_json' ][ 'nickname_left' ] * 2,
- ( $poster_data[ 'data' ][ 'template_json' ][ 'nickname_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] ) * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'nickname_width' ] * 2,
- $poster_data[ 'data' ][ 'template_json' ][ 'nickname_height' ] * 2,
- 0,
- $poster_data[ 'data' ][ 'template_json' ][ 'nickname_is_show' ]
- ]
- ],
- ];
- $option = array_merge($ground, $option, $member_option);
- }
-
- }
-
- $option_res = $poster->create($option);
- if (is_array($option_res)) return $option_res;
-
- $res = $option_res->jpeg('upload/poster/goods', 'goods_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . time() . '_' . $app_type);
- if ($res[ 'code' ] == 0) {
- $upload = new Upload($site_id);
- $cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
- if ($cloud_res[ 'code' ] >= 0) {
- return $this->success([ "path" => $cloud_res[ 'data' ] ]);
- } else {
- return $this->error();
- }
- }
- return $res;
- } catch (\Exception $e) {
- return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
-
- /**
- * 获取用户信息
- * @param unknown $member_id
- */
- private function getMemberInfo($member_id)
- {
- $info = model('member')->getInfo([ 'member_id' => $member_id ], 'nickname,headimg');
- return $info;
- }
-
- /**
- * 获取商品信息
- * @param unknown $sku_id
- */
- private function getGoodsInfo($id)
- {
- $alias = 'npsg';
- $join = [
- [ 'goods_sku ngs', 'npsg.sku_id = ngs.sku_id', 'inner' ]
- ];
- $field = 'ngs.sku_name,ngs.introduction,ngs.sku_image,ngs.sku_id,npsg.seckill_price, npsg.seckill_id,ngs.template_id,ngs.price';
- $info = model('promotion_seckill_goods')->getInfo([ 'npsg.goods_id' => $id ], $field, $alias, $join);
- return $info;
- }
-
- /**
- * 获取商品二维码
- * @param unknown $app_type 请求类型
- * @param unknown $page uniapp页面路径
- * @param unknown $qrcode_param 二维码携带参数
- * @param string $promotion_type 活动类型 null为无活动
- */
- private function getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id)
- {
- $res = event('Qrcode', [
- 'site_id' => $site_id,
- 'app_type' => $app_type,
- 'type' => 'create',
- 'data' => $qrcode_param,
- 'page' => $page,
- 'qrcode_path' => 'upload/qrcode/goods',
- 'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . $site_id,
- ], true);
- return $res;
- }
-
- /**
- * 获取海报信息
- * @param unknown $template_id
- */
- private function getTemplateInfo($template_id)
- {
- $info = model('poster_template')->getInfo([ 'template_id' => $template_id ], 'template_id,template_status');
- return $info;
- }
-
- /**
- * 分享图片
- * @param $page
- * @param $qrcode_param
- * @param $site_id
- * @return array|\extend\multitype|PosterExtend|string|string[]
- */
- public function shareImg($page, $qrcode_param, $site_id)
- {
- try {
- $goods_info = $this->getGoodsInfo($qrcode_param[ 'id' ]);
- if (empty($goods_info)) return $this->error('未获取到商品信息');
-
- $poster_width = 600;
- $poster_height = 480;
-
- $poster = new PosterExtend($poster_width, $poster_height);
- $option = [
- [
- 'action' => 'setBackground', // 设背景色
- 'data' => [ 255, 255, 255 ]
- ],
- [
- 'action' => 'imageCopy', // 商品图
- 'data' => [
- $goods_info[ 'sku_image' ],
- 30,
- 145,
- 200,
- 200,
- 'square',
- 50,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品名称
- 'data' => [
- $goods_info[ 'sku_name' ],
- 22,
- [ 51, 51, 51 ],
- 250,
- 190,
- 330,
- 2,
- false,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品价格
- 'data' => [
- '秒杀价:¥',
- 15,
- [ 255, 0, 0 ],
- 250,
- 300,
- 300,
- 2,
- false,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品价格
- 'data' => [
- $goods_info[ 'seckill_price' ],
- 30,
- [ 255, 0, 0 ],
- 345,
- 300,
- 300,
- 2,
- false,
- 1,
- PUBLIC_PATH . 'static/font/custom.ttf'
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品原价
- 'data' => [
- '原 价:¥',
- 15,
- [ 153, 153, 153 ],
- 250,
- 340,
- 300,
- 2,
- false,
- 1
- ]
- ],
- [
- 'action' => 'imageText', // 写入商品原价
- 'data' => [
- $goods_info[ 'price' ],
- 16,
- [ 153, 153, 153 ],
- 345,
- 338,
- 300,
- 2,
- false,
- 1,
- PUBLIC_PATH . 'static/font/custom.ttf',
- ]
- ],
- // 划线(两条线)
- [
- 'action' => 'imageline',
- 'data' => [
- 325,
- 330,
- 325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
- 330,
- [ 153, 153, 153 ],
- ]
- ],
- [
- 'action' => 'imageline',
- 'data' => [
- 325,
- 331,
- 325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
- 331,
- [ 153, 153, 153 ],
- ]
- ],
- [
- 'action' => 'imageCopy', // 背景图
- 'data' => [
- img('upload/share_img/bg/seckill_1.png'),
- 0,
- 0,
- 600,
- 480,
- 'square',
- 0,
- 1
- ]
- ],
- ];
-
- $option_res = $poster->create($option);
- if (is_array($option_res)) {
- return $option_res;
- }
-
- $res = $option_res->jpeg('upload/share_img/seckill_' . $goods_info[ 'seckill_id' ], 'sku_' . $goods_info[ 'sku_id' ]);
- return $res;
- } catch (\Exception $e) {
- return $this->error($e->getMessage());
- }
- }
-
+getGoodsInfo($qrcode_param[ 'id' ]);
+ if (empty($goods_info)) return $this->error('未获取到商品信息');
+
+ $qrcode_param[ 'id' ] = $qrcode_param[ 'seckillId' ];
+ unset($qrcode_param[ 'seckillId' ]);
+
+ $qrcode_info = $this->getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id);
+ if ($qrcode_info[ 'code' ] < 0) return $qrcode_info;
+ //判断海报是否存在或停用
+ $template_info = $this->getTemplateInfo($goods_info[ 'template_id' ]);
+ if (!empty($qrcode_param[ 'source_member' ])) {
+ $member_info = $this->getMemberInfo($qrcode_param[ 'source_member' ]);
+ }
+
+ $upload_config_model = new Config();
+ $upload_config_result = $upload_config_model->getDefaultImg($site_id);
+
+ $site_model = new Site();
+ $condition = array (
+ [ "site_id", "=", $site_id ]
+ );
+ $site_info = $site_model->getSiteInfo($condition);
+
+ if (empty($goods_info[ 'template_id' ]) || empty($template_info) || $template_info[ 'template_status' ] == 0) {
+ $poster_width = 720;
+ $poster_height = 1150;
+
+ $poster = new PosterExtend($poster_width, $poster_height);
+
+ $option = [
+ [
+ 'action' => 'setBackground', // 设背景色
+ 'data' => [ 255, 255, 255 ]
+ ],
+ [
+ 'action' => 'imageCopy', // 写入商品图
+ 'data' => [
+ explode(',', $goods_info[ 'sku_image' ])[ 0 ] ?? '',
+ 50,
+ 165,
+ 620,
+ 620,
+ 'square',
+ true,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品名称
+ 'data' => [
+ $goods_info[ 'sku_name' ],
+ 22,
+ [ 35, 35, 35 ],
+ 50,
+ 915,
+ 360,
+ 2,
+ true,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageCopy', // 写入商品二维码
+ 'data' => [
+ $qrcode_info[ 'data' ][ 'path' ],
+ 435,
+ 825,
+ 240,
+ 240,
+ 'square',
+ 0,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入提示
+ 'data' => [
+ '长按识别二维码',
+ 19,
+ [ 102, 102, 102 ],
+ 465,
+ 1110,
+ 490,
+ 1,
+ 1,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品价格单位
+ 'data' => [
+ '秒杀价:¥',
+ 22,
+ [ 255, 0, 0 ],
+ 50,
+ 860,
+ 490,
+ 2,
+ true,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品价格
+ 'data' => [
+ $goods_info[ 'seckill_price' ],
+ 30,
+ [ 255, 0, 0 ],
+ 188,
+ 862,
+ 490,
+ 2,
+ true,
+ 1
+ ]
+ ],
+ ];
+ if (!empty($member_info)) {
+ $member_option = [
+ [
+ 'action' => 'imageCircularCopy', // 写入用户头像
+ 'data' => [
+ !empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
+ 50,
+ 30,
+ 100,
+ 100
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入分享人昵称
+ 'data' => [
+ $member_info[ 'nickname' ],
+ 22,
+ [ 10, 10, 10 ],
+ 170,
+ 80,
+ 580,
+ 1,
+ 1,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入分享人昵称
+ 'data' => [
+ '限时秒杀,抢到就是赚到',
+ 18,
+ [ 102, 102, 102 ],
+ 170,
+ 115,
+ 580,
+ 1,
+ 1,
+ 1
+ ]
+ ]
+ ];
+ $option = array_merge($option, $member_option);
+ }
+ } else {
+ $condition = [
+ [ 'template_id', '=', $goods_info[ 'template_id' ] ],
+ [ 'site_id', '=', $site_id ]
+ ];
+ $poster_template_model = new PosterTemplateModel();
+ $poster_data = $poster_template_model->getPosterTemplateInfo($condition);
+ $poster_data[ 'data' ][ 'template_json' ] = json_decode($poster_data[ 'data' ][ 'template_json' ], true);
+ $poster_width = 720;
+ $poster_height = 1280;
+ $poster = new PosterExtend($poster_width, $poster_height);
+ $fontRate = 0.725; // 20px 等于 14.5磅,换算比率 1px = 0.725磅
+ if (!empty($poster_data[ 'data' ][ 'background' ])) {
+ list($width, $height, $type, $attr) = getimagesize(img($poster_data[ 'data' ][ 'background' ]));
+ $height = 720 * $height / $width;
+ $back_ground = [
+ 'action' => 'imageCopy', // 写入背景图
+ 'data' => [
+ img($poster_data[ 'data' ][ 'background' ]),
+ 0,
+ 0,
+ $poster_width,
+ $height,
+ 'square',
+ true,
+ 1
+ ]
+ ];
+ } else {
+ $back_ground = [
+ 'action' => 'setBackground', // 设背景色
+ 'data' => [ 255, 255, 255 ]
+ ];
+ }
+ $ground = [
+ [
+ 'action' => 'setBackground',
+ 'data' => [ 255, 255, 255 ]
+ ]
+ ];
+ $option = [
+ $back_ground,
+ [
+ 'action' => 'imageText', // 写入店铺名称
+ 'data' => [
+ $site_info[ 'data' ][ 'site_name' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] * $fontRate * 2,
+ hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'store_name_color' ]),
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_name_left' ] * 2,
+ ( $poster_data[ 'data' ][ 'template_json' ][ 'store_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] ) * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_name_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_name_height' ] * 2,
+ true,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_name_is_show' ]
+ ]
+ ],
+ [
+ 'action' => 'imageCopy', // 店铺logo
+ 'data' => [
+ !empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : getUrl() . '/app/shop/view/public/img/shop_logo.png',
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_left' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_top' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_height' ] * 2,
+ 'square',
+ true,
+ $poster_data[ 'data' ][ 'template_json' ][ 'store_logo_is_show' ]
+ ]
+ ],
+ [
+ 'action' => 'imageCopy', // 写入商品图
+ 'data' => [
+ $goods_info[ 'sku_image' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_left' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_top' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_height' ] * 2,
+ !empty($poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ] : 'square',
+ 0,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_is_show' ]
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品名称
+ 'data' => [
+ $goods_info[ 'sku_name' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] * $fontRate * 2,
+ hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_name_color' ]),
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_left' ] * 2,
+ ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] ) * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_width' ] * 2,
+ 1,//文本行数 $poster_data['data']['template_json']['goods_name_height']*2,
+ true,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_is_show' ]
+ ]
+ ],
+ [
+ 'action' => 'imageCopy', // 写入商品二维码
+ 'data' => [
+ $qrcode_info[ 'data' ][ 'path' ],
+ $poster_data[ 'data' ][ 'qrcode_left' ] * 2,
+ $poster_data[ 'data' ][ 'qrcode_top' ] * 2,
+ $poster_data[ 'data' ][ 'qrcode_width' ] * 2,
+ $poster_data[ 'data' ][ 'qrcode_height' ] * 2,
+ 'square',
+ 0,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品价格
+ 'data' => [
+ '¥' . $goods_info[ 'seckill_price' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] * $fontRate * 2,
+ hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_price_color' ]),
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_left' ] * 2,
+ ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] ) * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_height' ] * 2,
+ true,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_is_show' ]
+ ]
+ ],
+ ];
+
+ if ($goods_info[ 'price' ] == 0) {
+ $line = '一一一';
+ } else {
+ $line = '一一一一';
+ }
+ $market_price = [
+ [
+ 'action' => 'imageText', // 写入商品划线价格
+ 'data' => [
+ '¥' . $goods_info[ 'price' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
+ hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2,
+ ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] ) * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
+ true,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ] ?? 0
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入线
+ 'data' => [
+ $line,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
+ hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2 - 5,
+ ( $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] ) * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
+ true,
+ $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ]
+ ]
+ ],
+ ];
+ $option = array_merge($option, $market_price);
+
+ if (!empty($member_info)) {
+ $member_option = [
+ [
+ 'action' => 'imageCopy', // 写入用户头像
+ 'data' => [
+ !empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'headimg_left' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'headimg_top' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'headimg_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'headimg_height' ] * 2,
+ !empty($poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ] : 'square',
+ 0,
+ $poster_data[ 'data' ][ 'template_json' ][ 'headimg_is_show' ]
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入分享人昵称
+ 'data' => [
+ $member_info[ 'nickname' ],
+ $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] * $fontRate * 2,
+ hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]),
+ $poster_data[ 'data' ][ 'template_json' ][ 'nickname_left' ] * 2,
+ ( $poster_data[ 'data' ][ 'template_json' ][ 'nickname_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] ) * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'nickname_width' ] * 2,
+ $poster_data[ 'data' ][ 'template_json' ][ 'nickname_height' ] * 2,
+ 0,
+ $poster_data[ 'data' ][ 'template_json' ][ 'nickname_is_show' ]
+ ]
+ ],
+ ];
+ $option = array_merge($ground, $option, $member_option);
+ }
+
+ }
+
+ $option_res = $poster->create($option);
+ if (is_array($option_res)) return $option_res;
+
+ $res = $option_res->jpeg('upload/poster/goods', 'goods_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . time() . '_' . $app_type);
+ if ($res[ 'code' ] == 0) {
+ $upload = new Upload($site_id);
+ $cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
+ if ($cloud_res[ 'code' ] >= 0) {
+ return $this->success([ "path" => $cloud_res[ 'data' ] ]);
+ } else {
+ return $this->error();
+ }
+ }
+ return $res;
+ } catch (\Exception $e) {
+ return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
+ }
+ }
+
+ /**
+ * 获取用户信息
+ * @param unknown $member_id
+ */
+ private function getMemberInfo($member_id)
+ {
+ $info = model('member')->getInfo([ 'member_id' => $member_id ], 'nickname,headimg');
+ return $info;
+ }
+
+ /**
+ * 获取商品信息
+ * @param unknown $sku_id
+ */
+ private function getGoodsInfo($id)
+ {
+ $alias = 'npsg';
+ $join = [
+ [ 'goods_sku ngs', 'npsg.sku_id = ngs.sku_id', 'inner' ]
+ ];
+ $field = 'ngs.sku_name,ngs.introduction,ngs.sku_image,ngs.sku_id,npsg.seckill_price, npsg.seckill_id,ngs.template_id,ngs.price';
+ $info = model('promotion_seckill_goods')->getInfo([ 'npsg.goods_id' => $id ], $field, $alias, $join);
+ return $info;
+ }
+
+ /**
+ * 获取商品二维码
+ * @param unknown $app_type 请求类型
+ * @param unknown $page uniapp页面路径
+ * @param unknown $qrcode_param 二维码携带参数
+ * @param string $promotion_type 活动类型 null为无活动
+ */
+ private function getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id)
+ {
+ $res = event('Qrcode', [
+ 'site_id' => $site_id,
+ 'app_type' => $app_type,
+ 'type' => 'create',
+ 'data' => $qrcode_param,
+ 'page' => $page,
+ 'qrcode_path' => 'upload/qrcode/goods',
+ 'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . $site_id,
+ ], true);
+ return $res;
+ }
+
+ /**
+ * 获取海报信息
+ * @param unknown $template_id
+ */
+ private function getTemplateInfo($template_id)
+ {
+ $info = model('poster_template')->getInfo([ 'template_id' => $template_id ], 'template_id,template_status');
+ return $info;
+ }
+
+ /**
+ * 分享图片
+ * @param $page
+ * @param $qrcode_param
+ * @param $site_id
+ * @return array|\extend\multitype|PosterExtend|string|string[]
+ */
+ public function shareImg($page, $qrcode_param, $site_id)
+ {
+ try {
+ $goods_info = $this->getGoodsInfo($qrcode_param[ 'id' ]);
+ if (empty($goods_info)) return $this->error('未获取到商品信息');
+
+ $poster_width = 600;
+ $poster_height = 480;
+
+ $poster = new PosterExtend($poster_width, $poster_height);
+ $option = [
+ [
+ 'action' => 'setBackground', // 设背景色
+ 'data' => [ 255, 255, 255 ]
+ ],
+ [
+ 'action' => 'imageCopy', // 商品图
+ 'data' => [
+ $goods_info[ 'sku_image' ],
+ 30,
+ 145,
+ 200,
+ 200,
+ 'square',
+ 50,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品名称
+ 'data' => [
+ $goods_info[ 'sku_name' ],
+ 22,
+ [ 51, 51, 51 ],
+ 250,
+ 190,
+ 330,
+ 2,
+ false,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品价格
+ 'data' => [
+ '秒杀价:¥',
+ 15,
+ [ 255, 0, 0 ],
+ 250,
+ 300,
+ 300,
+ 2,
+ false,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品价格
+ 'data' => [
+ $goods_info[ 'seckill_price' ],
+ 30,
+ [ 255, 0, 0 ],
+ 345,
+ 300,
+ 300,
+ 2,
+ false,
+ 1,
+ PUBLIC_PATH . 'static/font/custom.ttf'
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品原价
+ 'data' => [
+ '原 价:¥',
+ 15,
+ [ 153, 153, 153 ],
+ 250,
+ 340,
+ 300,
+ 2,
+ false,
+ 1
+ ]
+ ],
+ [
+ 'action' => 'imageText', // 写入商品原价
+ 'data' => [
+ $goods_info[ 'price' ],
+ 16,
+ [ 153, 153, 153 ],
+ 345,
+ 338,
+ 300,
+ 2,
+ false,
+ 1,
+ PUBLIC_PATH . 'static/font/custom.ttf',
+ ]
+ ],
+ // 划线(两条线)
+ [
+ 'action' => 'imageline',
+ 'data' => [
+ 325,
+ 330,
+ 325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
+ 330,
+ [ 153, 153, 153 ],
+ ]
+ ],
+ [
+ 'action' => 'imageline',
+ 'data' => [
+ 325,
+ 331,
+ 325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
+ 331,
+ [ 153, 153, 153 ],
+ ]
+ ],
+ [
+ 'action' => 'imageCopy', // 背景图
+ 'data' => [
+ img('upload/share_img/bg/seckill_1.png'),
+ 0,
+ 0,
+ 600,
+ 480,
+ 'square',
+ 0,
+ 1
+ ]
+ ],
+ ];
+
+ $option_res = $poster->create($option);
+ if (is_array($option_res)) {
+ return $option_res;
+ }
+
+ $res = $option_res->jpeg('upload/share_img/seckill_' . $goods_info[ 'seckill_id' ], 'sku_' . $goods_info[ 'sku_id' ]);
+ return $res;
+ } catch (\Exception $e) {
+ return $this->error($e->getMessage());
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/seckill/model/Seckill.php b/src/addon/seckill/model/Seckill.php
index 374371c3f..0196b52c7 100644
--- a/src/addon/seckill/model/Seckill.php
+++ b/src/addon/seckill/model/Seckill.php
@@ -1,901 +1,893 @@
- $data[ 'seckill_end_time' ]) {
- return $this->error('', '秒杀时间段设置错误');
- }
-
- //时间段检测
- $seckill_count = model('promotion_seckill_time')->getCount([
- [ 'seckill_start_time|seckill_end_time', 'between', [ $data[ 'seckill_start_time' ], $data[ 'seckill_end_time' ] ] ],
- [ 'site_id', '=', $data[ 'site_id' ] ]
- ]);
- if ($seckill_count > 0) {
- return $this->error('', '秒杀场次设置冲突');
- }
- $seckill_count = model('promotion_seckill_time')->getCount([
- [ 'seckill_start_time', '<=', $data[ 'seckill_start_time' ] ],
- [ 'seckill_end_time', '>=', $data[ 'seckill_end_time' ] ],
- [ 'site_id', '=', $data[ 'site_id' ] ]
- ]);
- if ($seckill_count > 0) {
- return $this->error('', '秒杀场次设置冲突');
- }
- //添加数据
- $data[ 'create_time' ] = time();
- $seckill_id = model('promotion_seckill_time')->add($data);
- Cache::tag("promotion_seckill_time")->clear();
- return $this->success($seckill_id);
- }
-
- /**
- * 修改秒杀时段
- * @param $data
- * @param $site_id
- * @return array
- */
- public function editSeckillTime($data, $site_id)
- {
- if ($data[ 'seckill_start_time' ] > $data[ 'seckill_end_time' ]) {
- return $this->error('', '秒杀时间段设置错误');
- }
- //时间段检测
- $seckill_count = model('promotion_seckill_time')->getCount([
- [ 'seckill_start_time|seckill_end_time', 'between', [ $data[ 'seckill_start_time' ], $data[ 'seckill_end_time' ] ] ],
- [ 'site_id', '=', $site_id ],
- [ 'id', '<>', $data[ 'id' ] ]
- ]);
- if ($seckill_count > 0) {
- return $this->error('', '秒杀场次设置冲突');
- }
- $seckill_count = model('promotion_seckill_time')->getCount([
- [ 'seckill_start_time', '<=', $data[ 'seckill_start_time' ] ],
- [ 'seckill_end_time', '>=', $data[ 'seckill_end_time' ] ],
- [ 'site_id', '=', $site_id ],
- [ 'id', '<>', $data[ 'id' ] ]
- ]);
- if ($seckill_count > 0) {
- return $this->error('', '秒杀场次设置冲突');
- }
-
- //更新数据
- $data[ 'modify_time' ] = time();
- $res = model('promotion_seckill_time')->update($data, [ [ 'id', '=', $data[ 'id' ] ] ]);
- Cache::tag("promotion_seckill_time")->clear();
- return $this->success($res);
- }
-
- /**
- * 删除秒杀时段
- * @param $seckill_time_id
- * @return array
- */
- public function deleteSeckillTime($seckill_time_id)
- {
- $res = model('promotion_seckill_time')->delete([ [ 'id', '=', $seckill_time_id ] ]);
- if ($res) {
-
- $goods = new Goods();
-
- $condition = [
- [ 'seckill_time_id', 'like', '%,' . $seckill_time_id . ',%' ]
- ];
- $seckill_list = model('promotion_seckill')->getList($condition, 'id,seckill_time_id,goods_id');
-
- foreach ($seckill_list as $k => $v) {
-
- $time_ids = explode(',', trim($v[ 'seckill_time_id' ], ','));
- unset($time_ids[ array_search($seckill_time_id, $time_ids) ]);
-
- if (empty($time_ids)) {
- $goods->modifyPromotionAddon($v[ 'goods_id' ], [ 'seckill' => $v[ 'id' ] ], true);
- model('promotion_seckill_goods')->delete([ [ 'seckill_id', '=', $v[ 'id' ] ] ]);
- model('promotion_seckill')->delete([ [ 'id', '=', $v[ 'id' ] ] ]);
- } else {
-
- $time_id = ',' . implode(',', $time_ids) . ',';
- model('promotion_seckill')->update([ 'seckill_time_id' => $time_id ], [ [ 'id', '=', $v[ 'id' ] ] ]);
- model('promotion_seckill_goods')->update([ 'seckill_time_id' => $time_id ], [ [ 'seckill_id', '=', $v[ 'id' ] ] ]);
- }
-
- }
- }
- Cache::tag("promotion_seckill_time")->clear();
- return $this->success($res);
- }
-
- /**
- * 获取秒杀时段信息
- * @param $condition
- * @param string $field
- * @return array
- */
- public function getSeckillTimeInfo($condition, $field = '*')
- {
- $data = json_encode([ $condition, $field ]);
- $cache = Cache::get("promotion_seckill_time_getSeckillInfo_" . $data);
- if (!empty($cache)) {
- return $this->success($cache);
- }
- $res = model('promotion_seckill_time')->getInfo($condition, $field);
- Cache::tag("promotion_seckill_time")->set("promotion_seckill_time_getSeckillInfo_" . $data, $res);
- return $this->success($res);
- }
-
- /**
- * 获取秒杀时段列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @return array
- */
- public function getSeckillTimeList($condition = [], $field = '*', $order = '', $limit = null)
- {
- $list = model('promotion_seckill_time')->getList($condition, $field, $order, '', '', '', $limit);
- return $this->success($list);
- }
-
- /**
- * 获取有商品的秒杀时段列表
- * @param $condition
- * @param $field
- * @param string $order
- * @return array
- */
- public function getGoodsSeckillTimeList($condition, $field, $order = 'seckill_start_time asc')
- {
- if (empty($field)) {
- $field = 'id, site_id, name, seckill_start_time, seckill_end_time';
- }
-
- $seckill_time = model('promotion_seckill_time')->getList($condition, $field, $order);
- foreach ($seckill_time as $k => $v) {
- $condition = [
- [ 'seckill_time_id', 'like', '%,' . $v[ 'id' ] . ',%' ],
- [ 'status', '=', 1 ],
- [ 'g.goods_state', '=', 1 ],
- [ 'g.is_delete', '=', 0 ]
- ];
- $join = [
- [ 'goods g', 'g.goods_id = psg.goods_id', 'inner' ]
- ];
- $goods = model('promotion_seckill_goods')->getInfo($condition, 'id', 'psg', $join);
- if (empty($goods)) unset($seckill_time[ $k ]);
- }
- return $this->success($seckill_time);
- }
-
- /**
- * 转换秒杀时间
- * @param $info
- * @return mixed
- */
- public function transformSeckillTime($info)
- {
- $info[ 'start_hour' ] = floor($info[ 'seckill_start_time' ] / 3600);
- $info[ 'start_minute' ] = floor(( $info[ 'seckill_start_time' ] % 3600 ) / 60);
- $info[ 'start_second' ] = $info[ 'seckill_start_time' ] % 60;
-
- $info[ 'end_hour' ] = floor($info[ 'seckill_end_time' ] / 3600);
- $info[ 'end_minute' ] = floor(( $info[ 'seckill_end_time' ] % 3600 ) / 60);
- $info[ 'end_second' ] = $info[ 'seckill_end_time' ] % 60;
-
- if ($info[ 'start_hour' ] < 10) $info[ 'start_hour' ] = '0' . $info[ 'start_hour' ];
- if ($info[ 'start_minute' ] < 10) $info[ 'start_minute' ] = '0' . $info[ 'start_minute' ];
- if ($info[ 'start_second' ] < 10) $info[ 'start_second' ] = '0' . $info[ 'start_second' ];
-
- if ($info[ 'end_hour' ] < 10) $info[ 'end_hour' ] = '0' . $info[ 'end_hour' ];
- if ($info[ 'end_minute' ] < 10) $info[ 'end_minute' ] = '0' . $info[ 'end_minute' ];
- if ($info[ 'end_second' ] < 10) $info[ 'end_second' ] = '0' . $info[ 'end_second' ];
-
- return $info;
- }
-
- /******************************************************秒杀商品*********************************************************************/
- /**
- * 添加秒杀商品
- * @param $data
- * @return array
- */
- public function addSeckillGoods($data)
- {
- $cron = new Cron();
- $goods_data = $data[ 'goods_data' ];
-
- if (empty($data[ 'seckill_time_id' ])) {
- return $this->error('', '请选择秒杀时段');
- }
- $seckill_time_id = explode(',', $data[ 'seckill_time_id' ]);
-
- //时间段检测
- foreach ($seckill_time_id as $v) {
- $seckill_count = model('promotion_seckill')->getCount([
- [ 'goods_id', 'in', $data[ 'goods_ids' ] ],
- [ 'status', 'in', '0,1' ],
- [ 'seckill_time_id', 'like', '%,' . $v . ',%' ],
- [ 'site_id', '=', $data[ 'site_id' ] ],
- [ '', 'exp', Db::raw('not ( (`start_time` > ' . $data[ 'end_time' ] . ' and `start_time` > ' . $data[ 'start_time' ] . ' ) or (`end_time` < ' . $data[ 'start_time' ] . ' and `end_time` < ' . $data[ 'end_time' ] . '))') ]//todo 修正 所有的优惠都要一样
- ]);
- if ($seckill_count > 0) {
- return $this->error('', '有商品已设置秒杀,请不要重复设置');
- }
- }
-
- model('promotion_seckill')->startTrans();
- try {
- $seckill_data = [
- 'site_id' => $data[ 'site_id' ],
- 'seckill_name' => $data[ 'seckill_name' ],
- 'remark' => $data[ 'remark' ],
- 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
- 'start_time' => $data[ 'start_time' ],
- 'end_time' => $data[ 'end_time' ],
- 'create_time' => time(),
- 'sort' => $data[ 'sort' ],
- ];
-
- $goods = new Goods();
- $add_goods_data = [];
- foreach ($goods_data as $k => $v) {
- $seckill_data[ 'goods_id' ] = $v[ 'goods_id' ];
- $seckill_data[ 'goods_name' ] = $v[ 'sku_list' ][ 0 ][ 'sku_name' ];
- $seckill_data[ 'goods_image' ] = $v[ 'sku_list' ][ 0 ][ 'sku_image' ];
- $seckill_data[ 'seckill_price' ] = $v[ 'sku_list' ][ 0 ][ 'seckill_price' ];
-
- if ($data[ 'start_time' ] <= time()) {
- $seckill_data[ 'status' ] = 1;//直接启动
- $seckill_id = model('promotion_seckill')->add($seckill_data);
- $goods->modifyPromotionAddon($v[ 'goods_id' ], [ 'seckill' => $seckill_id ]);
- $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
- } else {
- $seckill_data[ 'status' ] = 0;
- $seckill_id = model('promotion_seckill')->add($seckill_data);
- $cron->addCron(1, 0, "秒杀开启", "OpenSeckill", $data[ 'start_time' ], $seckill_id);
- $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
- }
-
- $goods_stock = 0; // 秒杀商品总库存
-
- foreach ($v[ 'sku_list' ] as $key => $item) {
- $sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'goods_id, sku_id, sku_name,price,sku_image');
- $add_goods_data[] = [
- 'site_id' => $data[ 'site_id' ],
- 'seckill_id' => $seckill_id,
- 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
- 'sku_id' => $item[ 'sku_id' ],
- 'goods_id' => $item[ 'goods_id' ],
- 'sku_image' => $sku_info[ 'sku_image' ],
- 'sku_name' => $sku_info[ 'sku_name' ],
- 'seckill_price' => $item[ 'seckill_price' ],
- 'price' => $sku_info[ 'price' ],
- 'stock' => $item[ 'seckill_stock' ],
- 'max_buy' => $item[ 'max_buy' ],
- 'status' => $seckill_data[ 'status' ]
- ];
- $goods_stock += $item[ 'seckill_stock' ];
- }
- model('promotion_seckill')->update([ 'goods_stock' => $goods_stock ], [ [ 'id', '=', $seckill_id ] ]);
- }
- model('promotion_seckill_goods')->addList($add_goods_data);
- foreach ($seckill_time_id as $v) {
- $count = model('promotion_seckill_goods')->getCount([ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ] ], '*', 'a', '', 'goods_id');
- model('promotion_seckill_time')->update([ 'goods_num' => $count ], [ [ 'id', '=', $v ] ]);
- }
- model('promotion_seckill')->commit();
- return $this->success();
- } catch (\Exception $e) {
- model('promotion_seckill')->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
- /**
- * 修改秒杀商品
- * @param $data
- * @return array
- */
- public function editSeckillGoods($data)
- {
- $cron = new Cron();
-
- if (empty($data[ 'seckill_time_id' ])) {
- return $this->error('', '请选择秒杀时段');
- }
- $seckill_time_id = explode(',', $data[ 'seckill_time_id' ]);
-
- //时间段检测
- foreach ($seckill_time_id as $v) {
- $seckill_count = model('promotion_seckill')->getInfo([
- [ 'goods_id', 'in', $data[ 'goods_ids' ] ],
- [ 'status', 'in', '0,1' ],
- [ 'site_id', '=', $data[ 'site_id' ] ],
- [ 'seckill_time_id', 'like', '%,' . $v . ',%' ],
- [ 'id', '<>', $data[ 'id' ] ],
- [ '', 'exp', Db::raw('not ( (`start_time` > ' . $data[ 'end_time' ] . ' and `start_time` > ' . $data[ 'start_time' ] . ' ) or (`end_time` < ' . $data[ 'start_time' ] . ' and `end_time` < ' . $data[ 'end_time' ] . '))') ]//todo 修正 所有的优惠都要一样
- ]);
- if ($seckill_count > 0) {
- return $this->error('', '有商品已设置秒杀,请不要重复设置');
- }
- }
-
- model('promotion_seckill')->startTrans();
- try {
- $seckill_data = [
- 'site_id' => $data[ 'site_id' ],
- 'seckill_name' => $data[ 'seckill_name' ],
- 'remark' => $data[ 'remark' ],
- 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
- 'start_time' => $data[ 'start_time' ],
- 'end_time' => $data[ 'end_time' ],
- 'modify_time' => time(),
- 'sort' => $data[ 'sort' ],
- ];
-
- $goods = new Goods();
- $add_goods_data = [];
- $seckill_data[ 'goods_id' ] = $data[ 'sku_list' ][ 0 ][ 'goods_id' ];
- $seckill_data[ 'goods_name' ] = $data[ 'sku_list' ][ 0 ][ 'sku_name' ];
- $seckill_data[ 'goods_image' ] = $data[ 'sku_list' ][ 0 ][ 'sku_image' ];
- $seckill_data[ 'seckill_price' ] = $data[ 'sku_list' ][ 0 ][ 'seckill_price' ];
-
- $seckill_id = $data[ 'id' ];
-
- if ($data[ 'start_time' ] <= time()) {
- $seckill_data[ 'status' ] = 1;//直接启动
- model('promotion_seckill')->update($seckill_data, [ [ 'id', '=', $seckill_id ] ]);
- $goods->modifyPromotionAddon($data[ 'sku_list' ][ 0 ][ 'goods_id' ], [ 'seckill' => $seckill_id ]);
- $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
- } else {
- $seckill_data[ 'status' ] = 0;
- model('promotion_seckill')->update($seckill_data, [ [ 'id', '=', $seckill_id ] ]);
- $cron->addCron(1, 0, "秒杀开启", "OpenSeckill", $data[ 'start_time' ], $seckill_id);
- $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
- }
-
- model('promotion_seckill_goods')->delete([ [ 'seckill_id', '=', $seckill_id ] ]);
-
- $goods_stock = 0; // 秒杀商品总库存
-
- foreach ($data[ 'sku_list' ] as $key => $item) {
- $sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'goods_id, sku_id, sku_name,price,sku_image');
- $add_goods_data[] = [
- 'site_id' => $data[ 'site_id' ],
- 'seckill_id' => $seckill_id,
- 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
- 'sku_id' => $item[ 'sku_id' ],
- 'goods_id' => $item[ 'goods_id' ],
- 'sku_image' => $sku_info[ 'sku_image' ],
- 'sku_name' => $sku_info[ 'sku_name' ],
- 'seckill_price' => $item[ 'seckill_price' ],
- 'price' => $sku_info[ 'price' ],
- 'stock' => $item[ 'seckill_stock' ],
- 'max_buy' => $item[ 'max_buy' ],
- 'status' => $seckill_data[ 'status' ]
- ];
- $goods_stock += $item[ 'seckill_stock' ];
- }
- model('promotion_seckill')->update([ 'goods_stock' => $goods_stock ], [ [ 'id', '=', $seckill_id ] ]);
- model('promotion_seckill_goods')->addList($add_goods_data);
-
- foreach ($seckill_time_id as $v) {
- $count = model('promotion_seckill_goods')->getCount([ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ] ], '*', 'a', '', 'goods_id');
- model('promotion_seckill_time')->update([ 'goods_num' => $count ], [ [ 'id', '=', $v ] ]);
- }
- model('promotion_seckill')->commit();
- return $this->success();
- } catch (\Exception $e) {
- model('promotion_seckill')->rollback();
- return $this->error('', $e->getMessage());
- }
- }
-
- public function seckillSort($id, $sort)
- {
- $res = model('promotion_seckill')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
- return $this->success($res);
- }
-
- /**
- * 秒杀商品详情
- * @param array $condition
- * @param string $field
- * @param string $alias
- * @param array $join
- * @return array
- */
- public function getSeckillDetail($condition = [], $field = '*', $alias = '', $join = [])
- {
- $info = model("promotion_seckill")->getInfo($condition, $field, $alias, $join);
-
- $goods_sku = model('goods_sku')->getList([ [ 'goods_id', '=', $info[ 'goods_id' ] ], [ 'is_delete', '=', 0 ], [ 'goods_state', '=', 1 ] ], 'stock as goods_stock, goods_id, sku_id, sku_name,price,sku_image,stock');
-
- $discount_goods = model("promotion_seckill_goods")->getList([ [ 'goods_id', '=', $info[ 'goods_id' ] ], [ 'seckill_id', '=', $info[ 'id' ] ] ], '*');
-
- foreach ($goods_sku as $k => $v) {
- $goods_sku[ $k ][ 'is_select' ] = 0;
- $goods_sku[ $k ][ 'seckill_price' ] = $v[ 'price' ];
- $goods_sku[ $k ][ 'seckill_stock' ] = 0;
- $goods_sku[ $k ][ 'max_buy' ] = 0;
- $goods_sku[ $k ][ 'stock' ] = numberFormat($goods_sku[ $k ][ 'stock' ]);
- $goods_sku[ $k ][ 'goods_stock' ] = numberFormat($goods_sku[ $k ][ 'goods_stock' ]);
- foreach ($discount_goods as $key => $val) {
- if ($val[ 'sku_id' ] == $v[ 'sku_id' ]) {
- $goods_sku[ $k ][ 'is_select' ] = 1;
- $goods_sku[ $k ][ 'seckill_price' ] = $val[ 'seckill_price' ];
- $goods_sku[ $k ][ 'seckill_stock' ] = $val[ 'stock' ];
- $goods_sku[ $k ][ 'max_buy' ] = $val[ 'max_buy' ];
- }
- }
- }
-
- $info[ 'goods_sku' ] = $goods_sku;
- $info[ 'seckill_goods' ] = $discount_goods;
-
- return $this->success($info);
- }
-
- /**
- * 修改秒杀商品限购数量
- * @param $seckill_id
- * @param $site_id
- * @param $sku_id
- * @param $max_buy
- * @return array
- */
- public function editSeckillGoodsNum($seckill_id, $site_id, $sku_id, $max_buy)
- {
- $data = [
- 'seckill_id' => $seckill_id,
- 'site_id' => $site_id,
- 'sku_id' => $sku_id,
- 'max_buy' => $max_buy
- ];
- model("promotion_seckill_goods")->update($data, [ [ 'seckill_id', '=', $seckill_id ], [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $site_id ] ]);
- return $this->success();
- }
-
- /**
- * 删除秒杀商品
- * @param $seckill_id
- * @param $site_id
- * @return array
- */
- public function deleteSeckillGoods($seckill_id, $site_id)
- {
- $info = model("promotion_seckill")->getInfo([ [ 'id', '=', $seckill_id ] ], 'goods_id,seckill_time_id,status');
-
- if(empty($info)) return $this->error('', '该秒杀活动不存在');
- if($info['status'] == 1) return $this->error('', '该秒杀活动正在进行');
-
- $goods = new Goods();
- $goods->modifyPromotionAddon($info[ 'goods_id' ], [ 'seckill' => $seckill_id ], true);
- model("promotion_seckill")->delete([ [ 'id', '=', $seckill_id ], [ 'site_id', '=', $site_id ] ]);
- $goods_num = model("promotion_seckill_goods")->delete([ [ 'seckill_id', '=', $seckill_id ], [ 'site_id', '=', $site_id ] ]);
- $seckill_time_id = explode(',', $info[ 'seckill_time_id' ]);
- foreach ($seckill_time_id as $v) {
- $count = model('promotion_seckill_goods')->getCount([ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ] ], '*', 'a', '', 'goods_id');
- model('promotion_seckill_time')->update([ 'goods_num' => $count ], [ [ 'id', '=', $v ] ]);
- }
- return $this->success();
- }
-
- /**
- * 获取秒杀详情
- * @param $seckill_id
- * @return array
- */
- public function getSeckillInfo($seckill_id)
- {
- $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ]);
- if (empty($seckill_info)) {
- return $this->success([]);
- }
- $seckill_info[ 'seckill_start_time' ] = 0;
- $seckill_info[ 'seckill_end_time' ] = 0;
- $today_time = strtotime(date("Y-m-d"), time());
- $time = time() - $today_time;//当日时间戳
-
- $seckill_time_id = trim($seckill_info[ 'seckill_time_id' ], ',');
- $condition = [
- [ 'id', 'in', $seckill_time_id ],
- [ 'seckill_start_time', '<=', $time ],
- [ 'seckill_end_time', '>', $time ],
- ];
- $time_list = model('promotion_seckill_time')->getList($condition, 'seckill_start_time, seckill_end_time', 'seckill_start_time asc', '', '', '', 1);
- if (count($time_list) > 0) {
- $seckill_info[ 'seckill_start_time' ] = $time_list[ 0 ][ 'seckill_start_time' ];
- $seckill_info[ 'seckill_end_time' ] = $time_list[ 0 ][ 'seckill_end_time' ];
- }
-
- return $this->success($seckill_info);
- }
-
- /**
- * 获取秒杀列表
- * @param array $condition
- * @param int $page
- * @param int $page_size
- * @param string $order
- * @param string $field
- * @return mixed
- */
- public function getSeckillPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '', $alias = '', $join = [])
- {
- $list = model('promotion_seckill')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- return $this->success($list);
- }
-
- /**
- * 获取秒杀商品列表
- * @param $seckill_time_id
- * @param $site_id
- * @param int $page
- * @param int $page_size
- * @return array
- */
- public function getSeckillGoodsPageList($seckill_time_id, $site_id, $page = 1, $page_size = PAGE_LIST_ROWS)
- {
- $order = 'nps.sort asc';
- $alias = 'nps';
-// [ 'nps.goods_stock', '>', 0 ],
- $condition = [
- [ 'nps.seckill_time_id', 'like', '%,' . $seckill_time_id . ',%' ],
- [ 'nps.status', '=', 1 ],
- [ 'g.goods_state', '=', 1 ],
- [ 'g.is_delete', '=', 0 ],
- [ 'nps.site_id', '=', $site_id ]
- ];
-
- $field = 'nps.id,nps.site_id,nps.seckill_name,nps.status,nps.remark,nps.start_time,nps.end_time,
- nps.goods_id,nps.seckill_time_id,nps.seckill_price,nps.sale_num,nps.goods_stock,
- g.goods_name,g.goods_image,g.price';
-
- $join = [
- [ 'goods g', 'nps.goods_id = g.goods_id', 'inner' ]
- ];
- $res = model('promotion_seckill')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- foreach ($res[ 'list' ] as $k => $v) {
- $res[ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($res[ 'list' ][ $k ][ 'goods_stock' ]);
- }
- return $this->success($res);
- }
-
- /**
- * 获取秒杀商品列表
- * @param $seckill_time_id
- * @param $site_id
- * @param null $limit
- * @return array
- */
- public function getSeckillList($seckill_time_id, $site_id, $limit = null)
- {
- $order = 'nps.sort asc';
- $alias = 'nps';
-// [ 'nps.goods_stock', '>', 0 ],
- $condition = [
- [ 'nps.seckill_time_id', 'like', '%,' . $seckill_time_id . ',%' ],
- [ 'nps.status', '=', 1 ],
- [ 'g.goods_state', '=', 1 ],
- [ 'g.is_delete', '=', 0 ],
- [ 'nps.site_id', '=', $site_id ]
- ];
-
- $field = 'nps.id,nps.site_id,nps.seckill_name,nps.status,nps.remark,nps.start_time,nps.end_time,
- nps.goods_id,nps.seckill_time_id,nps.seckill_price,nps.sale_num,nps.goods_stock,
- g.goods_name,g.goods_image,g.price';
-
- $join = [
- [ 'goods g', 'nps.goods_id = g.goods_id', 'inner' ]
- ];
- $list = model('promotion_seckill')->getList($condition, $field, $order, $alias, $join, '', $limit);
- foreach ($list as $k => $v) {
- $list[ $k ][ 'goods_stock' ] = numberFormat($list[ $k ][ 'goods_stock' ]);
- }
- return $this->success($list);
- }
-
- /**
- * 启动秒杀事件
- * @param $seckill_id
- * @return array
- */
- public function cronOpenSeckill($seckill_id)
- {
- $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ], 'start_time,status, goods_id');
- if (!empty($seckill_info)) {
- if ($seckill_info[ 'start_time' ] <= time() && $seckill_info[ 'status' ] == 0) {
- model('promotion_seckill')->update([ 'status' => 1 ], [ [ 'id', '=', $seckill_id ] ]);
- model('promotion_seckill_goods')->update([ 'status' => 1 ], [ [ 'seckill_id', '=', $seckill_id ] ]);
- $goods = new Goods();
- $goods->modifyPromotionAddon($seckill_info[ 'goods_id' ], [ 'seckill' => $seckill_id ]);
- return $this->success(1);
- } else {
- return $this->error("", "秒杀已开启或者关闭");
- }
- } else {
- return $this->error("", "秒杀不存在");
- }
- }
-
- /**
- * 结束秒杀事件
- * @param $seckill_id
- * @return array
- */
- public function cronCloseSeckill($seckill_id)
- {
- $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ], 'start_time,status, goods_id');
- if (!empty($seckill_info)) {
- //针对正在进行的活动
- if ($seckill_info[ 'status' ] == 1) {
-
- model('promotion_seckill')->update([ 'status' => 2 ], [ [ 'id', '=', $seckill_id ] ]);
- model('promotion_seckill_goods')->update([ 'status' => 2 ], [ [ 'seckill_id', '=', $seckill_id ] ]);
-
- $goods = new Goods();
- $goods->modifyPromotionAddon($seckill_info[ 'goods_id' ], [ 'seckill' => $seckill_id ], true);
-
- return $this->success();
- } else {
- return $this->error("", "正在进行的秒杀才能进行关闭操作");
- }
- } else {
- return $this->error("", "活动不存在");
- }
- }
-
- /**
- * 手动结束秒杀事件
- * @param $seckill_id
- * @return array
- */
- public function closeSeckill($seckill_id)
- {
- $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ], 'start_time,status, goods_id');
- if (!empty($seckill_info)) {
- //针对正在进行的活动
- if ($seckill_info[ 'status' ] == 1) {
-
- model('promotion_seckill')->update([ 'status' => -1 ], [ [ 'id', '=', $seckill_id ] ]);
- model('promotion_seckill_goods')->update([ 'status' => -1 ], [ [ 'seckill_id', '=', $seckill_id ] ]);
-
- $goods = new Goods();
- $goods->modifyPromotionAddon($seckill_info[ 'goods_id' ], [ 'seckill' => $seckill_id ], true);
-
- return $this->success();
- } else {
- return $this->error("", "正在进行的秒杀才能进行关闭操作");
- }
- } else {
- return $this->error("", "活动不存在");
- }
- }
-
- /**
- * 获取商品列表
- * @param $seckill_id
- * @return array
- */
- public function getSeckillGoodsList($seckill_id)
- {
- $field = 'psg.*,sku.sku_name,sku.price,sku.sku_image';
- $alias = 'psg';
- $join = [
- [
- 'goods g',
- 'g.goods_id = psg.goods_id',
- 'inner'
- ],
- [
- 'goods_sku sku',
- 'sku.sku_id = psg.sku_id',
- 'inner'
- ]
- ];
- $condition = [
- [ 'psg.seckill_id', '=', $seckill_id ],
- [ 'g.is_delete', '=', 0 ], [ 'g.goods_state', '=', 1 ]
- ];
- $list = model('promotion_seckill_goods')->getList($condition, $field, '', $alias, $join);
- return $this->success($list);
- }
-
- /**
- * 获取秒杀商品信息
- * @param array $condition
- * @param string $field
- * @return array
- */
- public function getSeckillGoodsInfo($condition = [], $field = '')
- {
-
- if (empty($field)) {
- $field = 'psg.id,psg.seckill_id,ps.goods_id,psg.sku_id,psg.seckill_price,psg.max_buy,psg.stock,
- ps.status,ps.start_time,ps.end_time,(ps.sale_num + g.virtual_sale) as sale_num,ps.remark,
- sku.site_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,
- sku.click_num,sku.collect_num,sku.sku_image,sku.sku_images,
- sku.goods_content,sku.goods_state,sku.is_virtual,sku.is_free_shipping,
- sku.goods_spec_format,sku.goods_attr_format,sku.introduction,sku.unit,
- sku.video_url,g.evaluate,sku.goods_service_ids,sku.support_trade_type,g.goods_image,
- ps.goods_stock,g.goods_name,sku.qr_id,g.stock_show,g.sale_show,g.label_name,g.category_id';
- }
- $join = [
- [ 'goods_sku sku', 'psg.sku_id = sku.sku_id', 'inner' ],
- [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
- [ 'promotion_seckill ps', 'ps.id = psg.seckill_id', 'inner' ],
- ];
- $seckill_goods_info = model('promotion_seckill_goods')->getInfo($condition, $field, 'psg', $join);
- if (!empty($seckill_goods_info)) {
- if (isset($seckill_goods_info[ 'sale_num' ])) {
- $seckill_goods_info[ 'sale_num' ] = numberFormat($seckill_goods_info[ 'sale_num' ]);
- }
- if (isset($seckill_goods_info[ 'goods_stock' ])) {
- $seckill_goods_info[ 'goods_stock' ] = numberFormat($seckill_goods_info[ 'goods_stock' ]);
- }
- }
- return $this->success($seckill_goods_info);
- }
-
- /**
- * 获取秒杀商品信息
- * @param array $condition
- * @return array
- */
- public function getSeckillGoodsSkuList($condition = [])
- {
- $field = 'psg.id,psg.seckill_id,ps.goods_id,psg.sku_id,psg.seckill_price,psg.max_buy,psg.stock,
- ps.status,ps.start_time,ps.end_time,ps.sale_num,sku.sku_name,sku.sku_spec_format,sku.price,sku.sku_image,sku.sku_images,sku.goods_spec_format,g.goods_image,ps.goods_stock';
- $join = [
- [ 'goods_sku sku', 'psg.sku_id = sku.sku_id', 'inner' ],
- [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
- [ 'promotion_seckill ps', 'ps.id = psg.seckill_id', 'inner' ],
- ];
- $list = model('promotion_seckill_goods')->getList($condition, $field, 'psg.id asc', 'psg', $join);
- foreach ($list as $k => $v) {
- $list[ $k ][ 'goods_stock' ] = numberFormat($list[ $k ][ 'goods_stock' ]);
- }
- return $this->success($list);
- }
-
- /**
- * 判断规格值是否禁用
- * @param $seckill_id
- * @param $site_id
- * @param string $goods_spec_format
- * @return int|mixed
- */
- public function getGoodsSpecFormat($seckill_id, $site_id, $goods_spec_format = '')
- {
- //获取活动参与的商品sku_ids
- $sku_ids = model('promotion_seckill_goods')->getColumn([ [ 'seckill_id', '=', $seckill_id ], [ 'site_id', '=', $site_id ] ], 'sku_id');
- $goods_model = new Goods();
- $res = $goods_model->getGoodsSpecFormat($sku_ids, $goods_spec_format);
- return $res;
- }
-
- /**
- * 生成砍价二维码
- * @param $seckill_id
- * @param string $name
- * @param string $type 类型 create创建 get获取
- * @return mixed|array
- */
- public function qrcode($seckill_id, $name, $site_id, $type = 'create')
- {
- $data = [
- 'site_id' => $site_id,
- 'app_type' => "all", // all为全部
- 'type' => $type, // 类型 create创建 get获取
- 'data' => [
- "seckill_id" => $seckill_id
- ],
- 'page' => '/pages_promotion/seckill/detail',
- 'qrcode_path' => 'upload/qrcode/seckill',
- 'qrcode_name' => "seckill_qrcode_" . $seckill_id
- ];
-
- event('Qrcode', $data, true);
- $app_type_list = config('app_type');
- $path = [];
- foreach ($app_type_list as $k => $v) {
- switch ( $k ) {
- case 'h5':
- $wap_domain = getH5Domain();
- $path[ $k ][ 'status' ] = 1;
- $path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ] . '?id=' . $seckill_id;
- $path[ $k ][ 'img' ] = "upload/qrcode/seckill/seckill_qrcode_" . $seckill_id . "_" . $k . ".png";
- break;
- case 'weapp' :
- $config = new ConfigModel();
- $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
- if (!empty($res[ 'data' ])) {
- if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
- $path[ $k ][ 'status' ] = 2;
- $path[ $k ][ 'message' ] = '未配置微信小程序';
- } else {
- $path[ $k ][ 'status' ] = 1;
- $path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
- }
-
- } else {
- $path[ $k ][ 'status' ] = 2;
- $path[ $k ][ 'message' ] = '未配置微信小程序';
- }
- break;
-
- case 'wechat' :
- $config = new ConfigModel();
- $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
- if (!empty($res[ 'data' ])) {
- if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
- $path[ $k ][ 'status' ] = 2;
- $path[ $k ][ 'message' ] = '未配置微信公众号';
- } else {
- $path[ $k ][ 'status' ] = 1;
- $path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
- }
- } else {
- $path[ $k ][ 'status' ] = 2;
- $path[ $k ][ 'message' ] = '未配置微信公众号';
- }
- break;
- }
-
- }
-
- $return = [
- 'path' => $path,
- 'name' => $name,
- ];
-
- return $this->success($return);
- }
-
- public function urlQrcode($page, $qrcode_param, $promotion_type, $app_type, $site_id)
- {
- $params = [
- 'site_id' => $site_id,
- 'data' => $qrcode_param,
- 'page' => $page,
- 'promotion_type' => $promotion_type,
- 'app_type' => $app_type,
- 'h5_path' => $page . '?id=' . $qrcode_param[ 'id' ],
- 'qrcode_path' => 'upload/qrcode/seckill',
- 'qrcode_name' => 'seckill_qrcode_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $site_id,
- ];
- $solitaire = event('PromotionQrcode', $params, true);
- return $this->success($solitaire);
- }
-
+ $data[ 'seckill_end_time' ]) {
+ return $this->error('', '秒杀时间段设置错误');
+ }
+
+ //时间段检测
+ $seckill_count = model('promotion_seckill_time')->getCount([
+ [ 'seckill_start_time|seckill_end_time', 'between', [ $data[ 'seckill_start_time' ], $data[ 'seckill_end_time' ] ] ],
+ [ 'site_id', '=', $data[ 'site_id' ] ]
+ ]);
+ if ($seckill_count > 0) {
+ return $this->error('', '秒杀场次设置冲突');
+ }
+ $seckill_count = model('promotion_seckill_time')->getCount([
+ [ 'seckill_start_time', '<=', $data[ 'seckill_start_time' ] ],
+ [ 'seckill_end_time', '>=', $data[ 'seckill_end_time' ] ],
+ [ 'site_id', '=', $data[ 'site_id' ] ]
+ ]);
+ if ($seckill_count > 0) {
+ return $this->error('', '秒杀场次设置冲突');
+ }
+ //添加数据
+ $data[ 'create_time' ] = time();
+ $seckill_id = model('promotion_seckill_time')->add($data);
+ Cache::tag("promotion_seckill_time")->clear();
+ return $this->success($seckill_id);
+ }
+
+ /**
+ * 修改秒杀时段
+ * @param $data
+ * @param $site_id
+ * @return array
+ */
+ public function editSeckillTime($data, $site_id)
+ {
+ if ($data[ 'seckill_start_time' ] > $data[ 'seckill_end_time' ]) {
+ return $this->error('', '秒杀时间段设置错误');
+ }
+ //时间段检测
+ $seckill_count = model('promotion_seckill_time')->getCount([
+ [ 'seckill_start_time|seckill_end_time', 'between', [ $data[ 'seckill_start_time' ], $data[ 'seckill_end_time' ] ] ],
+ [ 'site_id', '=', $site_id ],
+ [ 'id', '<>', $data[ 'id' ] ]
+ ]);
+ if ($seckill_count > 0) {
+ return $this->error('', '秒杀场次设置冲突');
+ }
+ $seckill_count = model('promotion_seckill_time')->getCount([
+ [ 'seckill_start_time', '<=', $data[ 'seckill_start_time' ] ],
+ [ 'seckill_end_time', '>=', $data[ 'seckill_end_time' ] ],
+ [ 'site_id', '=', $site_id ],
+ [ 'id', '<>', $data[ 'id' ] ]
+ ]);
+ if ($seckill_count > 0) {
+ return $this->error('', '秒杀场次设置冲突');
+ }
+
+ //更新数据
+ $data[ 'modify_time' ] = time();
+ $res = model('promotion_seckill_time')->update($data, [ [ 'id', '=', $data[ 'id' ] ] ]);
+ Cache::tag("promotion_seckill_time")->clear();
+ return $this->success($res);
+ }
+
+ /**
+ * 删除秒杀时段
+ * @param $seckill_time_id
+ * @return array
+ */
+ public function deleteSeckillTime($seckill_time_id)
+ {
+ $res = model('promotion_seckill_time')->delete([ [ 'id', '=', $seckill_time_id ] ]);
+ if ($res) {
+
+ $goods = new Goods();
+
+ $condition = [
+ [ 'seckill_time_id', 'like', '%,' . $seckill_time_id . ',%' ]
+ ];
+ $seckill_list = model('promotion_seckill')->getList($condition, 'id,seckill_time_id,goods_id');
+
+ foreach ($seckill_list as $k => $v) {
+
+ $time_ids = explode(',', trim($v[ 'seckill_time_id' ], ','));
+ unset($time_ids[ array_search($seckill_time_id, $time_ids) ]);
+
+ if (empty($time_ids)) {
+ $goods->modifyPromotionAddon($v[ 'goods_id' ], [ 'seckill' => $v[ 'id' ] ], true);
+ model('promotion_seckill_goods')->delete([ [ 'seckill_id', '=', $v[ 'id' ] ] ]);
+ model('promotion_seckill')->delete([ [ 'id', '=', $v[ 'id' ] ] ]);
+ } else {
+
+ $time_id = ',' . implode(',', $time_ids) . ',';
+ model('promotion_seckill')->update([ 'seckill_time_id' => $time_id ], [ [ 'id', '=', $v[ 'id' ] ] ]);
+ model('promotion_seckill_goods')->update([ 'seckill_time_id' => $time_id ], [ [ 'seckill_id', '=', $v[ 'id' ] ] ]);
+ }
+
+ }
+ }
+ Cache::tag("promotion_seckill_time")->clear();
+ return $this->success($res);
+ }
+
+ /**
+ * 获取秒杀时段信息
+ * @param $condition
+ * @param string $field
+ * @return array
+ */
+ public function getSeckillTimeInfo($condition, $field = '*')
+ {
+ $data = json_encode([ $condition, $field ]);
+ $cache = Cache::get("promotion_seckill_time_getSeckillInfo_" . $data);
+ if (!empty($cache)) {
+ return $this->success($cache);
+ }
+ $res = model('promotion_seckill_time')->getInfo($condition, $field);
+ Cache::tag("promotion_seckill_time")->set("promotion_seckill_time_getSeckillInfo_" . $data, $res);
+ return $this->success($res);
+ }
+
+ /**
+ * 获取秒杀时段列表
+ * @param array $condition
+ * @param string $field
+ * @param string $order
+ * @param null $limit
+ * @return array
+ */
+ public function getSeckillTimeList($condition = [], $field = '*', $order = '', $limit = null)
+ {
+ $list = model('promotion_seckill_time')->getList($condition, $field, $order, '', '', '', $limit);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取有商品的秒杀时段列表
+ * @param $condition
+ * @param $field
+ * @param string $order
+ * @return array
+ */
+ public function getGoodsSeckillTimeList($condition, $field, $order = 'seckill_start_time asc')
+ {
+ if (empty($field)) {
+ $field = 'id, site_id, name, seckill_start_time, seckill_end_time';
+ }
+
+ $seckill_time = model('promotion_seckill_time')->getList($condition, $field, $order);
+ foreach ($seckill_time as $k => $v) {
+ $condition = [
+ [ 'seckill_time_id', 'like', '%,' . $v[ 'id' ] . ',%' ],
+ [ 'status', '=', 1 ],
+ [ 'g.goods_state', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ]
+ ];
+ $join = [
+ [ 'goods g', 'g.goods_id = psg.goods_id', 'inner' ]
+ ];
+ $goods = model('promotion_seckill_goods')->getInfo($condition, 'id', 'psg', $join);
+ if (empty($goods)) unset($seckill_time[ $k ]);
+ }
+ return $this->success($seckill_time);
+ }
+
+ /**
+ * 转换秒杀时间
+ * @param $info
+ * @return mixed
+ */
+ public function transformSeckillTime($info)
+ {
+ $info[ 'start_hour' ] = floor($info[ 'seckill_start_time' ] / 3600);
+ $info[ 'start_minute' ] = floor(( $info[ 'seckill_start_time' ] % 3600 ) / 60);
+ $info[ 'start_second' ] = $info[ 'seckill_start_time' ] % 60;
+
+ $info[ 'end_hour' ] = floor($info[ 'seckill_end_time' ] / 3600);
+ $info[ 'end_minute' ] = floor(( $info[ 'seckill_end_time' ] % 3600 ) / 60);
+ $info[ 'end_second' ] = $info[ 'seckill_end_time' ] % 60;
+
+ if ($info[ 'start_hour' ] < 10) $info[ 'start_hour' ] = '0' . $info[ 'start_hour' ];
+ if ($info[ 'start_minute' ] < 10) $info[ 'start_minute' ] = '0' . $info[ 'start_minute' ];
+ if ($info[ 'start_second' ] < 10) $info[ 'start_second' ] = '0' . $info[ 'start_second' ];
+
+ if ($info[ 'end_hour' ] < 10) $info[ 'end_hour' ] = '0' . $info[ 'end_hour' ];
+ if ($info[ 'end_minute' ] < 10) $info[ 'end_minute' ] = '0' . $info[ 'end_minute' ];
+ if ($info[ 'end_second' ] < 10) $info[ 'end_second' ] = '0' . $info[ 'end_second' ];
+
+ return $info;
+ }
+
+ /******************************************************秒杀商品*********************************************************************/
+ /**
+ * 添加秒杀商品
+ * @param $data
+ * @return array
+ */
+ public function addSeckillGoods($data)
+ {
+ $cron = new Cron();
+ $goods_data = $data[ 'goods_data' ];
+
+ if (empty($data[ 'seckill_time_id' ])) {
+ return $this->error('', '请选择秒杀时段');
+ }
+ $seckill_time_id = explode(',', $data[ 'seckill_time_id' ]);
+
+ //时间段检测
+ foreach ($seckill_time_id as $v) {
+ $seckill_count = model('promotion_seckill')->getCount([
+ [ 'goods_id', 'in', $data[ 'goods_ids' ] ],
+ [ 'status', 'in', '0,1' ],
+ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ],
+ [ 'site_id', '=', $data[ 'site_id' ] ],
+ [ '', 'exp', Db::raw('not ( (`start_time` > ' . $data[ 'end_time' ] . ' and `start_time` > ' . $data[ 'start_time' ] . ' ) or (`end_time` < ' . $data[ 'start_time' ] . ' and `end_time` < ' . $data[ 'end_time' ] . '))') ]//todo 修正 所有的优惠都要一样
+ ]);
+ if ($seckill_count > 0) {
+ return $this->error('', '有商品已设置秒杀,请不要重复设置');
+ }
+ }
+
+ model('promotion_seckill')->startTrans();
+ try {
+ $seckill_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'seckill_name' => $data[ 'seckill_name' ],
+ 'remark' => $data[ 'remark' ],
+ 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
+ 'start_time' => $data[ 'start_time' ],
+ 'end_time' => $data[ 'end_time' ],
+ 'create_time' => time(),
+ 'sort' => $data[ 'sort' ],
+ ];
+
+ $goods = new Goods();
+ $add_goods_data = [];
+ foreach ($goods_data as $k => $v) {
+ $seckill_data[ 'goods_id' ] = $v[ 'goods_id' ];
+ $seckill_data[ 'goods_name' ] = $v[ 'sku_list' ][ 0 ][ 'sku_name' ];
+ $seckill_data[ 'goods_image' ] = $v[ 'sku_list' ][ 0 ][ 'sku_image' ];
+ $seckill_data[ 'seckill_price' ] = $v[ 'sku_list' ][ 0 ][ 'seckill_price' ];
+
+ if ($data[ 'start_time' ] <= time()) {
+ $seckill_data[ 'status' ] = 1;//直接启动
+ $seckill_id = model('promotion_seckill')->add($seckill_data);
+ $goods->modifyPromotionAddon($v[ 'goods_id' ], [ 'seckill' => $seckill_id ]);
+ $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
+ } else {
+ $seckill_data[ 'status' ] = 0;
+ $seckill_id = model('promotion_seckill')->add($seckill_data);
+ $cron->addCron(1, 0, "秒杀开启", "OpenSeckill", $data[ 'start_time' ], $seckill_id);
+ $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
+ }
+
+ $goods_stock = 0; // 秒杀商品总库存
+
+ foreach ($v[ 'sku_list' ] as $key => $item) {
+ $sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'goods_id, sku_id, sku_name,price,sku_image');
+ $add_goods_data[] = [
+ 'site_id' => $data[ 'site_id' ],
+ 'seckill_id' => $seckill_id,
+ 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
+ 'sku_id' => $item[ 'sku_id' ],
+ 'goods_id' => $item[ 'goods_id' ],
+ 'sku_image' => $sku_info[ 'sku_image' ],
+ 'sku_name' => $sku_info[ 'sku_name' ],
+ 'seckill_price' => $item[ 'seckill_price' ],
+ 'price' => $sku_info[ 'price' ],
+ 'stock' => $item[ 'seckill_stock' ],
+ 'max_buy' => $item[ 'max_buy' ],
+ 'status' => $seckill_data[ 'status' ]
+ ];
+ $goods_stock += $item[ 'seckill_stock' ];
+ }
+ model('promotion_seckill')->update([ 'goods_stock' => $goods_stock ], [ [ 'id', '=', $seckill_id ] ]);
+ }
+ model('promotion_seckill_goods')->addList($add_goods_data);
+ foreach ($seckill_time_id as $v) {
+ $count = model('promotion_seckill_goods')->getCount([ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ] ], '*', 'a', '', 'goods_id');
+ model('promotion_seckill_time')->update([ 'goods_num' => $count ], [ [ 'id', '=', $v ] ]);
+ }
+ model('promotion_seckill')->commit();
+ return $this->success();
+ } catch (\Exception $e) {
+ model('promotion_seckill')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
+ /**
+ * 修改秒杀商品
+ * @param $data
+ * @return array
+ */
+ public function editSeckillGoods($data)
+ {
+ $cron = new Cron();
+
+ if (empty($data[ 'seckill_time_id' ])) {
+ return $this->error('', '请选择秒杀时段');
+ }
+ $seckill_time_id = explode(',', $data[ 'seckill_time_id' ]);
+
+ //时间段检测
+ foreach ($seckill_time_id as $v) {
+ $seckill_count = model('promotion_seckill')->getInfo([
+ [ 'goods_id', 'in', $data[ 'goods_ids' ] ],
+ [ 'status', 'in', '0,1' ],
+ [ 'site_id', '=', $data[ 'site_id' ] ],
+ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ],
+ [ 'id', '<>', $data[ 'id' ] ],
+ [ '', 'exp', Db::raw('not ( (`start_time` > ' . $data[ 'end_time' ] . ' and `start_time` > ' . $data[ 'start_time' ] . ' ) or (`end_time` < ' . $data[ 'start_time' ] . ' and `end_time` < ' . $data[ 'end_time' ] . '))') ]//todo 修正 所有的优惠都要一样
+ ]);
+ if ($seckill_count > 0) {
+ return $this->error('', '有商品已设置秒杀,请不要重复设置');
+ }
+ }
+
+ model('promotion_seckill')->startTrans();
+ try {
+ $seckill_data = [
+ 'site_id' => $data[ 'site_id' ],
+ 'seckill_name' => $data[ 'seckill_name' ],
+ 'remark' => $data[ 'remark' ],
+ 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
+ 'start_time' => $data[ 'start_time' ],
+ 'end_time' => $data[ 'end_time' ],
+ 'modify_time' => time(),
+ 'sort' => $data[ 'sort' ],
+ ];
+
+ $goods = new Goods();
+ $add_goods_data = [];
+ $seckill_data[ 'goods_id' ] = $data[ 'sku_list' ][ 0 ][ 'goods_id' ];
+ $seckill_data[ 'goods_name' ] = $data[ 'sku_list' ][ 0 ][ 'sku_name' ];
+ $seckill_data[ 'goods_image' ] = $data[ 'sku_list' ][ 0 ][ 'sku_image' ];
+ $seckill_data[ 'seckill_price' ] = $data[ 'sku_list' ][ 0 ][ 'seckill_price' ];
+
+ $seckill_id = $data[ 'id' ];
+
+ if ($data[ 'start_time' ] <= time()) {
+ $seckill_data[ 'status' ] = 1;//直接启动
+ model('promotion_seckill')->update($seckill_data, [ [ 'id', '=', $seckill_id ] ]);
+ $goods->modifyPromotionAddon($data[ 'sku_list' ][ 0 ][ 'goods_id' ], [ 'seckill' => $seckill_id ]);
+ $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
+ } else {
+ $seckill_data[ 'status' ] = 0;
+ model('promotion_seckill')->update($seckill_data, [ [ 'id', '=', $seckill_id ] ]);
+ $cron->addCron(1, 0, "秒杀开启", "OpenSeckill", $data[ 'start_time' ], $seckill_id);
+ $cron->addCron(1, 0, "秒杀关闭", "CloseSeckill", $data[ 'end_time' ], $seckill_id);
+ }
+
+ model('promotion_seckill_goods')->delete([ [ 'seckill_id', '=', $seckill_id ] ]);
+
+ $goods_stock = 0; // 秒杀商品总库存
+
+ foreach ($data[ 'sku_list' ] as $key => $item) {
+ $sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $item[ 'sku_id' ] ] ], 'goods_id, sku_id, sku_name,price,sku_image');
+ $add_goods_data[] = [
+ 'site_id' => $data[ 'site_id' ],
+ 'seckill_id' => $seckill_id,
+ 'seckill_time_id' => ',' . $data[ 'seckill_time_id' ] . ',',
+ 'sku_id' => $item[ 'sku_id' ],
+ 'goods_id' => $item[ 'goods_id' ],
+ 'sku_image' => $sku_info[ 'sku_image' ],
+ 'sku_name' => $sku_info[ 'sku_name' ],
+ 'seckill_price' => $item[ 'seckill_price' ],
+ 'price' => $sku_info[ 'price' ],
+ 'stock' => $item[ 'seckill_stock' ],
+ 'max_buy' => $item[ 'max_buy' ],
+ 'status' => $seckill_data[ 'status' ]
+ ];
+ $goods_stock += $item[ 'seckill_stock' ];
+ }
+ model('promotion_seckill')->update([ 'goods_stock' => $goods_stock ], [ [ 'id', '=', $seckill_id ] ]);
+ model('promotion_seckill_goods')->addList($add_goods_data);
+
+ foreach ($seckill_time_id as $v) {
+ $count = model('promotion_seckill_goods')->getCount([ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ] ], '*', 'a', '', 'goods_id');
+ model('promotion_seckill_time')->update([ 'goods_num' => $count ], [ [ 'id', '=', $v ] ]);
+ }
+ model('promotion_seckill')->commit();
+ return $this->success();
+ } catch (\Exception $e) {
+ model('promotion_seckill')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+ }
+
+ public function seckillSort($id, $sort)
+ {
+ $res = model('promotion_seckill')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
+ return $this->success($res);
+ }
+
+ /**
+ * 秒杀商品详情
+ * @param array $condition
+ * @param string $field
+ * @param string $alias
+ * @param array $join
+ * @return array
+ */
+ public function getSeckillDetail($condition = [], $field = '*', $alias = '', $join = [])
+ {
+ $info = model("promotion_seckill")->getInfo($condition, $field, $alias, $join);
+
+ $goods_sku = model('goods_sku')->getList([ [ 'goods_id', '=', $info[ 'goods_id' ] ], [ 'is_delete', '=', 0 ], [ 'goods_state', '=', 1 ] ], 'stock as goods_stock, goods_id, sku_id, sku_name,price,sku_image,stock');
+
+ $discount_goods = model("promotion_seckill_goods")->getList([ [ 'goods_id', '=', $info[ 'goods_id' ] ], [ 'seckill_id', '=', $info[ 'id' ] ] ], '*');
+
+ foreach ($goods_sku as $k => $v) {
+ $goods_sku[ $k ][ 'is_select' ] = 0;
+ $goods_sku[ $k ][ 'seckill_price' ] = $v[ 'price' ];
+ $goods_sku[ $k ][ 'seckill_stock' ] = 0;
+ $goods_sku[ $k ][ 'max_buy' ] = 0;
+ $goods_sku[ $k ][ 'stock' ] = numberFormat($goods_sku[ $k ][ 'stock' ]);
+ $goods_sku[ $k ][ 'goods_stock' ] = numberFormat($goods_sku[ $k ][ 'goods_stock' ]);
+ foreach ($discount_goods as $key => $val) {
+ if ($val[ 'sku_id' ] == $v[ 'sku_id' ]) {
+ $goods_sku[ $k ][ 'is_select' ] = 1;
+ $goods_sku[ $k ][ 'seckill_price' ] = $val[ 'seckill_price' ];
+ $goods_sku[ $k ][ 'seckill_stock' ] = $val[ 'stock' ];
+ $goods_sku[ $k ][ 'max_buy' ] = $val[ 'max_buy' ];
+ }
+ }
+ }
+
+ $info[ 'goods_sku' ] = $goods_sku;
+ $info[ 'seckill_goods' ] = $discount_goods;
+
+ return $this->success($info);
+ }
+
+ /**
+ * 修改秒杀商品限购数量
+ * @param $seckill_id
+ * @param $site_id
+ * @param $sku_id
+ * @param $max_buy
+ * @return array
+ */
+ public function editSeckillGoodsNum($seckill_id, $site_id, $sku_id, $max_buy)
+ {
+ $data = [
+ 'seckill_id' => $seckill_id,
+ 'site_id' => $site_id,
+ 'sku_id' => $sku_id,
+ 'max_buy' => $max_buy
+ ];
+ model("promotion_seckill_goods")->update($data, [ [ 'seckill_id', '=', $seckill_id ], [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $site_id ] ]);
+ return $this->success();
+ }
+
+ /**
+ * 删除秒杀商品
+ * @param $seckill_id
+ * @param $site_id
+ * @return array
+ */
+ public function deleteSeckillGoods($seckill_id, $site_id)
+ {
+ $info = model("promotion_seckill")->getInfo([ [ 'id', '=', $seckill_id ] ], 'goods_id,seckill_time_id,status');
+
+ if(empty($info)) return $this->error('', '该秒杀活动不存在');
+ if($info['status'] == 1) return $this->error('', '该秒杀活动正在进行');
+
+ $goods = new Goods();
+ $goods->modifyPromotionAddon($info[ 'goods_id' ], [ 'seckill' => $seckill_id ], true);
+ model("promotion_seckill")->delete([ [ 'id', '=', $seckill_id ], [ 'site_id', '=', $site_id ] ]);
+ $goods_num = model("promotion_seckill_goods")->delete([ [ 'seckill_id', '=', $seckill_id ], [ 'site_id', '=', $site_id ] ]);
+ $seckill_time_id = explode(',', $info[ 'seckill_time_id' ]);
+ foreach ($seckill_time_id as $v) {
+ $count = model('promotion_seckill_goods')->getCount([ [ 'seckill_time_id', 'like', '%,' . $v . ',%' ] ], '*', 'a', '', 'goods_id');
+ model('promotion_seckill_time')->update([ 'goods_num' => $count ], [ [ 'id', '=', $v ] ]);
+ }
+ return $this->success();
+ }
+
+ /**
+ * 获取秒杀详情
+ * @param $seckill_id
+ * @return array
+ */
+ public function getSeckillInfo($seckill_id)
+ {
+ $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ]);
+ if (empty($seckill_info)) {
+ return $this->success([]);
+ }
+ $seckill_info[ 'seckill_start_time' ] = 0;
+ $seckill_info[ 'seckill_end_time' ] = 0;
+ $today_time = strtotime(date("Y-m-d"), time());
+ $time = time() - $today_time;//当日时间戳
+
+ $seckill_time_id = trim($seckill_info[ 'seckill_time_id' ], ',');
+ $condition = [
+ [ 'id', 'in', $seckill_time_id ],
+ [ 'seckill_start_time', '<=', $time ],
+ [ 'seckill_end_time', '>', $time ],
+ ];
+ $time_list = model('promotion_seckill_time')->getList($condition, 'seckill_start_time, seckill_end_time', 'seckill_start_time asc', '', '', '', 1);
+ if (count($time_list) > 0) {
+ $seckill_info[ 'seckill_start_time' ] = $time_list[ 0 ][ 'seckill_start_time' ];
+ $seckill_info[ 'seckill_end_time' ] = $time_list[ 0 ][ 'seckill_end_time' ];
+ }
+
+ return $this->success($seckill_info);
+ }
+
+ /**
+ * 获取秒杀列表
+ * @param array $condition
+ * @param int $page
+ * @param int $page_size
+ * @param string $order
+ * @param string $field
+ * @return mixed
+ */
+ public function getSeckillPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '', $alias = '', $join = [])
+ {
+ $list = model('promotion_seckill')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取秒杀商品列表
+ * @param $seckill_time_id
+ * @param $site_id
+ * @param int $page
+ * @param int $page_size
+ * @return array
+ */
+ public function getSeckillGoodsPageList($seckill_time_id, $site_id, $page = 1, $page_size = PAGE_LIST_ROWS)
+ {
+ $order = 'nps.sort asc';
+ $alias = 'nps';
+// [ 'nps.goods_stock', '>', 0 ],
+ $condition = [
+ [ 'nps.seckill_time_id', 'like', '%,' . $seckill_time_id . ',%' ],
+ [ 'nps.status', '=', 1 ],
+ [ 'g.goods_state', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ],
+ [ 'nps.site_id', '=', $site_id ]
+ ];
+
+ $field = 'nps.id,nps.site_id,nps.seckill_name,nps.status,nps.remark,nps.start_time,nps.end_time,
+ nps.goods_id,nps.seckill_time_id,nps.seckill_price,nps.sale_num,nps.goods_stock,
+ g.goods_name,g.goods_image,g.price';
+
+ $join = [
+ [ 'goods g', 'nps.goods_id = g.goods_id', 'inner' ]
+ ];
+ $res = model('promotion_seckill')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
+ foreach ($res[ 'list' ] as $k => $v) {
+ $res[ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($res[ 'list' ][ $k ][ 'goods_stock' ]);
+ }
+ return $this->success($res);
+ }
+
+ /**
+ * 获取秒杀商品列表
+ * @param $seckill_time_id
+ * @param $site_id
+ * @param null $limit
+ * @return array
+ */
+ public function getSeckillList($seckill_time_id, $site_id, $limit = null)
+ {
+ $order = 'nps.sort asc';
+ $alias = 'nps';
+// [ 'nps.goods_stock', '>', 0 ],
+ $condition = [
+ [ 'nps.seckill_time_id', 'like', '%,' . $seckill_time_id . ',%' ],
+ [ 'nps.status', '=', 1 ],
+ [ 'g.goods_state', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ],
+ [ 'nps.site_id', '=', $site_id ]
+ ];
+
+ $field = 'nps.id,nps.site_id,nps.seckill_name,nps.status,nps.remark,nps.start_time,nps.end_time,
+ nps.goods_id,nps.seckill_time_id,nps.seckill_price,nps.sale_num,nps.goods_stock,
+ g.goods_name,g.goods_image,g.price';
+
+ $join = [
+ [ 'goods g', 'nps.goods_id = g.goods_id', 'inner' ]
+ ];
+ $list = model('promotion_seckill')->getList($condition, $field, $order, $alias, $join, '', $limit);
+ foreach ($list as $k => $v) {
+ $list[ $k ][ 'goods_stock' ] = numberFormat($list[ $k ][ 'goods_stock' ]);
+ }
+ return $this->success($list);
+ }
+
+ /**
+ * 启动秒杀事件
+ * @param $seckill_id
+ * @return array
+ */
+ public function cronOpenSeckill($seckill_id)
+ {
+ $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ], 'start_time,status, goods_id');
+ if (!empty($seckill_info)) {
+ if ($seckill_info[ 'start_time' ] <= time() && $seckill_info[ 'status' ] == 0) {
+ model('promotion_seckill')->update([ 'status' => 1 ], [ [ 'id', '=', $seckill_id ] ]);
+ model('promotion_seckill_goods')->update([ 'status' => 1 ], [ [ 'seckill_id', '=', $seckill_id ] ]);
+ $goods = new Goods();
+ $goods->modifyPromotionAddon($seckill_info[ 'goods_id' ], [ 'seckill' => $seckill_id ]);
+ return $this->success(1);
+ } else {
+ return $this->error("", "秒杀已开启或者关闭");
+ }
+ } else {
+ return $this->error("", "秒杀不存在");
+ }
+ }
+
+ /**
+ * 结束秒杀事件
+ * @param $seckill_id
+ * @return array
+ */
+ public function cronCloseSeckill($seckill_id)
+ {
+ $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ], 'start_time,status, goods_id');
+ if (!empty($seckill_info)) {
+ //针对正在进行的活动
+ if ($seckill_info[ 'status' ] == 1) {
+
+ model('promotion_seckill')->update([ 'status' => 2 ], [ [ 'id', '=', $seckill_id ] ]);
+ model('promotion_seckill_goods')->update([ 'status' => 2 ], [ [ 'seckill_id', '=', $seckill_id ] ]);
+
+ $goods = new Goods();
+ $goods->modifyPromotionAddon($seckill_info[ 'goods_id' ], [ 'seckill' => $seckill_id ], true);
+
+ return $this->success();
+ } else {
+ return $this->error("", "正在进行的秒杀才能进行关闭操作");
+ }
+ } else {
+ return $this->error("", "活动不存在");
+ }
+ }
+
+ /**
+ * 手动结束秒杀事件
+ * @param $seckill_id
+ * @return array
+ */
+ public function closeSeckill($seckill_id)
+ {
+ $seckill_info = model('promotion_seckill')->getInfo([ [ 'id', '=', $seckill_id ] ], 'start_time,status, goods_id');
+ if (!empty($seckill_info)) {
+ //针对正在进行的活动
+ if ($seckill_info[ 'status' ] == 1) {
+
+ model('promotion_seckill')->update([ 'status' => -1 ], [ [ 'id', '=', $seckill_id ] ]);
+ model('promotion_seckill_goods')->update([ 'status' => -1 ], [ [ 'seckill_id', '=', $seckill_id ] ]);
+
+ $goods = new Goods();
+ $goods->modifyPromotionAddon($seckill_info[ 'goods_id' ], [ 'seckill' => $seckill_id ], true);
+
+ return $this->success();
+ } else {
+ return $this->error("", "正在进行的秒杀才能进行关闭操作");
+ }
+ } else {
+ return $this->error("", "活动不存在");
+ }
+ }
+
+ /**
+ * 获取商品列表
+ * @param $seckill_id
+ * @return array
+ */
+ public function getSeckillGoodsList($seckill_id)
+ {
+ $field = 'psg.*,sku.sku_name,sku.price,sku.sku_image';
+ $alias = 'psg';
+ $join = [
+ [
+ 'goods g',
+ 'g.goods_id = psg.goods_id',
+ 'inner'
+ ],
+ [
+ 'goods_sku sku',
+ 'sku.sku_id = psg.sku_id',
+ 'inner'
+ ]
+ ];
+ $condition = [
+ [ 'psg.seckill_id', '=', $seckill_id ],
+ [ 'g.is_delete', '=', 0 ], [ 'g.goods_state', '=', 1 ]
+ ];
+ $list = model('promotion_seckill_goods')->getList($condition, $field, '', $alias, $join);
+ return $this->success($list);
+ }
+
+ /**
+ * 获取秒杀商品信息
+ * @param array $condition
+ * @param string $field
+ * @return array
+ */
+ public function getSeckillGoodsInfo($condition = [], $field = '')
+ {
+
+ if (empty($field)) {
+ $field = 'psg.id,psg.seckill_id,ps.goods_id,psg.sku_id,psg.seckill_price,psg.max_buy,psg.stock,
+ ps.status,ps.start_time,ps.end_time,(ps.sale_num + g.virtual_sale) as sale_num,ps.remark,
+ sku.site_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,
+ sku.click_num,sku.collect_num,sku.sku_image,sku.sku_images,
+ sku.goods_content,sku.goods_state,sku.is_virtual,sku.is_free_shipping,
+ sku.goods_spec_format,sku.goods_attr_format,sku.introduction,sku.unit,
+ sku.video_url,g.evaluate,sku.goods_service_ids,sku.support_trade_type,g.goods_image,
+ ps.goods_stock,g.goods_name,sku.qr_id,g.stock_show,g.sale_show,g.label_name,g.category_id';
+ }
+ $join = [
+ [ 'goods_sku sku', 'psg.sku_id = sku.sku_id', 'inner' ],
+ [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
+ [ 'promotion_seckill ps', 'ps.id = psg.seckill_id', 'inner' ],
+ ];
+ $seckill_goods_info = model('promotion_seckill_goods')->getInfo($condition, $field, 'psg', $join);
+ if (!empty($seckill_goods_info)) {
+ if (isset($seckill_goods_info[ 'sale_num' ])) {
+ $seckill_goods_info[ 'sale_num' ] = numberFormat($seckill_goods_info[ 'sale_num' ]);
+ }
+ if (isset($seckill_goods_info[ 'goods_stock' ])) {
+ $seckill_goods_info[ 'goods_stock' ] = numberFormat($seckill_goods_info[ 'goods_stock' ]);
+ }
+ }
+ return $this->success($seckill_goods_info);
+ }
+
+ /**
+ * 获取秒杀商品信息
+ * @param array $condition
+ * @return array
+ */
+ public function getSeckillGoodsSkuList($condition = [])
+ {
+ $field = 'psg.id,psg.seckill_id,ps.goods_id,psg.sku_id,psg.seckill_price,psg.max_buy,psg.stock,
+ ps.status,ps.start_time,ps.end_time,ps.sale_num,sku.sku_name,sku.sku_spec_format,sku.price,sku.sku_image,sku.sku_images,sku.goods_spec_format,g.goods_image,ps.goods_stock';
+ $join = [
+ [ 'goods_sku sku', 'psg.sku_id = sku.sku_id', 'inner' ],
+ [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ],
+ [ 'promotion_seckill ps', 'ps.id = psg.seckill_id', 'inner' ],
+ ];
+ $list = model('promotion_seckill_goods')->getList($condition, $field, 'psg.id asc', 'psg', $join);
+ foreach ($list as $k => $v) {
+ $list[ $k ][ 'goods_stock' ] = numberFormat($list[ $k ][ 'goods_stock' ]);
+ }
+ return $this->success($list);
+ }
+
+ /**
+ * 判断规格值是否禁用
+ * @param $seckill_id
+ * @param $site_id
+ * @param string $goods_spec_format
+ * @return int|mixed
+ */
+ public function getGoodsSpecFormat($seckill_id, $site_id, $goods_spec_format = '')
+ {
+ //获取活动参与的商品sku_ids
+ $sku_ids = model('promotion_seckill_goods')->getColumn([ [ 'seckill_id', '=', $seckill_id ], [ 'site_id', '=', $site_id ] ], 'sku_id');
+ $goods_model = new Goods();
+ $res = $goods_model->getGoodsSpecFormat($sku_ids, $goods_spec_format);
+ return $res;
+ }
+
+ /**
+ * 生成砍价二维码
+ * @param $seckill_id
+ * @param string $name
+ * @param string $type 类型 create创建 get获取
+ * @return mixed|array
+ */
+ public function qrcode($seckill_id, $name, $site_id, $type = 'create')
+ {
+ $data = [
+ 'site_id' => $site_id,
+ 'app_type' => "all", // all为全部
+ 'type' => $type, // 类型 create创建 get获取
+ 'data' => [
+ "seckill_id" => $seckill_id
+ ],
+ 'page' => '/pages_promotion/seckill/detail',
+ 'qrcode_path' => 'upload/qrcode/seckill',
+ 'qrcode_name' => "seckill_qrcode_" . $seckill_id
+ ];
+
+ event('Qrcode', $data, true);
+ $app_type_list = config('app_type');
+ $path = [];
+ foreach ($app_type_list as $k => $v) {
+ switch ( $k ) {
+ case 'h5':
+ $wap_domain = getH5Domain();
+ $path[ $k ][ 'status' ] = 1;
+ $path[ $k ][ 'url' ] = $wap_domain . $data[ 'page' ] . '?id=' . $seckill_id;
+ $path[ $k ][ 'img' ] = "upload/qrcode/seckill/seckill_qrcode_" . $seckill_id . "_" . $k . ".png";
+ break;
+ case 'weapp' :
+ $config = new ConfigModel();
+ $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WEAPP_CONFIG' ] ]);
+ if (!empty($res[ 'data' ])) {
+ if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
+ $path[ $k ][ 'status' ] = 2;
+ $path[ $k ][ 'message' ] = '未配置微信小程序';
+ } else {
+ $path[ $k ][ 'status' ] = 1;
+ $path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
+ }
+
+ } else {
+ $path[ $k ][ 'status' ] = 2;
+ $path[ $k ][ 'message' ] = '未配置微信小程序';
+ }
+ break;
+
+ case 'wechat' :
+ $config = new ConfigModel();
+ $res = $config->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'WECHAT_CONFIG' ] ]);
+ if (!empty($res[ 'data' ])) {
+ if (empty($res[ 'data' ][ 'value' ][ 'qrcode' ])) {
+ $path[ $k ][ 'status' ] = 2;
+ $path[ $k ][ 'message' ] = '未配置微信公众号';
+ } else {
+ $path[ $k ][ 'status' ] = 1;
+ $path[ $k ][ 'img' ] = $res[ 'data' ][ 'value' ][ 'qrcode' ];
+ }
+ } else {
+ $path[ $k ][ 'status' ] = 2;
+ $path[ $k ][ 'message' ] = '未配置微信公众号';
+ }
+ break;
+ }
+
+ }
+
+ $return = [
+ 'path' => $path,
+ 'name' => $name,
+ ];
+
+ return $this->success($return);
+ }
+
+ public function urlQrcode($page, $qrcode_param, $promotion_type, $app_type, $site_id)
+ {
+ $params = [
+ 'site_id' => $site_id,
+ 'data' => $qrcode_param,
+ 'page' => $page,
+ 'promotion_type' => $promotion_type,
+ 'app_type' => $app_type,
+ 'h5_path' => $page . '?id=' . $qrcode_param[ 'id' ],
+ 'qrcode_path' => 'upload/qrcode/seckill',
+ 'qrcode_name' => 'seckill_qrcode_' . $promotion_type . '_' . $qrcode_param[ 'id' ] . '_' . $site_id,
+ ];
+ $solitaire = event('PromotionQrcode', $params, true);
+ return $this->success($solitaire);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/seckill/model/SeckillOrder.php b/src/addon/seckill/model/SeckillOrder.php
index 53f14acaf..56d0ba6cf 100644
--- a/src/addon/seckill/model/SeckillOrder.php
+++ b/src/addon/seckill/model/SeckillOrder.php
@@ -1,75 +1,67 @@
-getInfo([['order_id', '=', $order_id], ['promotion_type', '=', 'seckill'], ['order_status', '=', -1]], 'promotion_id');
- if (!empty($order_info)) {
- $condition = array(
- ["order_id", "=", $order_id]
- );
- $order_goods_list = model('order_goods')->getList($condition, "order_goods_id,sku_id,num,refund_status,use_point");
- foreach ($order_goods_list as $k => $v) {
- // 返还库存
- model("promotion_seckill")->setInc([['id', '=', $order_info["promotion_id"]]], "goods_stock", $v["num"]);
- model("promotion_seckill_goods")->setInc([["sku_id", '=', $v["sku_id"]], ["seckill_id", '=', $order_info["promotion_id"]]], "stock", $v["num"]);
- // 减少销量
- model("promotion_seckill")->setDec([['id', '=', $order_info["promotion_id"]]], "sale_num", $v["num"]);
- }
- }
- return $this->success();
- }
-
-
- /**
- * 获取商品已秒杀数
- * @param $goods_id
- * @param $member_id
- * @return float
- */
- public function getGoodsSeckillNum($seckill_id)
- {
- $join = [
- ['order o', 'o.order_id = og.order_id', 'left']
- ];
- $num = model('order_goods')->getSum([
- ['o.order_status', '<>', Order::ORDER_CLOSE],
- ['o.promotion_type', '=', 'seckill'],
- ['o.promotion_id', '=', $seckill_id],
- ['og.refund_status', '<>', OrderRefundDict::REFUND_COMPLETE],
- ], 'og.num', 'og', $join);
- return $num;
- }
+getInfo([['order_id', '=', $order_id], ['promotion_type', '=', 'seckill'], ['order_status', '=', -1]], 'promotion_id');
+ if (!empty($order_info)) {
+ $condition = array(
+ ["order_id", "=", $order_id]
+ );
+ $order_goods_list = model('order_goods')->getList($condition, "order_goods_id,sku_id,num,refund_status,use_point");
+ foreach ($order_goods_list as $k => $v) {
+ // 返还库存
+ model("promotion_seckill")->setInc([['id', '=', $order_info["promotion_id"]]], "goods_stock", $v["num"]);
+ model("promotion_seckill_goods")->setInc([["sku_id", '=', $v["sku_id"]], ["seckill_id", '=', $order_info["promotion_id"]]], "stock", $v["num"]);
+ // 减少销量
+ model("promotion_seckill")->setDec([['id', '=', $order_info["promotion_id"]]], "sale_num", $v["num"]);
+ }
+ }
+ return $this->success();
+ }
+
+
+ /**
+ * 获取商品已秒杀数
+ * @param $goods_id
+ * @param $member_id
+ * @return float
+ */
+ public function getGoodsSeckillNum($seckill_id)
+ {
+ $join = [
+ ['order o', 'o.order_id = og.order_id', 'left']
+ ];
+ $num = model('order_goods')->getSum([
+ ['o.order_status', '<>', Order::ORDER_CLOSE],
+ ['o.promotion_type', '=', 'seckill'],
+ ['o.promotion_id', '=', $seckill_id],
+ ['og.refund_status', '<>', OrderRefundDict::REFUND_COMPLETE],
+ ], 'og.num', 'og', $join);
+ return $num;
+ }
}
\ No newline at end of file
diff --git a/src/addon/seckill/model/SeckillOrderCreate.php b/src/addon/seckill/model/SeckillOrderCreate.php
index 9363e49e2..00c7f063b 100644
--- a/src/addon/seckill/model/SeckillOrderCreate.php
+++ b/src/addon/seckill/model/SeckillOrderCreate.php
@@ -1,310 +1,302 @@
-promotion_type = 'seckill';
- $this->promotion_type_name = '秒杀';
- }
- /**
- * 订单创建
- */
- public function create()
- {
- //计算
- $this->confirm();
- if ($this->error > 0) {
- return $this->error(['error_code' => $this->error], $this->error_msg);
- }
- //订单创建数据
- $order_insert_data = $this->getOrderInsertData(['discount'], 'invert');
- $order_insert_data['store_id'] = $this->store_id;
- $order_insert_data['create_time'] = time();
- $order_insert_data['is_enable_refund'] = 0;
- //订单类型以及状态
- $this->orderType();
- $order_insert_data['order_type'] = $this->order_type['order_type_id'];
- $order_insert_data['order_type_name'] = $this->order_type['order_type_name'];
- $order_insert_data['order_status_name'] = $this->order_type['order_status']['name'];
- $order_insert_data['order_status_action'] = json_encode($this->order_type['order_status'], JSON_UNESCAPED_UNICODE);
-
- model('order')->startTrans();
- //循环生成多个订单
- try {
- $this->order_id = model('order')->add($order_insert_data);
- $order_goods_insert_data = [];
- //订单项目表
- foreach ($this->goods_list as &$order_goods_v) {
- $order_goods_insert_data[] = $this->getOrderGoodsInsertData($order_goods_v);
-
- model("promotion_seckill_goods")->setDec([['sku_id', '=', $order_goods_v['sku_id']], ['seckill_id', '=', $this->seckill_info["id"]]], "stock", $order_goods_v['num']);
- model("promotion_seckill")->setDec([['id', '=', $this->seckill_info["id"]]], "goods_stock", $order_goods_v['num']);
- // 增加销量
- model("promotion_seckill")->setInc([['id', '=', $this->seckill_info["id"]]], "sale_num", $order_goods_v['num']);
- }
- model('order_goods')->addList($order_goods_insert_data);
-
- //扣除余额(统一扣除)
- $this->useBalance();
- //批量库存处理(卡密商品支付后在扣出库存)
- $this->batchDecOrderGoodssStock();
- model('order')->commit();
- //订单创建后事件
- $this->orderCreateAfter();
- //支付单据
- $pay = new Pay();
- $pay->addPay($this->site_id, $this->out_trade_no, $this->pay_type, $this->order_name, $this->order_name, $this->pay_money, '', 'OrderPayNotify', '');
- return $this->success($this->out_trade_no);
- } catch ( \Exception $e ) {
- model('order')->rollback();
- return $this->error('', $e->getMessage());
- }
-
- }
-
-
- /**
- * 计算后的进一步计算(不存缓存,每次都是重新计算)
- * @return array
- */
- public function confirm()
- {
- $order_key = $this->param['order_key'];
- $this->getOrderCache($order_key);
- //初始化地址
- $this->initMemberAddress();
- //初始化门店信息
- $this->initStore();
- //配送计算
- $this->calculateDelivery();
- //批量校验配送方式
- $this->batchCheckDeliveryType();
- //计算发票相关
- $this->calculateInvoice();
- //计算余额
- $this->calculateBalcnce();
- $this->pay_money = $this->order_money - $this->balance_money;
- //设置过的商品项信息
- return get_object_vars($this);
- }
-
- /**
- * 订单计算
- */
- public function calculate()
- {
- //初始化会员地址
- $this->initMemberAddress();
- $this->initMemberAccount();//初始化会员账户
- //商品列表信息
- $this->getOrderGoodsCalculate();
- //查询秒杀信息
- $seckill_model = new Seckill();
- $seckill_info = $seckill_model->getSeckillInfo($this->seckill_id)['data'] ?? [];
- if (empty($seckill_info)) throw new OrderException("找不到可用的秒杀活动");
- $this->seckill_info = $seckill_info;
- //判断秒杀时间段是否符合
- $today_time = strtotime(date("Y-m-d"), time());
- $time = time() - $today_time;//当日时间戳
- if ($time < $this->seckill_info["seckill_start_time"] || $time > $this->seckill_info["seckill_end_time"]) {
- $this->error = 1;
- $this->error_msg = "当前商品秒杀活动未开启或已过期!";
- }
-
- //秒杀库存
- if ($this->goods_list[0]) {
- $seckill_goods = $seckill_model->getSeckillGoodsInfo([['psg.seckill_id', '=', $this->seckill_id], ['psg.sku_id', '=', $this->goods_list[0]['sku_id']]], 'psg.stock')['data'] ?? [];
- $seckill_goods_stock = $seckill_goods['stock'];
- if ($this->goods_list[0]['num'] > $seckill_goods_stock) {
- $this->error = 1;
- $this->error_msg = "该商品库存不足";
- }
- }
-
- // 秒杀商品限购 按每日某时段限购
- if ($this->goods_list[0]['limit_num'] > 0) {
- $purchased_num = $this->getGoodsPurchasedNum($this->goods_list[0]['sku_id'], $this->member_id, $this->seckill_info['id']);
- if (($purchased_num + $this->goods_list[0]['num']) > $this->goods_list[0]['limit_num']) {
- $this->error = 1;
- $this->error_msg = "该商品每人限购{$this->goods_list[ 0 ]['limit_num']}件,您已购买{$purchased_num}件";
- }
- }
- $this->shopOrderCalculate();
- //获取发票相关
- $this->getInovice();
- $this->order_key = create_no();
- $this->setOrderCache(get_object_vars($this), $this->order_key);
- return true;
- }
-
- /**
- * 待付款订单
- * @param unknown $data
- */
- public function orderPayment()
- {
- //计算
- $this->calculate();
- //查询配送信息
- $this->getDeliveryData();
- //订单初始项
- event('OrderPayment', ['order_object' => $this]);
- return get_object_vars($this);
- }
-
- /**
- * 获取商品的计算信息
- * @param unknown $data
- */
- public function getOrderGoodsCalculate()
- {
- $this->getSeckillGoodsInfo();
- return true;
- }
-
- /**
- * 获取秒杀商品列表信息
- * @param $id
- * @param $num
- * @param $data
- * @return array
- */
- public function getSeckillGoodsInfo()
- {
- $id = $this->param['id'];
- $sku_id = $this->param['sku_id'];
- $num = $this->param['num'];
- //组装商品列表
- $field = 'npsg.sku_id,npsg.seckill_id,npsg.seckill_price,npsg.max_buy as limit_num,ngs.sku_name, ngs.sku_no,
- ngs.price, ngs.discount_price, ngs.cost_price, ngs.stock, ngs.weight, ngs.volume, ngs.sku_image,
- ngs.site_id, ns.site_name, ngs.goods_state, ngs.is_virtual,ngs.supplier_id,
- ngs.is_free_shipping, ngs.shipping_template, ngs.goods_class, ngs.goods_class_name,ngs.goods_id,ngs.sku_spec_format,ngs.goods_name,ngs.support_trade_type';
- $alias = 'npsg';
- $join = [
- [
- 'goods_sku ngs',
- 'npsg.sku_id = ngs.sku_id',
- 'inner'
- ],
- [
- 'site ns',
- 'ngs.site_id = ns.site_id',
- 'inner'
- ]
- ];
-
- $condition = [
- ['npsg.sku_id', '=', $sku_id],
- ['npsg.seckill_id', '=', $id],
- ['npsg.site_id', '=', $this->site_id]
- ];
- $info = model("promotion_seckill_goods")->getInfo($condition, $field, $alias, $join);
- if (empty($info)) throw new OrderException('无效的商品!');
- //判断是否是虚拟订单
- $this->seckill_id = $info['seckill_id'];
- if ($info['is_virtual']) {
- $this->is_virtual = 1;
- } else {
- $this->is_virtual = 0;
- }
- $info["num"] = $num;
- $price = $info["seckill_price"];//订单项商品单价
- $goods_money = $price * $info['num'];
- $info["price"] = $price;
- $info['goods_money'] = $goods_money;//订单项商品总价
- $info['real_goods_money'] = $goods_money;//真实商品金额
- $info['coupon_money'] = 0;//优惠券金额
- $info['promotion_money'] = 0;//优惠金额
-
- $this->site_name = $info['site_name'];
- $this->goods_money = $goods_money;
- $this->goods_list_str = $info['sku_id'] . ':' . $info['num'];
- $this->order_name = string_split("", ",", $info['sku_name']);
- $this->goods_num = $info['num'];
- $this->goods_list[] = $info;
- return true;
- }
-
- /**
- * 获取店铺订单计算
- */
- public function shopOrderCalculate()
- {
- //重新计算订单总额
- $this->getOrderMoney();
- //理论上是多余的操作
- if ($this->order_money < 0) {
- $this->order_money = 0;
- }
- //总结计算
- $this->pay_money = $this->order_money;
-
- return true;
- }
-
-
-
- /**
- * 获取会员该秒杀时段已购该商品数
- * @param $goods_id
- * @param $member_id
- * @return float
- */
- public function getGoodsPurchasedNum($sku_id, $member_id, $seckill_id)
- {
- $join = [
- ['order o', 'o.order_id = og.order_id', 'left']
- ];
- $num = model('order_goods')->getSum([
- ['og.member_id', '=', $member_id],
- ['og.sku_id', '=', $sku_id],
- ['o.order_status', '<>', Order::ORDER_CLOSE],
- ['o.promotion_type', '=', 'seckill'],
- ['o.promotion_id', '=', $seckill_id],
- ['og.refund_status', '<>', OrderRefundDict::REFUND_COMPLETE],
- ['o.create_time', 'between', [date_to_time(date('Y-m-d 00:00:00')), time()]]
- ], 'og.num', 'og', $join);
- return $num;
- }
-
-
-
+promotion_type = 'seckill';
+ $this->promotion_type_name = '秒杀';
+ }
+ /**
+ * 订单创建
+ */
+ public function create()
+ {
+ //计算
+ $this->confirm();
+ if ($this->error > 0) {
+ return $this->error(['error_code' => $this->error], $this->error_msg);
+ }
+ //订单创建数据
+ $order_insert_data = $this->getOrderInsertData(['discount'], 'invert');
+ $order_insert_data['store_id'] = $this->store_id;
+ $order_insert_data['create_time'] = time();
+ $order_insert_data['is_enable_refund'] = 0;
+ //订单类型以及状态
+ $this->orderType();
+ $order_insert_data['order_type'] = $this->order_type['order_type_id'];
+ $order_insert_data['order_type_name'] = $this->order_type['order_type_name'];
+ $order_insert_data['order_status_name'] = $this->order_type['order_status']['name'];
+ $order_insert_data['order_status_action'] = json_encode($this->order_type['order_status'], JSON_UNESCAPED_UNICODE);
+
+ model('order')->startTrans();
+ //循环生成多个订单
+ try {
+ $this->order_id = model('order')->add($order_insert_data);
+ $order_goods_insert_data = [];
+ //订单项目表
+ foreach ($this->goods_list as &$order_goods_v) {
+ $order_goods_insert_data[] = $this->getOrderGoodsInsertData($order_goods_v);
+
+ model("promotion_seckill_goods")->setDec([['sku_id', '=', $order_goods_v['sku_id']], ['seckill_id', '=', $this->seckill_info["id"]]], "stock", $order_goods_v['num']);
+ model("promotion_seckill")->setDec([['id', '=', $this->seckill_info["id"]]], "goods_stock", $order_goods_v['num']);
+ // 增加销量
+ model("promotion_seckill")->setInc([['id', '=', $this->seckill_info["id"]]], "sale_num", $order_goods_v['num']);
+ }
+ model('order_goods')->addList($order_goods_insert_data);
+
+ //扣除余额(统一扣除)
+ $this->useBalance();
+ //批量库存处理(卡密商品支付后在扣出库存)
+ $this->batchDecOrderGoodssStock();
+ model('order')->commit();
+ //订单创建后事件
+ $this->orderCreateAfter();
+ //支付单据
+ $pay = new Pay();
+ $pay->addPay($this->site_id, $this->out_trade_no, $this->pay_type, $this->order_name, $this->order_name, $this->pay_money, '', 'OrderPayNotify', '');
+ return $this->success($this->out_trade_no);
+ } catch ( \Exception $e ) {
+ model('order')->rollback();
+ return $this->error('', $e->getMessage());
+ }
+
+ }
+
+
+ /**
+ * 计算后的进一步计算(不存缓存,每次都是重新计算)
+ * @return array
+ */
+ public function confirm()
+ {
+ $order_key = $this->param['order_key'];
+ $this->getOrderCache($order_key);
+ //初始化地址
+ $this->initMemberAddress();
+ //初始化门店信息
+ $this->initStore();
+ //配送计算
+ $this->calculateDelivery();
+ //批量校验配送方式
+ $this->batchCheckDeliveryType();
+ //计算发票相关
+ $this->calculateInvoice();
+ //计算余额
+ $this->calculateBalcnce();
+ $this->pay_money = $this->order_money - $this->balance_money;
+ //设置过的商品项信息
+ return get_object_vars($this);
+ }
+
+ /**
+ * 订单计算
+ */
+ public function calculate()
+ {
+ //初始化会员地址
+ $this->initMemberAddress();
+ $this->initMemberAccount();//初始化会员账户
+ //商品列表信息
+ $this->getOrderGoodsCalculate();
+ //查询秒杀信息
+ $seckill_model = new Seckill();
+ $seckill_info = $seckill_model->getSeckillInfo($this->seckill_id)['data'] ?? [];
+ if (empty($seckill_info)) throw new OrderException("找不到可用的秒杀活动");
+ $this->seckill_info = $seckill_info;
+ //判断秒杀时间段是否符合
+ $today_time = strtotime(date("Y-m-d"), time());
+ $time = time() - $today_time;//当日时间戳
+ if ($time < $this->seckill_info["seckill_start_time"] || $time > $this->seckill_info["seckill_end_time"]) {
+ $this->error = 1;
+ $this->error_msg = "当前商品秒杀活动未开启或已过期!";
+ }
+
+ //秒杀库存
+ if ($this->goods_list[0]) {
+ $seckill_goods = $seckill_model->getSeckillGoodsInfo([['psg.seckill_id', '=', $this->seckill_id], ['psg.sku_id', '=', $this->goods_list[0]['sku_id']]], 'psg.stock')['data'] ?? [];
+ $seckill_goods_stock = $seckill_goods['stock'];
+ if ($this->goods_list[0]['num'] > $seckill_goods_stock) {
+ $this->error = 1;
+ $this->error_msg = "该商品库存不足";
+ }
+ }
+
+ // 秒杀商品限购 按每日某时段限购
+ if ($this->goods_list[0]['limit_num'] > 0) {
+ $purchased_num = $this->getGoodsPurchasedNum($this->goods_list[0]['sku_id'], $this->member_id, $this->seckill_info['id']);
+ if (($purchased_num + $this->goods_list[0]['num']) > $this->goods_list[0]['limit_num']) {
+ $this->error = 1;
+ $this->error_msg = "该商品每人限购{$this->goods_list[ 0 ]['limit_num']}件,您已购买{$purchased_num}件";
+ }
+ }
+ $this->shopOrderCalculate();
+ //获取发票相关
+ $this->getInovice();
+ $this->order_key = create_no();
+ $this->setOrderCache(get_object_vars($this), $this->order_key);
+ return true;
+ }
+
+ /**
+ * 待付款订单
+ * @param unknown $data
+ */
+ public function orderPayment()
+ {
+ //计算
+ $this->calculate();
+ //查询配送信息
+ $this->getDeliveryData();
+ //订单初始项
+ event('OrderPayment', ['order_object' => $this]);
+ return get_object_vars($this);
+ }
+
+ /**
+ * 获取商品的计算信息
+ * @param unknown $data
+ */
+ public function getOrderGoodsCalculate()
+ {
+ $this->getSeckillGoodsInfo();
+ return true;
+ }
+
+ /**
+ * 获取秒杀商品列表信息
+ * @param $id
+ * @param $num
+ * @param $data
+ * @return array
+ */
+ public function getSeckillGoodsInfo()
+ {
+ $id = $this->param['id'];
+ $sku_id = $this->param['sku_id'];
+ $num = $this->param['num'];
+ //组装商品列表
+ $field = 'npsg.sku_id,npsg.seckill_id,npsg.seckill_price,npsg.max_buy as limit_num,ngs.sku_name, ngs.sku_no,
+ ngs.price, ngs.discount_price, ngs.cost_price, ngs.stock, ngs.weight, ngs.volume, ngs.sku_image,
+ ngs.site_id, ns.site_name, ngs.goods_state, ngs.is_virtual,ngs.supplier_id,
+ ngs.is_free_shipping, ngs.shipping_template, ngs.goods_class, ngs.goods_class_name,ngs.goods_id,ngs.sku_spec_format,ngs.goods_name,ngs.support_trade_type';
+ $alias = 'npsg';
+ $join = [
+ [
+ 'goods_sku ngs',
+ 'npsg.sku_id = ngs.sku_id',
+ 'inner'
+ ],
+ [
+ 'site ns',
+ 'ngs.site_id = ns.site_id',
+ 'inner'
+ ]
+ ];
+
+ $condition = [
+ ['npsg.sku_id', '=', $sku_id],
+ ['npsg.seckill_id', '=', $id],
+ ['npsg.site_id', '=', $this->site_id]
+ ];
+ $info = model("promotion_seckill_goods")->getInfo($condition, $field, $alias, $join);
+ if (empty($info)) throw new OrderException('无效的商品!');
+ //判断是否是虚拟订单
+ $this->seckill_id = $info['seckill_id'];
+ if ($info['is_virtual']) {
+ $this->is_virtual = 1;
+ } else {
+ $this->is_virtual = 0;
+ }
+ $info["num"] = $num;
+ $price = $info["seckill_price"];//订单项商品单价
+ $goods_money = $price * $info['num'];
+ $info["price"] = $price;
+ $info['goods_money'] = $goods_money;//订单项商品总价
+ $info['real_goods_money'] = $goods_money;//真实商品金额
+ $info['coupon_money'] = 0;//优惠券金额
+ $info['promotion_money'] = 0;//优惠金额
+
+ $this->site_name = $info['site_name'];
+ $this->goods_money = $goods_money;
+ $this->goods_list_str = $info['sku_id'] . ':' . $info['num'];
+ $this->order_name = string_split("", ",", $info['sku_name']);
+ $this->goods_num = $info['num'];
+ $this->goods_list[] = $info;
+ return true;
+ }
+
+ /**
+ * 获取店铺订单计算
+ */
+ public function shopOrderCalculate()
+ {
+ //重新计算订单总额
+ $this->getOrderMoney();
+ //理论上是多余的操作
+ if ($this->order_money < 0) {
+ $this->order_money = 0;
+ }
+ //总结计算
+ $this->pay_money = $this->order_money;
+
+ return true;
+ }
+
+
+
+ /**
+ * 获取会员该秒杀时段已购该商品数
+ * @param $goods_id
+ * @param $member_id
+ * @return float
+ */
+ public function getGoodsPurchasedNum($sku_id, $member_id, $seckill_id)
+ {
+ $join = [
+ ['order o', 'o.order_id = og.order_id', 'left']
+ ];
+ $num = model('order_goods')->getSum([
+ ['og.member_id', '=', $member_id],
+ ['og.sku_id', '=', $sku_id],
+ ['o.order_status', '<>', Order::ORDER_CLOSE],
+ ['o.promotion_type', '=', 'seckill'],
+ ['o.promotion_id', '=', $seckill_id],
+ ['og.refund_status', '<>', OrderRefundDict::REFUND_COMPLETE],
+ ['o.create_time', 'between', [date_to_time(date('Y-m-d 00:00:00')), time()]]
+ ], 'og.num', 'og', $join);
+ return $num;
+ }
+
+
+
}
\ No newline at end of file
diff --git a/src/addon/seckill/model/share/WchatShare.php b/src/addon/seckill/model/share/WchatShare.php
index 441ed31f2..2940cfe0f 100644
--- a/src/addon/seckill/model/share/WchatShare.php
+++ b/src/addon/seckill/model/share/WchatShare.php
@@ -1,141 +1,132 @@
- '秒杀分享',
- 'config_key' => 'WCHAT_SHARE_CONFIG_SECKILL_PROMOTE',
- 'path' => [ '/pages_promotion/seckill/detail' ],
- 'method_prefix' => 'goodsDetail',
- ],
- [
- 'title' => '秒杀列表',
- 'config_key' => 'WCHAT_SHARE_CONFIG_SECKILL_LIST_PROMOTE',
- 'path' => [ '/pages_promotion/seckill/list' ],
- 'method_prefix' => 'goodsList',
- ],
- ];
-
- protected $sort = 8;
-
- /**
- * 秒杀列表
- * @param $param
- * @return array
- */
- protected function goodsListShareData($param)
- {
- //跳转路径
- $link = $this->getShareLink($param);
- $config_data = $this->goodsListShareConfig($param)[ 'value' ];
-
- $data = [
- 'link' => $link,
- 'desc' => $config_data[ 'desc' ],
- 'imgUrl' => $config_data[ 'imgUrl' ],
- 'title' => $config_data[ 'title' ]
- ];
- return [
- 'permission' => [
- 'hideOptionMenu' => false,
- 'hideMenuItems' => [],
- ],
- 'data' => $data,//分享内容
- ];
- }
-
- /**
- * 秒杀列表分享配置
- * @param $param
- * @return array
- */
- public function goodsListShareConfig($param)
- {
- $site_id = $param[ 'site_id' ];
- $config = $param[ 'config' ];
-
- $config_model = new ConfigModel();
- $data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
- if (empty($data[ 'value' ])) {
- $data[ 'value' ] = [
- 'title' => "秒杀列表",
- 'desc' => "秒杀进行时\n快来参与吧",
- 'imgUrl' => ''
- ];
- }
- if (empty($data[ 'value' ][ 'imgUrl' ])) {
- $data[ 'value' ][ 'imgUrl' ] = img('addon/seckill/icon.png');
- }
- return [
- 'value' => $data[ 'value' ],
- ];
- }
-
- /**
- * 秒杀分享数据
- * @param $param
- * @return array
- */
- protected function goodsDetailShareData($param)
- {
- $url = $param[ 'url' ];
-
- $parse_res = parse_url($url);
- parse_str($parse_res[ 'query' ] ?? '', $query);
-
- if (isset($query[ 'seckill_id' ]) || $query[ 'id' ]) {
- $seckill_id = $query['seckill_id'] ?? $query['id'];
- $goods = new Seckill();
- $condition = [
- [ 'ps.id', '=', $seckill_id ],
- [ 'psg.site_id', '=', 1 ],
- [ 'psg.status', '=', 1 ],
- [ 'ps.status', '=', 1 ],
- [ 'g.is_delete', '=', 0 ]
- ];
- $sku_info = $goods->getSeckillGoodsInfo($condition)[ 'data' ];
- if (!empty($sku_info)) {
- $config_model = new \app\model\share\WchatShare();
- $config_data = $config_model->goodsDetailShareConfig($param);
-
- $title = str_replace('{goods_name}', $sku_info[ 'sku_name' ], $config_data[ 'value' ][ 'title' ]);
- $desc = str_replace('{price}', $sku_info[ 'seckill_price' ], $config_data[ 'value' ][ 'desc' ]);
- $link = $this->getShareLink($param);
- $image_url = $sku_info[ 'sku_image' ];
-
- $data = [
- 'title' => $title,
- 'desc' => $desc,
- 'link' => $link,
- 'imgUrl' => $image_url,
- ];
- return [
- 'permission' => [
- 'hideOptionMenu' => false,
- 'hideMenuItems' => [],
- ],
- 'data' => $data,//分享内容
- ];
- }
- }
- }
-}
+ '秒杀分享',
+ 'config_key' => 'WCHAT_SHARE_CONFIG_SECKILL_PROMOTE',
+ 'path' => [ '/pages_promotion/seckill/detail' ],
+ 'method_prefix' => 'goodsDetail',
+ ],
+ [
+ 'title' => '秒杀列表',
+ 'config_key' => 'WCHAT_SHARE_CONFIG_SECKILL_LIST_PROMOTE',
+ 'path' => [ '/pages_promotion/seckill/list' ],
+ 'method_prefix' => 'goodsList',
+ ],
+ ];
+
+ protected $sort = 8;
+
+ /**
+ * 秒杀列表
+ * @param $param
+ * @return array
+ */
+ protected function goodsListShareData($param)
+ {
+ //跳转路径
+ $link = $this->getShareLink($param);
+ $config_data = $this->goodsListShareConfig($param)[ 'value' ];
+
+ $data = [
+ 'link' => $link,
+ 'desc' => $config_data[ 'desc' ],
+ 'imgUrl' => $config_data[ 'imgUrl' ],
+ 'title' => $config_data[ 'title' ]
+ ];
+ return [
+ 'permission' => [
+ 'hideOptionMenu' => false,
+ 'hideMenuItems' => [],
+ ],
+ 'data' => $data,//分享内容
+ ];
+ }
+
+ /**
+ * 秒杀列表分享配置
+ * @param $param
+ * @return array
+ */
+ public function goodsListShareConfig($param)
+ {
+ $site_id = $param[ 'site_id' ];
+ $config = $param[ 'config' ];
+
+ $config_model = new ConfigModel();
+ $data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
+ if (empty($data[ 'value' ])) {
+ $data[ 'value' ] = [
+ 'title' => "秒杀列表",
+ 'desc' => "秒杀进行时\n快来参与吧",
+ 'imgUrl' => ''
+ ];
+ }
+ if (empty($data[ 'value' ][ 'imgUrl' ])) {
+ $data[ 'value' ][ 'imgUrl' ] = img('addon/seckill/icon.png');
+ }
+ return [
+ 'value' => $data[ 'value' ],
+ ];
+ }
+
+ /**
+ * 秒杀分享数据
+ * @param $param
+ * @return array
+ */
+ protected function goodsDetailShareData($param)
+ {
+ $url = $param[ 'url' ];
+
+ $parse_res = parse_url($url);
+ parse_str($parse_res[ 'query' ] ?? '', $query);
+
+ if (isset($query[ 'seckill_id' ]) || $query[ 'id' ]) {
+ $seckill_id = $query['seckill_id'] ?? $query['id'];
+ $goods = new Seckill();
+ $condition = [
+ [ 'ps.id', '=', $seckill_id ],
+ [ 'psg.site_id', '=', 1 ],
+ [ 'psg.status', '=', 1 ],
+ [ 'ps.status', '=', 1 ],
+ [ 'g.is_delete', '=', 0 ]
+ ];
+ $sku_info = $goods->getSeckillGoodsInfo($condition)[ 'data' ];
+ if (!empty($sku_info)) {
+ $config_model = new \app\model\share\WchatShare();
+ $config_data = $config_model->goodsDetailShareConfig($param);
+
+ $title = str_replace('{goods_name}', $sku_info[ 'sku_name' ], $config_data[ 'value' ][ 'title' ]);
+ $desc = str_replace('{price}', $sku_info[ 'seckill_price' ], $config_data[ 'value' ][ 'desc' ]);
+ $link = $this->getShareLink($param);
+ $image_url = $sku_info[ 'sku_image' ];
+
+ $data = [
+ 'title' => $title,
+ 'desc' => $desc,
+ 'link' => $link,
+ 'imgUrl' => $image_url,
+ ];
+ return [
+ 'permission' => [
+ 'hideOptionMenu' => false,
+ 'hideMenuItems' => [],
+ ],
+ 'data' => $data,//分享内容
+ ];
+ }
+ }
+ }
+}
diff --git a/src/addon/seckill/model/share/WeappShare.php b/src/addon/seckill/model/share/WeappShare.php
index 1ddb5c90c..05d565615 100644
--- a/src/addon/seckill/model/share/WeappShare.php
+++ b/src/addon/seckill/model/share/WeappShare.php
@@ -1,15 +1,7 @@
replace = [
- 'SECKILL_CSS' => __ROOT__ . '/addon/seckill/shop/view/public/css',
- 'SECKILL_JS' => __ROOT__ . '/addon/seckill/shop/view/public/js',
- 'SECKILL_IMG' => __ROOT__ . '/addon/seckill/shop/view/public/img',
- ];
- parent::__construct($app);
- }
-
- /**
- * 秒杀时间段列表
- */
- public function lists()
- {
- if (request()->isJson()) {
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $order = 'seckill_start_time asc';
- $field = '*';
-
- $seckill_model = new SeckillModel();
- $res = $seckill_model->getSeckillTimeList($condition, $field, $order, null);
- foreach ($res[ 'data' ] as $key => $val) {
- $val = $seckill_model->transformSeckillTime($val);
- $res[ 'data' ][ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
- $res[ 'data' ][ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
- }
- return $res;
- } else {
-
- return $this->fetch("seckill/lists");
- }
- }
-
- /**
- * 添加秒杀时间段
- */
- public function add()
- {
- if (request()->isJson()) {
- $start_hour = input('start_hour', 0);
- $start_minute = input('start_minute', 0);
- $start_second = input('start_second', 0);
-
- $end_hour = input('end_hour', 0);
- $end_minute = input('end_minute', 0);
- $end_second = input('end_second', 0);
-
- $data = [
- 'site_id' => $this->site_id,
- 'name' => input('name', ''),
- 'seckill_start_time' => $start_hour * 3600 + $start_minute * 60 + $start_second,
- 'seckill_end_time' => $end_hour * 3600 + $end_minute * 60 + $end_second,
- 'create_time' => time(),
- ];
- $seckill_model = new SeckillModel();
- return $seckill_model->addSeckillTime($data);
- } else {
- return $this->fetch("seckill/add");
- }
- }
-
- /**
- * 编辑秒杀时间段
- */
- public function edit()
- {
- $seckill_model = new SeckillModel();
- if (request()->isJson()) {
- $start_hour = input('start_hour', 0);
- $start_minute = input('start_minute', 0);
- $start_second = input('start_second', 0);
-
- $end_hour = input('end_hour', 0);
- $end_minute = input('end_minute', 0);
- $end_second = input('end_second', 0);
-
- $data = [
- 'name' => input('name', ''),
- 'seckill_start_time' => $start_hour * 3600 + $start_minute * 60 + $start_second,
- 'seckill_end_time' => $end_hour * 3600 + $end_minute * 60 + $end_second,
- 'create_time' => time(),
- 'id' => input('id', 0),
- ];
- return $seckill_model->editSeckillTime($data, $this->site_id);
- } else {
- $id = input('id', 0);
- $this->assign('id', $id);
-
- //秒杀详情
- $time_info = $seckill_model->getSeckillTimeInfo([ [ 'id', '=', $id ] ]);
- if (!empty($time_info[ 'data' ])) {
- $time_info[ 'data' ] = $seckill_model->transformSeckillTime($time_info[ 'data' ]);
- }
- $this->assign('time_info', $time_info[ 'data' ]);
-
- return $this->fetch("seckill/edit");
- }
- }
-
- /**
- * 删除秒杀时间段
- */
- public function delete()
- {
- if (request()->isJson()) {
- $seckill_time_id = input('id', 0);
- $seckill_model = new SeckillModel();
- return $seckill_model->deleteSeckillTime($seckill_time_id);
- }
- }
-
- /**
- * 添加秒杀商品
- */
- public function addGoods()
- {
- $seckill_model = new SeckillModel();
- if (request()->isJson()) {
- $data = [
- 'site_id' => $this->site_id,
- 'seckill_name' => input('seckill_name', ''),
- 'remark' => input('remark', ''),
- 'seckill_time_id' => input('seckill_time_id', ''),
- 'start_time' => strtotime(input('start_time', '')),
- 'end_time' => strtotime(input('end_time', '')),
- 'goods_data' => input('goods_data', ''),
- 'goods_ids' => input('goods_ids', ''),
- 'sort' => input('sort', '')
- ];
- $res = $seckill_model->addSeckillGoods($data);
- return $res;
- } else {
- return $this->fetch("seckill/editgoods");
- }
- }
-
- /**
- * 更新商品(秒杀价格)
- */
- public function updateGoods()
- {
- $seckill_model = new SeckillModel();
- if (request()->isJson()) {
- $data = [
- 'site_id' => $this->site_id,
- 'id' => input('id', ''),
- 'seckill_name' => input('seckill_name', ''),
- 'remark' => input('remark', ''),
- 'seckill_time_id' => input('seckill_time_id', ''),
- 'start_time' => strtotime(input('start_time', '')),
- 'end_time' => strtotime(input('end_time', '')),
- 'sku_list' => input('sku_list', ''),
- 'goods_ids' => input('goods_ids', ''),
- 'sort' => input('sort', ''),
- ];
- $res = $seckill_model->editSeckillGoods($data);
- return $res;
- } else {
- $seckill_id = input('id', '');
- if (empty($seckill_id)) {
- $this->error('缺少参数id');
- }
- $seckill_info = $seckill_model->getSeckillDetail([ [ 'id', '=', $seckill_id ] ])[ 'data' ];
-
- $seckill_time_id = trim($seckill_info[ 'seckill_time_id' ], ',');
- $time_list = $seckill_model->getSeckillTimeList([ [ 'id', 'in', $seckill_time_id ] ])[ 'data' ];
-
- $this->assign('seckill_info', $seckill_info);
- $this->assign('time_list', $time_list);
-
- return $this->fetch("seckill/editgoods");
- }
- }
-
- public function seckillSort()
- {
- $sort = input('sort', 0);
- $id = input('id', 0);
- $seckill_model = new SeckillModel();
- return $seckill_model->seckillSort($id, $sort);
- }
-
- /**
- * 删除商品
- */
- public function deleteGoods()
- {
- if (request()->isJson()) {
- $seckill_id = input('id', 0);
- $site_id = $this->site_id;
-
- $seckill_model = new SeckillModel();
- return $seckill_model->deleteSeckillGoods($seckill_id, $site_id);
- }
- }
-
- /**
- * 秒杀商品
- */
- public function goodslist()
- {
- $seckill_time_id = input('seckill_time_id', '');
- if (request()->isJson()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $goods_name = input('goods_name', '');
- $status = input('status', '');
- $link_sort = input('order', 'start_time');
- $sort = input('sort', 'desc');
-
- $condition = [];
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $condition[] = [ 'goods_name', 'like', '%' . $goods_name . '%' ];
-
- if ($status !== '') $condition[] = [ 'status', '=', $status ];
- //排序
- if ($link_sort == 'sort') {
- $order_by = $link_sort . ' ' . $sort;
- } else {
- $order_by = $link_sort . ' ' . $sort . ',sort desc';
- }
-
- if (!empty($seckill_time_id)) {
- $condition[] = [ '', 'exp', \think\facade\Db::raw("FIND_IN_SET({$seckill_time_id},seckill_time_id)") ];
- }
-
- $start_time = input('start_time', '');
- $end_time = input('end_time', '');
-
- if ($start_time && !$end_time) {
- $condition[] = [ 'end_time', '>=', date_to_time($start_time) ];
- } elseif (!$start_time && $end_time) {
- $condition[] = [ 'start_time', '<=', date_to_time($end_time) ];
- } elseif ($start_time && $end_time) {
- $start_timestamp = date_to_time($start_time);
- $end_timestamp = date_to_time($end_time);
- $sql = "start_time between {$start_timestamp} and {$end_timestamp}";
- $sql .= " or end_time between {$start_timestamp} and {$end_timestamp}";
- $sql .= " or (start_time <= {$start_timestamp} and end_time >= {$end_timestamp})";
- $condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
- }
-
- $seckill_model = new SeckillModel();
- $seckill_list = $seckill_model->getSeckillPageList($condition, $page, $page_size, $order_by);
-
- $seckill_condition[] = [ 'site_id', '=', $this->site_id ];
-
- $time_list = $seckill_model->getSeckillTimeList($seckill_condition);
- foreach ($seckill_list[ 'data' ][ 'list' ] as $k => $v) {
- $seckill_list[ 'data' ][ 'list' ][ $k ][ 'time_list' ] = [];
- foreach ($time_list[ 'data' ] as $index => $item) {
- if (strpos(',' . $v[ 'seckill_time_id' ] . ',', ',' . $item[ 'id' ] . ',') !== false) {
- $seckill_list[ 'data' ][ 'list' ][ $k ][ 'time_list' ][] = $item;
- }
- }
- }
-
- return $seckill_list;
- } else {
-
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $order = 'seckill_start_time asc';
- $field = '*';
-
- $seckill_model = new SeckillModel();
- $res = $seckill_model->getSeckillTimeList($condition, $field, $order, null);
- $this->assign('seckill_time_id', $seckill_time_id);
- $this->assign('res', $res[ 'data' ]);
- return $this->fetch("seckill/goodslist");
- }
- }
-
- /**
- * 秒杀时段
- */
- public function seckilltimeselect()
- {
- if (request()->isJson()) {
- $condition[] = [ 'site_id', '=', $this->site_id ];
- $order = 'seckill_start_time asc';
- $field = '*';
-
- $seckill_model = new SeckillModel();
- $res = $seckill_model->getSeckillTimeList($condition, $field, $order, null);
- foreach ($res[ 'data' ] as $key => $val) {
- $val = $seckill_model->transformSeckillTime($val);
- $res[ 'data' ][ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
- $res[ 'data' ][ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
- }
- return $res;
- } else {
-
- return $this->fetch("seckill/seckilltimeselect");
- }
-
- }
-
- /**
- * 获取商品列表
- * @return array
- */
- public function getSkuList()
- {
- if (request()->isJson()) {
- $seckill_model = new SeckillModel();
- $seckill_id = input('seckill_id', '');
- $goods_list = $seckill_model->getSeckillGoodsList($seckill_id);
- return $goods_list;
- }
- }
-
- /**
- * 手动关闭秒杀
- * @return array
- */
- public function closeSeckill()
- {
- if (request()->isJson()) {
- $seckill_model = new SeckillModel();
- $seckill_id = input('seckill_id', '');
- $goods_list = $seckill_model->closeSeckill($seckill_id);
- return $goods_list;
- }
- }
-
- /**
- * 秒杀推广
- */
- public function seckillUrl()
- {
- $seckill_id = input('seckill_id', '');
- $app_type = input('app_type', 'all');
- $seckill_model = new SeckillModel();
-
- $res = $seckill_model->urlQrcode('/pages_promotion/seckill/detail', [ 'id' => $seckill_id ], 'seckill', $app_type, $this->site_id);
- return $res;
- }
-
- /**
- * 批量删除商品
- */
- public function deleteGoodsAll()
- {
- if (request()->isJson()) {
- $seckill_id = input('seckill_id', 0);
-
- $seckill_model = new SeckillModel();
- foreach ($seckill_id as $k => $v){
- $res = $seckill_model->deleteSeckillGoods($v, $this->site_id);
- }
- return $res;
- }
- }
-
- /**
- * 批量关闭秒杀
- * @return array
- */
- public function closeSeckillAll()
- {
- if (request()->isJson()) {
- $seckill_model = new SeckillModel();
- $seckill_id = input('seckill_id', '');
-
- foreach ($seckill_id as $k => $v){
- $res = $seckill_model->closeSeckill($v);
- }
- return $res;
- }
- }
-
+replace = [
+ 'SECKILL_CSS' => __ROOT__ . '/addon/seckill/shop/view/public/css',
+ 'SECKILL_JS' => __ROOT__ . '/addon/seckill/shop/view/public/js',
+ 'SECKILL_IMG' => __ROOT__ . '/addon/seckill/shop/view/public/img',
+ ];
+ parent::__construct($app);
+ }
+
+ /**
+ * 秒杀时间段列表
+ */
+ public function lists()
+ {
+ if (request()->isJson()) {
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $order = 'seckill_start_time asc';
+ $field = '*';
+
+ $seckill_model = new SeckillModel();
+ $res = $seckill_model->getSeckillTimeList($condition, $field, $order, null);
+ foreach ($res[ 'data' ] as $key => $val) {
+ $val = $seckill_model->transformSeckillTime($val);
+ $res[ 'data' ][ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
+ $res[ 'data' ][ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
+ }
+ return $res;
+ } else {
+
+ return $this->fetch("seckill/lists");
+ }
+ }
+
+ /**
+ * 添加秒杀时间段
+ */
+ public function add()
+ {
+ if (request()->isJson()) {
+ $start_hour = input('start_hour', 0);
+ $start_minute = input('start_minute', 0);
+ $start_second = input('start_second', 0);
+
+ $end_hour = input('end_hour', 0);
+ $end_minute = input('end_minute', 0);
+ $end_second = input('end_second', 0);
+
+ $data = [
+ 'site_id' => $this->site_id,
+ 'name' => input('name', ''),
+ 'seckill_start_time' => $start_hour * 3600 + $start_minute * 60 + $start_second,
+ 'seckill_end_time' => $end_hour * 3600 + $end_minute * 60 + $end_second,
+ 'create_time' => time(),
+ ];
+ $seckill_model = new SeckillModel();
+ return $seckill_model->addSeckillTime($data);
+ } else {
+ return $this->fetch("seckill/add");
+ }
+ }
+
+ /**
+ * 编辑秒杀时间段
+ */
+ public function edit()
+ {
+ $seckill_model = new SeckillModel();
+ if (request()->isJson()) {
+ $start_hour = input('start_hour', 0);
+ $start_minute = input('start_minute', 0);
+ $start_second = input('start_second', 0);
+
+ $end_hour = input('end_hour', 0);
+ $end_minute = input('end_minute', 0);
+ $end_second = input('end_second', 0);
+
+ $data = [
+ 'name' => input('name', ''),
+ 'seckill_start_time' => $start_hour * 3600 + $start_minute * 60 + $start_second,
+ 'seckill_end_time' => $end_hour * 3600 + $end_minute * 60 + $end_second,
+ 'create_time' => time(),
+ 'id' => input('id', 0),
+ ];
+ return $seckill_model->editSeckillTime($data, $this->site_id);
+ } else {
+ $id = input('id', 0);
+ $this->assign('id', $id);
+
+ //秒杀详情
+ $time_info = $seckill_model->getSeckillTimeInfo([ [ 'id', '=', $id ] ]);
+ if (!empty($time_info[ 'data' ])) {
+ $time_info[ 'data' ] = $seckill_model->transformSeckillTime($time_info[ 'data' ]);
+ }
+ $this->assign('time_info', $time_info[ 'data' ]);
+
+ return $this->fetch("seckill/edit");
+ }
+ }
+
+ /**
+ * 删除秒杀时间段
+ */
+ public function delete()
+ {
+ if (request()->isJson()) {
+ $seckill_time_id = input('id', 0);
+ $seckill_model = new SeckillModel();
+ return $seckill_model->deleteSeckillTime($seckill_time_id);
+ }
+ }
+
+ /**
+ * 添加秒杀商品
+ */
+ public function addGoods()
+ {
+ $seckill_model = new SeckillModel();
+ if (request()->isJson()) {
+ $data = [
+ 'site_id' => $this->site_id,
+ 'seckill_name' => input('seckill_name', ''),
+ 'remark' => input('remark', ''),
+ 'seckill_time_id' => input('seckill_time_id', ''),
+ 'start_time' => strtotime(input('start_time', '')),
+ 'end_time' => strtotime(input('end_time', '')),
+ 'goods_data' => input('goods_data', ''),
+ 'goods_ids' => input('goods_ids', ''),
+ 'sort' => input('sort', '')
+ ];
+ $res = $seckill_model->addSeckillGoods($data);
+ return $res;
+ } else {
+ return $this->fetch("seckill/editgoods");
+ }
+ }
+
+ /**
+ * 更新商品(秒杀价格)
+ */
+ public function updateGoods()
+ {
+ $seckill_model = new SeckillModel();
+ if (request()->isJson()) {
+ $data = [
+ 'site_id' => $this->site_id,
+ 'id' => input('id', ''),
+ 'seckill_name' => input('seckill_name', ''),
+ 'remark' => input('remark', ''),
+ 'seckill_time_id' => input('seckill_time_id', ''),
+ 'start_time' => strtotime(input('start_time', '')),
+ 'end_time' => strtotime(input('end_time', '')),
+ 'sku_list' => input('sku_list', ''),
+ 'goods_ids' => input('goods_ids', ''),
+ 'sort' => input('sort', ''),
+ ];
+ $res = $seckill_model->editSeckillGoods($data);
+ return $res;
+ } else {
+ $seckill_id = input('id', '');
+ if (empty($seckill_id)) {
+ $this->error('缺少参数id');
+ }
+ $seckill_info = $seckill_model->getSeckillDetail([ [ 'id', '=', $seckill_id ] ])[ 'data' ];
+
+ $seckill_time_id = trim($seckill_info[ 'seckill_time_id' ], ',');
+ $time_list = $seckill_model->getSeckillTimeList([ [ 'id', 'in', $seckill_time_id ] ])[ 'data' ];
+
+ $this->assign('seckill_info', $seckill_info);
+ $this->assign('time_list', $time_list);
+
+ return $this->fetch("seckill/editgoods");
+ }
+ }
+
+ public function seckillSort()
+ {
+ $sort = input('sort', 0);
+ $id = input('id', 0);
+ $seckill_model = new SeckillModel();
+ return $seckill_model->seckillSort($id, $sort);
+ }
+
+ /**
+ * 删除商品
+ */
+ public function deleteGoods()
+ {
+ if (request()->isJson()) {
+ $seckill_id = input('id', 0);
+ $site_id = $this->site_id;
+
+ $seckill_model = new SeckillModel();
+ return $seckill_model->deleteSeckillGoods($seckill_id, $site_id);
+ }
+ }
+
+ /**
+ * 秒杀商品
+ */
+ public function goodslist()
+ {
+ $seckill_time_id = input('seckill_time_id', '');
+ if (request()->isJson()) {
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $goods_name = input('goods_name', '');
+ $status = input('status', '');
+ $link_sort = input('order', 'start_time');
+ $sort = input('sort', 'desc');
+
+ $condition = [];
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $condition[] = [ 'goods_name', 'like', '%' . $goods_name . '%' ];
+
+ if ($status !== '') $condition[] = [ 'status', '=', $status ];
+ //排序
+ if ($link_sort == 'sort') {
+ $order_by = $link_sort . ' ' . $sort;
+ } else {
+ $order_by = $link_sort . ' ' . $sort . ',sort desc';
+ }
+
+ if (!empty($seckill_time_id)) {
+ $condition[] = [ '', 'exp', \think\facade\Db::raw("FIND_IN_SET({$seckill_time_id},seckill_time_id)") ];
+ }
+
+ $start_time = input('start_time', '');
+ $end_time = input('end_time', '');
+
+ if ($start_time && !$end_time) {
+ $condition[] = [ 'end_time', '>=', date_to_time($start_time) ];
+ } elseif (!$start_time && $end_time) {
+ $condition[] = [ 'start_time', '<=', date_to_time($end_time) ];
+ } elseif ($start_time && $end_time) {
+ $start_timestamp = date_to_time($start_time);
+ $end_timestamp = date_to_time($end_time);
+ $sql = "start_time between {$start_timestamp} and {$end_timestamp}";
+ $sql .= " or end_time between {$start_timestamp} and {$end_timestamp}";
+ $sql .= " or (start_time <= {$start_timestamp} and end_time >= {$end_timestamp})";
+ $condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
+ }
+
+ $seckill_model = new SeckillModel();
+ $seckill_list = $seckill_model->getSeckillPageList($condition, $page, $page_size, $order_by);
+
+ $seckill_condition[] = [ 'site_id', '=', $this->site_id ];
+
+ $time_list = $seckill_model->getSeckillTimeList($seckill_condition);
+ foreach ($seckill_list[ 'data' ][ 'list' ] as $k => $v) {
+ $seckill_list[ 'data' ][ 'list' ][ $k ][ 'time_list' ] = [];
+ foreach ($time_list[ 'data' ] as $index => $item) {
+ if (strpos(',' . $v[ 'seckill_time_id' ] . ',', ',' . $item[ 'id' ] . ',') !== false) {
+ $seckill_list[ 'data' ][ 'list' ][ $k ][ 'time_list' ][] = $item;
+ }
+ }
+ }
+
+ return $seckill_list;
+ } else {
+
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $order = 'seckill_start_time asc';
+ $field = '*';
+
+ $seckill_model = new SeckillModel();
+ $res = $seckill_model->getSeckillTimeList($condition, $field, $order, null);
+ $this->assign('seckill_time_id', $seckill_time_id);
+ $this->assign('res', $res[ 'data' ]);
+ return $this->fetch("seckill/goodslist");
+ }
+ }
+
+ /**
+ * 秒杀时段
+ */
+ public function seckilltimeselect()
+ {
+ if (request()->isJson()) {
+ $condition[] = [ 'site_id', '=', $this->site_id ];
+ $order = 'seckill_start_time asc';
+ $field = '*';
+
+ $seckill_model = new SeckillModel();
+ $res = $seckill_model->getSeckillTimeList($condition, $field, $order, null);
+ foreach ($res[ 'data' ] as $key => $val) {
+ $val = $seckill_model->transformSeckillTime($val);
+ $res[ 'data' ][ $key ][ 'seckill_start_time_show' ] = "{$val['start_hour']}:{$val['start_minute']}:{$val['start_second']}";
+ $res[ 'data' ][ $key ][ 'seckill_end_time_show' ] = "{$val['end_hour']}:{$val['end_minute']}:{$val['end_second']}";
+ }
+ return $res;
+ } else {
+
+ return $this->fetch("seckill/seckilltimeselect");
+ }
+
+ }
+
+ /**
+ * 获取商品列表
+ * @return array
+ */
+ public function getSkuList()
+ {
+ if (request()->isJson()) {
+ $seckill_model = new SeckillModel();
+ $seckill_id = input('seckill_id', '');
+ $goods_list = $seckill_model->getSeckillGoodsList($seckill_id);
+ return $goods_list;
+ }
+ }
+
+ /**
+ * 手动关闭秒杀
+ * @return array
+ */
+ public function closeSeckill()
+ {
+ if (request()->isJson()) {
+ $seckill_model = new SeckillModel();
+ $seckill_id = input('seckill_id', '');
+ $goods_list = $seckill_model->closeSeckill($seckill_id);
+ return $goods_list;
+ }
+ }
+
+ /**
+ * 秒杀推广
+ */
+ public function seckillUrl()
+ {
+ $seckill_id = input('seckill_id', '');
+ $app_type = input('app_type', 'all');
+ $seckill_model = new SeckillModel();
+
+ $res = $seckill_model->urlQrcode('/pages_promotion/seckill/detail', [ 'id' => $seckill_id ], 'seckill', $app_type, $this->site_id);
+ return $res;
+ }
+
+ /**
+ * 批量删除商品
+ */
+ public function deleteGoodsAll()
+ {
+ if (request()->isJson()) {
+ $seckill_id = input('seckill_id', 0);
+
+ $seckill_model = new SeckillModel();
+ foreach ($seckill_id as $k => $v){
+ $res = $seckill_model->deleteSeckillGoods($v, $this->site_id);
+ }
+ return $res;
+ }
+ }
+
+ /**
+ * 批量关闭秒杀
+ * @return array
+ */
+ public function closeSeckillAll()
+ {
+ if (request()->isJson()) {
+ $seckill_model = new SeckillModel();
+ $seckill_id = input('seckill_id', '');
+
+ foreach ($seckill_id as $k => $v){
+ $res = $seckill_model->closeSeckill($v);
+ }
+ return $res;
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/virtualcard/config/diy_view.php b/src/addon/virtualcard/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/virtualcard/config/diy_view.php
+++ b/src/addon/virtualcard/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/virtualcard/config/info.php b/src/addon/virtualcard/config/info.php
index 3377795d5..867255f12 100644
--- a/src/addon/virtualcard/config/info.php
+++ b/src/addon/virtualcard/config/info.php
@@ -1,20 +1,12 @@
- 'virtualcard',
- 'title' => '卡密商品',
- 'description' => '创建电子卡密类型商品',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'virtualcard',
+ 'title' => '卡密商品',
+ 'description' => '创建电子卡密类型商品',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/virtualcard/event/Install.php b/src/addon/virtualcard/event/Install.php
index 1e18c3d96..f61ff6f37 100644
--- a/src/addon/virtualcard/event/Install.php
+++ b/src/addon/virtualcard/event/Install.php
@@ -1,26 +1,18 @@
- 3, 'name' => '电子卡密' );
-
- private $goods_state = array (
- 1 => '销售中',
- 0 => '仓库中'
- );
-
- public function getGoodsState()
- {
- return $this->goods_state;
- }
-
- public function getGoodsClass()
- {
- return $this->goods_class;
- }
-
- /**
- * 商品添加
- * @param $data
- */
- public function addGoods($data)
- {
- model('goods')->startTrans();
-
- try {
-
- if (!empty($data[ 'goods_attr_format' ])) {
-
- $goods_attr_format = json_decode($data[ 'goods_attr_format' ], true);
- $keys = array_column($goods_attr_format, 'sort');
- if (!empty($keys)) {
- array_multisort($keys, SORT_ASC, SORT_NUMERIC, $goods_attr_format);
- $data[ 'goods_attr_format' ] = json_encode($goods_attr_format);
- }
- }
-
- $goods_image = $data[ 'goods_image' ];
- $first_image = explode(",", $goods_image)[ 0 ];
-
- //SKU商品数据
- if (!empty($data[ 'goods_sku_data' ])) {
- $data[ 'goods_sku_data' ] = json_decode($data[ 'goods_sku_data' ], true);
- }
-
- //获取标签名称
- $label_name = '';
- if ($data[ 'label_id' ]) {
- $label_info = model('goods_label')->getInfo([ [ 'id', '=', $data[ 'label_id' ] ] ], 'label_name');
- $label_name = $label_info[ 'label_name' ] ?? '';
- }
- $brand_name = '';
- if ($data[ 'brand_id' ]) {
- $brand_info = model('goods_brand')->getInfo([ [ 'brand_id', '=', $data[ 'brand_id' ] ] ], 'brand_name');
- $brand_name = $brand_info[ 'brand_name' ] ?? '';
- }
- $goods_data = array (
- 'goods_image' => $goods_image,
- 'price' => $data[ 'goods_sku_data' ][ 0 ][ 'price' ],
- 'market_price' => $data[ 'goods_sku_data' ][ 0 ][ 'market_price' ],
- 'cost_price' => $data[ 'goods_sku_data' ][ 0 ][ 'cost_price' ],
- 'goods_spec_format' => $data[ 'goods_spec_format' ],
- 'category_id' => $data[ 'category_id' ],
- 'category_json' => $data[ 'category_json' ],
- 'label_id' => $data[ 'label_id' ],
- 'label_name' => $label_name,
- 'timer_on' => $data[ 'timer_on' ],
- 'timer_off' => $data[ 'timer_off' ],
- 'sale_show' => $data[ 'sale_show' ] ?? 1,
- 'stock_show' => $data[ 'stock_show' ] ?? 1,
- 'market_price_show' => $data[ 'market_price_show' ] ?? 1,
- 'barrage_show' => $data[ 'barrage_show' ] ?? 1,
- 'is_consume_discount' => $data[ 'is_consume_discount' ],
- );
-
- $common_data = array (
- 'goods_name' => $data[ 'goods_name' ],
- 'goods_class' => $this->goods_class[ 'id' ],
- 'goods_class_name' => $this->goods_class[ 'name' ],
- 'goods_attr_class' => $data[ 'goods_attr_class' ],
- 'goods_attr_name' => $data[ 'goods_attr_name' ],
- 'is_limit' => $data[ 'is_limit' ] ?? 0,
- 'limit_type' => $data[ 'limit_type' ] ?? 1,
- 'site_id' => $data[ 'site_id' ],
- 'goods_content' => $data[ 'goods_content' ],
- 'goods_state' => $data[ 'goods_state' ],
- 'goods_stock_alarm' => $data[ 'goods_stock_alarm' ],
- 'is_virtual' => 1,
- 'virtual_indate' => 0,
- 'goods_attr_format' => $data[ 'goods_attr_format' ],
- 'introduction' => $data[ 'introduction' ],
- 'keywords' => $data[ 'keywords' ],
- 'unit' => $data[ 'unit' ],
- 'brand_id' => $data[ 'brand_id' ],//品牌id
- 'brand_name' => $brand_name,//品牌名称
- 'video_url' => $data[ 'video_url' ],
- 'sort' => $data[ 'sort' ],
- 'goods_service_ids' => $data[ 'goods_service_ids' ],
- 'create_time' => time(),
- 'virtual_sale' => $data[ 'virtual_sale' ],
- 'max_buy' => $data[ 'max_buy' ],
- 'min_buy' => $data[ 'min_buy' ],
- 'recommend_way' => $data[ 'recommend_way' ],
- 'qr_id' => $data[ 'qr_id' ] ?? 0,
- 'template_id' => $data[ 'template_id' ] ?? 0,
- 'form_id' => $data[ 'form_id' ] ?? 0,
- 'sale_channel' => $data[ 'sale_channel' ] ?? 'all',
- 'sale_store' => $data[ 'sale_store' ] ?? 'all',
- 'supplier_id' => $data[ 'supplier_id' ] ?? 0
- );
-
- $goods_id = model('goods')->add(array_merge($goods_data, $common_data));
-
- $goods_stock = 0;
-
- //添加sku商品
- foreach ($data[ 'goods_sku_data' ] as $item) {
-// $carmichael = 0;
-// if (isset($item[ 'carmichael' ])) {
-// if (is_array($item[ 'carmichael' ])) {
-// $carmichael = count($item[ 'carmichael' ]);
-// }
-// }
- $sku_data = array (
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'spec_name' => $item[ 'spec_name' ],
- 'sku_no' => $item[ 'sku_no' ],
- 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
- 'price' => $item[ 'price' ],
- 'market_price' => $item[ 'market_price' ],
- 'cost_price' => $item[ 'cost_price' ],
- 'discount_price' => $item[ 'price' ],//sku折扣价(默认等于单价)
-// 'stock' => $carmichael,
- 'stock_alarm' => $item[ 'stock_alarm' ],
- 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
- 'sku_images' => $item[ 'sku_images' ],
- 'goods_id' => $goods_id,
- 'is_default' => $item[ 'is_default' ] ?? 0,
- 'is_consume_discount' => $data[ 'is_consume_discount' ],
- 'site_id' => $data[ 'site_id' ]
- );
- $sku_data = array_merge($sku_data, $common_data);
- $sku_id = model('goods_sku')->add($sku_data);
-
- // 添加到虚拟商品表
- if (isset($item[ 'carmichael' ])) {
- if (is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
- $goods_stock += count($item[ 'carmichael' ]);
- $virtual_goods = [];
- foreach ($item[ 'carmichael' ] as $carmichael_item) {
- $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
- $card = explode(' ', $carmichael_item);
- $card_arr = [
- 'cardno' => $card[ 0 ] ?? '',
- 'password' => $card[ 1 ] ?? ''
- ];
- $virtual_goods[] = [
- 'site_id' => $data[ 'site_id' ],
- 'sku_id' => $sku_id,
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'card_info' => json_encode($card_arr),
- 'goods_id' => $goods_id
- ];
- }
- model('goods_virtual')->addList($virtual_goods);
- }
- }
- }
-
- // 赋值第一个商品sku_id
- $first_info = model('goods_sku')->getFirstData([ 'goods_id' => $goods_id ], 'sku_id', 'is_default desc,sku_id asc');
- model('goods')->update([ 'sku_id' => $first_info[ 'sku_id' ] ], [ [ 'goods_id', '=', $goods_id ] ]);
-
- if (!empty($data[ 'goods_spec_format' ])) {
- // 刷新SKU商品规格项 / 规格值JSON字符串
- $this->dealGoodsSkuSpecFormat($goods_id, $data[ 'goods_spec_format' ]);
- }
-
- $cron = new Cron();
- //定时上下架
- if ($goods_data[ 'timer_on' ] > 0) {
- $cron->addCron(1, 0, "商品定时上架", "CronGoodsTimerOn", $goods_data[ 'timer_on' ], $goods_id);
- }
- if ($goods_data[ 'timer_off' ] > 0) {
- $cron->addCron(1, 0, "商品定时下架", "CronGoodsTimerOff", $goods_data[ 'timer_off' ], $goods_id);
- }
-
- //添加统计
- $stat = new Stat();
-// $stat->addShopStat([ 'add_goods_count' => 1, 'site_id' => $data[ 'site_id' ] ]);
- $stat->switchStat([ 'type' => 'add_goods', 'data' => [ 'add_goods_count' => 1, 'site_id' => $data[ 'site_id' ] ] ]);
-
- //同步计算卡密库存数据
- $this->statisticsStock($goods_id);
- model('goods')->commit();
-
- return $this->success($goods_id);
- } catch (\Exception $e) {
- model('goods')->rollback();
- return $this->error($e->getMessage());
- }
- }
-
- /**
- * 商品编辑
- * @param $data
- */
- public function editGoods($data)
- {
-
- model('goods')->startTrans();
-
- try {
-
- if (!empty($data[ 'goods_attr_format' ])) {
-
- $goods_attr_format = json_decode($data[ 'goods_attr_format' ], true);
- $keys = array_column($goods_attr_format, 'sort');
- if (!empty($keys)) {
- array_multisort($keys, SORT_ASC, SORT_NUMERIC, $goods_attr_format);
- $data[ 'goods_attr_format' ] = json_encode($goods_attr_format);
- }
- }
-
- $goods_id = $data[ 'goods_id' ];
- $goods_image = $data[ 'goods_image' ];
- $first_image = explode(",", $goods_image)[ 0 ];
-
- //SKU商品数据
- if (!empty($data[ 'goods_sku_data' ])) {
- $data[ 'goods_sku_data' ] = json_decode($data[ 'goods_sku_data' ], true);
- }
-
- //获取标签名称
- $label_name = '';
- if ($data[ 'label_id' ]) {
- $label_info = model('goods_label')->getInfo([ [ 'id', '=', $data[ 'label_id' ] ] ], 'label_name');
- $label_name = $label_info[ 'label_name' ] ?? '';
- }
- $brand_name = '';
- if ($data[ 'brand_id' ]) {
- $brand_info = model('goods_brand')->getInfo([ [ 'brand_id', '=', $data[ 'brand_id' ] ] ], 'brand_name');
- $brand_name = $brand_info[ 'brand_name' ] ?? '';
- }
- $goods_data = array (
- 'goods_image' => $goods_image,
- 'price' => $data[ 'goods_sku_data' ][ 0 ][ 'price' ],
- 'market_price' => $data[ 'goods_sku_data' ][ 0 ][ 'market_price' ],
- 'cost_price' => $data[ 'goods_sku_data' ][ 0 ][ 'cost_price' ],
- 'goods_spec_format' => $data[ 'goods_spec_format' ],
- 'category_id' => $data[ 'category_id' ],
- 'category_json' => $data[ 'category_json' ],
- 'label_id' => $data[ 'label_id' ],
- 'label_name' => $label_name,
- 'timer_on' => $data[ 'timer_on' ],
- 'timer_off' => $data[ 'timer_off' ],
- 'sale_show' => $data[ 'sale_show' ],
- 'stock_show' => $data[ 'stock_show' ],
- 'market_price_show' => $data[ 'market_price_show' ],
- 'barrage_show' => $data[ 'barrage_show' ],
- 'is_consume_discount' => $data[ 'is_consume_discount' ],
- );
-
- $common_data = array (
- 'goods_name' => $data[ 'goods_name' ],
- 'goods_class' => $this->goods_class[ 'id' ],
- 'goods_class_name' => $this->goods_class[ 'name' ],
- 'goods_attr_class' => $data[ 'goods_attr_class' ],
- 'goods_attr_name' => $data[ 'goods_attr_name' ],
- 'is_limit' => $data[ 'is_limit' ] ?? 0,
- 'limit_type' => $data[ 'limit_type' ] ?? 1,
- 'site_id' => $data[ 'site_id' ],
- 'goods_content' => $data[ 'goods_content' ],
- 'goods_state' => $data[ 'goods_state' ],
- 'goods_stock_alarm' => $data[ 'goods_stock_alarm' ],
- 'is_virtual' => 1,
- 'virtual_indate' => 0,
- 'goods_attr_format' => $data[ 'goods_attr_format' ],
- 'introduction' => $data[ 'introduction' ],
- 'keywords' => $data[ 'keywords' ],
- 'unit' => $data[ 'unit' ],
- 'video_url' => $data[ 'video_url' ],
- 'sort' => $data[ 'sort' ],
- 'goods_service_ids' => $data[ 'goods_service_ids' ],
- 'brand_id' => $data[ 'brand_id' ],//品牌id
- 'brand_name' => $brand_name,//品牌名称
- 'modify_time' => time(),
- 'virtual_sale' => $data[ 'virtual_sale' ],
- 'max_buy' => $data[ 'max_buy' ],
- 'min_buy' => $data[ 'min_buy' ],
- 'recommend_way' => $data[ 'recommend_way' ],
- 'qr_id' => $data[ 'qr_id' ] ?? 0,
- 'template_id' => $data[ 'template_id' ] ?? 0,
- 'form_id' => $data[ 'form_id' ] ?? 0,
- 'sale_channel' => $data[ 'sale_channel' ] ?? 'all',
- 'sale_store' => $data[ 'sale_store' ] ?? 'all',
- 'supplier_id' => $data[ 'supplier_id' ] ?? 0
- );
-
- model('goods')->update(array_merge($goods_data, $common_data), [ [ 'goods_id', '=', $goods_id ], [ 'goods_class', '=', $this->goods_class[ 'id' ] ] ]);
-
- $goods_stock = 0;
-
- // 如果只编辑价格库存就是修改,如果添加规格项/值就需要重新生成
- if (!empty($data[ 'goods_sku_data' ][ 0 ][ 'sku_id' ])) {
-
- if ($data[ 'spec_type_status' ] == 1) {
- $sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], 'sku_id');
- $sku_id_arr = array_column($sku_list, 'sku_id', 'sku_id');
- //添加sku商品
- foreach ($data[ 'goods_sku_data' ] as $item) {
- $carmichael = 0;
- if (isset($item[ 'carmichael' ])) {
- if (is_array($item[ 'carmichael' ])) {
- $carmichael = count($item[ 'carmichael' ]);
- }
- }
- $sku_data = array (
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'spec_name' => $item[ 'spec_name' ],
- 'sku_no' => $item[ 'sku_no' ],
- 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
- 'price' => $item[ 'price' ],
- 'market_price' => $item[ 'market_price' ],
- 'cost_price' => $item[ 'cost_price' ],
- 'discount_price' => $item[ 'price' ],//sku折扣价(默认等于单价)
-// 'stock' => $carmichael,
- 'stock_alarm' => $item[ 'stock_alarm' ],
- 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
- 'sku_images' => $item[ 'sku_images' ],
- 'goods_id' => $goods_id,
- 'is_default' => $item[ 'is_default' ] ?? 0,
- 'is_consume_discount' => $data[ 'is_consume_discount' ]
- );
- $sku_data = array_merge($sku_data, $common_data);
- if (!empty($item[ 'sku_id' ]) && in_array($item[ 'sku_id' ], $sku_id_arr)) {
- $sku_id = $item[ 'sku_id' ];
- model('goods_sku')->update($sku_data, [ [ 'sku_id', '=', $sku_id ] ]);
- unset($sku_id_arr[ $sku_id ]);
- } else {
- $sku_id = model('goods_sku')->add($sku_data);
- }
-
- // 添加到虚拟商品表
- if (isset($item[ 'carmichael' ])) {
- if (is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
- $goods_stock += count($item[ 'carmichael' ]);
- $virtual_goods = [];
- foreach ($item[ 'carmichael' ] as $carmichael_item) {
- $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
- $card = explode(' ', $carmichael_item);
- $card_arr = [
- 'cardno' => $card[ 0 ] ?? '',
- 'password' => $card[ 1 ] ?? ''
- ];
- $virtual_goods[] = [
- 'site_id' => $data[ 'site_id' ],
- 'sku_id' => $sku_id,
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'card_info' => json_encode($card_arr),
- 'goods_id' => $goods_id
- ];
- }
- model('goods_virtual')->addList($virtual_goods);
- }
- }
- }
- //删除已经不存在的sku
- if (!empty($sku_id_arr)) {
- $check = $this->checkGoodsIsExistsOrder([ 'site_id' => $data[ 'site_id' ], 'goods_id' => $goods_id, 'sku_id' => implode(",", $sku_id_arr) ]);
- if ($check[ 'code' ] < 0) {
- model('goods')->rollback();
- return $check;
- }
- model('goods_sku')->delete([ [ 'sku_id', 'in', $sku_id_arr ] ]);
- }
- } else {
- $discount_model = new Discount();
- $sku_id_arr = [];
- foreach ($data[ 'goods_sku_data' ] as $item) {
- $discount_info = [];
- if (!empty($item[ 'sku_id' ])) {
- $discount_info_result = $discount_model->getDiscountGoodsInfo([ [ 'pdg.sku_id', '=', $item[ 'sku_id' ] ], [ 'pd.status', '=', 1 ] ], 'id');
- $discount_info = $discount_info_result[ 'data' ];
- }
-
- $carmichael = 0;
- if (isset($item[ 'carmichael' ])) {
- if (is_array($item[ 'carmichael' ])) {
- $carmichael = count($item[ 'carmichael' ]);
- }
- }
-
- $sku_data = array (
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'spec_name' => $item[ 'spec_name' ],
- 'sku_no' => $item[ 'sku_no' ],
- 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
- 'price' => $item[ 'price' ],
- 'market_price' => $item[ 'market_price' ],
- 'cost_price' => $item[ 'cost_price' ],
-// 'stock' => $carmichael,
- 'stock_alarm' => $item[ 'stock_alarm' ],
- 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
- 'sku_images' => $item[ 'sku_images' ],
- 'goods_id' => $goods_id,
- 'is_default' => $item[ 'is_default' ] ?? 0,
- 'is_consume_discount' => $data[ 'is_consume_discount' ]
- );
- if (empty($discount_info)) {
- $sku_data[ 'discount_price' ] = $item[ 'price' ];
- }
- if (!empty($item[ 'sku_id' ])) {
- $sku_id = $item[ 'sku_id' ];
- $sku_id_arr[] = $item[ 'sku_id' ];
- model('goods_sku')->update(array_merge($sku_data, $common_data), [ [ 'sku_id', '=', $item[ 'sku_id' ] ], [ 'goods_class', '=', $this->goods_class[ 'id' ] ] ]);
- } else {
- $sku_id = model('goods_sku')->add(array_merge($sku_data, $common_data));
- $sku_id_arr[] = $sku_id;
- }
-
- // 添加到虚拟商品表
- if (isset($item[ 'carmichael' ])) {
- if (is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
- $goods_stock += count($item[ 'carmichael' ]);
- $virtual_goods = [];
- foreach ($item[ 'carmichael' ] as $carmichael_item) {
- $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
- $card = explode(' ', $carmichael_item);
- $card_arr = [
- 'cardno' => $card[ 0 ] ?? '',
- 'password' => $card[ 1 ] ?? ''
- ];
- $virtual_goods[] = [
- 'site_id' => $data[ 'site_id' ],
- 'sku_id' => $sku_id,
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'card_info' => json_encode($card_arr),
- 'goods_id' => $goods_id
- ];
- }
- model('goods_virtual')->addList($virtual_goods);
- }
- }
- }
-
- // 移除不存在的商品SKU
- $sku_id_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], 'sku_id');
- $sku_id_list = array_column($sku_id_list, 'sku_id');
- foreach ($sku_id_list as $k => $v) {
- foreach ($sku_id_arr as $ck => $cv) {
- if ($v == $cv) {
- unset($sku_id_list[ $k ]);
- }
- }
- }
-
- $sku_id_list = array_values($sku_id_list);
- if (!empty($sku_id_list)) {
- $check = $this->checkGoodsIsExistsOrder([ 'site_id' => $data[ 'site_id' ], 'goods_id' => $goods_id, 'sku_id' => implode(",", $sku_id_list) ]);
- if ($check[ 'code' ] < 0) {
- model('goods')->rollback();
- return $check;
- }
- model('goods_sku')->delete([ [ 'sku_id', 'in', implode(",", $sku_id_list) ] ]);
- }
- }
-
- } else {
- $check = $this->checkGoodsIsExistsOrder([ 'site_id' => $data[ 'site_id' ], 'goods_id' => $goods_id ]);
- if ($check[ 'code' ] < 0) {
- model('goods')->rollback();
- return $check;
- }
-
- model('goods_sku')->delete([ [ 'goods_id', '=', $goods_id ] ]);
-
- $sku_arr = array ();
- //添加sku商品
- foreach ($data[ 'goods_sku_data' ] as $item) {
- $sku_data = array (
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'spec_name' => $item[ 'spec_name' ],
- 'sku_no' => $item[ 'sku_no' ],
- 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
- 'price' => $item[ 'price' ],
- 'market_price' => $item[ 'market_price' ],
- 'cost_price' => $item[ 'cost_price' ],
- 'discount_price' => $item[ 'price' ],//sku折扣价(默认等于单价)
-// 'stock' => $item[ 'stock' ],
- 'stock_alarm' => $item[ 'stock_alarm' ],
- 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
- 'sku_images' => $item[ 'sku_images' ],
- 'goods_id' => $goods_id,
- 'is_default' => $item[ 'is_default' ] ?? 0,
- 'is_consume_discount' => $data[ 'is_consume_discount' ]
- );
- $sku_data = array_merge($sku_data, $common_data);
- $sku_id = model('goods_sku')->add($sku_data);
-
- // 添加到虚拟商品表
- if (isset($item[ 'carmichael' ]) && is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
- $goods_stock += count($item[ 'carmichael' ]);
- $virtual_goods = [];
- foreach ($item[ 'carmichael' ] as $carmichael_item) {
- $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
- $card = explode(' ', $carmichael_item);
- $card_arr = [
- 'cardno' => $card[ 0 ] ?? '',
- 'password' => $card[ 1 ] ?? ''
- ];
- $virtual_goods[] = [
- 'site_id' => $data[ 'site_id' ],
- 'sku_id' => $sku_id,
- 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
- 'card_info' => json_encode($card_arr),
- 'goods_id' => $goods_id
- ];
- }
- model('goods_virtual')->addList($virtual_goods);
- }
- }
- }
-
- // 赋值第一个商品sku_id
- $first_info = model('goods_sku')->getFirstData([ 'goods_id' => $goods_id ], 'sku_id', 'is_default desc,sku_id asc');
- model('goods')->update([ 'sku_id' => $first_info[ 'sku_id' ] ], [ [ 'goods_id', '=', $goods_id ] ]);
-
- if (!empty($data[ 'goods_spec_format' ])) {
- // 刷新SKU商品规格项 / 规格值JSON字符串
- $this->dealGoodsSkuSpecFormat($goods_id, $data[ 'goods_spec_format' ]);
- }
-
- $cron = new Cron();
- $cron->deleteCron([ [ 'event', '=', 'CronGoodsTimerOn' ], [ 'relate_id', '=', $goods_id ] ]);
- $cron->deleteCron([ [ 'event', '=', 'CronGoodsTimerOff' ], [ 'relate_id', '=', $goods_id ] ]);
- //定时上下架
- if ($goods_data[ 'timer_on' ] > 0) {
- $cron->addCron(1, 0, "商品定时上架", "CronGoodsTimerOn", $goods_data[ 'timer_on' ], $goods_id);
- }
- if ($goods_data[ 'timer_off' ] > 0) {
- $cron->addCron(1, 0, "商品定时下架", "CronGoodsTimerOff", $goods_data[ 'timer_off' ], $goods_id);
- }
-
- $this->statisticsStock($goods_id);
-
- model('goods')->commit();
- return $this->success($goods_id);
- } catch (\Exception $e) {
- model('goods')->rollback();
- return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
-
- /**
- * 获取商品详情
- * @param $goods_id
- * @return array
- */
- public function getGoodsDetail($goods_id, $site_id)
- {
- $info = model('goods')->getInfo([ [ 'is_delete', '=', 0 ], [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $site_id ], [ 'goods_class', '=', 3 ] ], "*");
- $field = 'sku_id, sku_name,spec_name, sku_no, sku_spec_format, price, market_price, cost_price, discount_price, stock,
- weight, volume, sku_image, sku_images, sort,member_price,fenxiao_price';
- $sku_data = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], $field);
-
- if (!empty($sku_data)) {
- foreach ($sku_data as $k => $v) {
- $sku_data[ $k ][ 'member_price' ] = $v[ 'member_price' ] == '' ? '' : json_decode($v[ 'member_price' ], true);
- $sku_data[ $k ][ 'stock' ] = numberFormat($sku_data[ $k ][ 'stock' ]);
- }
- }
- if (!empty($info)) {
- if (isset($info[ 'goods_stock' ])) {
- $info[ 'goods_stock' ] = numberFormat($info[ 'goods_stock' ]);
- }
- if (isset($info[ 'sale_num' ])) {
- $info[ 'sale_num' ] = numberFormat($info[ 'sale_num' ]);
- }
- if (isset($info[ 'virtual_sale' ])) {
- $info[ 'virtual_sale' ] = numberFormat($info[ 'virtual_sale' ]);
- }
- if (isset($info[ 'real_stock' ])) {
- $info[ 'real_stock' ] = numberFormat($info[ 'real_stock' ]);
- }
- $info[ 'sku_data' ] = $sku_data;
- }
- return $this->success($info);
- }
-
- /**
- * 刷新SKU商品规格项/规格值JSON字符串
- * @param int $goods_id 商品id
- * @param string $goods_spec_format 商品完整规格项/规格值json
- */
- private function dealGoodsSkuSpecFormat($goods_id, $goods_spec_format)
- {
- if (empty($goods_spec_format)) return;
-
- $goods_spec_format = json_decode($goods_spec_format, true);
-
- //根据goods_id查询sku商品列表,查询:sku_id、sku_spec_format 列
- $sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ], [ 'sku_spec_format', '<>', '' ] ], 'sku_id,sku_spec_format', 'sku_id asc');
- if (!empty($sku_list)) {
-
-// $temp = 0;//测试性能,勿删
-
- //循环SKU商品列表
- foreach ($sku_list as $k => $v) {
-// $temp++;
-
- $sku_format = $goods_spec_format;//最终要存储的值
- $current_format = json_decode($v[ 'sku_spec_format' ], true);//当前SKU商品规格值json
-
- $selected_data = [];//已选规格/规格值json
-
- //1、找出已选规格/规格值json
-
- //循环完整商品规格json
- foreach ($sku_format as $sku_k => $sku_v) {
-// $temp++;
-
- //循环当前SKU商品规格json
- foreach ($current_format as $current_k => $current_v) {
-// $temp++;
-
- //匹配规格项
- if ($current_v[ 'spec_id' ] == $sku_v[ 'spec_id' ]) {
-
- //循环规格值
- foreach ($sku_v[ 'value' ] as $sku_value_k => $sku_value_v) {
-// $temp++;
-
- //匹配规格值id
- if ($current_v[ 'spec_value_id' ] == $sku_value_v[ 'spec_value_id' ]) {
- $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'selected' ] = true;
- $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'sku_id' ] = $v[ 'sku_id' ];
- $selected_data[] = $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ];
- break;
- }
- }
-
- }
-
- }
- }
-
- //2、找出未选中的规格/规格值json
- foreach ($sku_format as $sku_k => $sku_v) {
-// $temp++;
-
- foreach ($sku_v[ 'value' ] as $sku_value_k => $sku_value_v) {
-// $temp++;
-
- if (!isset($sku_value_v[ 'selected' ])) {
-
- $refer_data = [];//参考已选中的规格/规格值json
- $refer_data[] = $sku_value_v;
-
-// 根据已选中的规格值进行参考
- foreach ($selected_data as $selected_k => $selected_v) {
-// $temp++;
-// 排除自身,然后进行参考
- if ($selected_v[ 'spec_id' ] != $sku_value_v[ 'spec_id' ]) {
- $refer_data[] = $selected_v;
- }
- }
-
- foreach ($sku_list as $again_k => $again_v) {
-// $temp++;
-
- //排除当前SKU商品
- if ($again_v[ 'sku_id' ] != $v[ 'sku_id' ]) {
-
- $current_format_again = json_decode($again_v[ 'sku_spec_format' ], true);
- $count = count($current_format_again);//规格总数量
- $curr_count = 0;//当前匹配规格数量
-
- //循环当前SKU商品规格json
- foreach ($current_format_again as $current_again_k => $current_again_v) {
-// $temp++;
-
- foreach ($refer_data as $fan_k => $fan_v) {
-// $temp++;
-
- if ($current_again_v[ 'spec_value_id' ] == $fan_v[ 'spec_value_id' ]) {
- $curr_count++;
- }
- }
-
- }
-
-// 匹配数量跟规格总数一致表示匹配成功
- if ($curr_count == $count) {
- $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'selected' ] = false;
- $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'sku_id' ] = $again_v[ 'sku_id' ];
- break;
- }
- }
-
- }
-
- //没有匹配到规格值,则禁用
- if (!isset($sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'selected' ])) {
- $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'disabled' ] = false;
- }
-
- }
- }
- }
-
-// var_dump($sku_format);
-// var_dump("=========");
- //修改ns_goods_sku表表中的goods_spec_format字段,将$sku_format值传入
- model('goods_sku')->update([ 'goods_spec_format' => json_encode($sku_format) ], [ [ 'sku_id', '=', $v[ 'sku_id' ] ] ]);
-
- }
-
-// var_dump("性能:" . $temp);
-
- }
-
- }
-
- /************************************************************************* 购买的虚拟产品 start *******************************************************************/
- /**
- * 生成购买的虚拟产品
- * @param $site_id
- * @param $order_id
- * @param $order_no
- * @param $sku_id
- * @param $sku_name
- * @param $code
- * @param $member_id
- * @param $sku_image
- */
- public function addGoodsVirtual($site_id, $goods_id, $sku_id, $data)
- {
- if (is_array($data) && count($data)) {
- $virtual_goods = [];
- foreach ($data as $carmichael_item) {
- $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
- $card = explode(' ', $carmichael_item);
- $card_arr = [
- 'cardno' => $card[ 0 ] ?? '',
- 'password' => $card[ 1 ] ?? ''
- ];
- $virtual_goods[] = [
- 'site_id' => $site_id,
- 'sku_id' => $sku_id,
- 'card_info' => json_encode($card_arr),
- 'goods_id' => $goods_id
- ];
- }
- model("goods_virtual")->startTrans();
- try {
- $res = model("goods_virtual")->addList($virtual_goods);
-// model('goods')->setInc([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $site_id ] ], 'goods_stock', count($virtual_goods)); // 增加商品总库存
-// model('goods_sku')->setInc([ [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $site_id ] ], 'stock', count($virtual_goods)); // 增加sku库存
- //同步计算卡密库存数据
- $this->statisticsStock($goods_id);
- model("goods_virtual")->commit();
- return $this->success($res);
- } catch (\Exception $e) {
- model("goods_virtual")->rollback();
- return $this->error('', $e->getMessage());
- }
- } else {
- return $this->error('', '请输入要添加的卡密数据');
- }
- }
-
- /**
- * 编辑卡密数据
- * @param $data
- * @param $condition
- * @return array
- */
- public function updateGoodsVirtual($data, $condition)
- {
- $res = model("goods_virtual")->update($data, $condition);
- return $this->success();
- }
-
- /**
- * 删除
- * @param $condition
- */
- public function deleteGoodsVirtual($condition)
- {
- $res = model("goods_virtual")->delete($condition);
- if ($res === false)
- return $this->error();
-
- $check_condition = array_column($condition, 2, 0);
- $goods_id = $check_condition[ 'goods_id' ] ?? 0;
- if ($goods_id) $this->statisticsStock($goods_id);
-
- return $this->success();
- }
-
-
- /**
- * 虚拟商品详情
- * @param $condition
- */
- public function getVirtualGoodsInfo($condition, $field = "*")
- {
- $info = model('goods_virtual')->getInfo($condition, $field);
- return $this->success($info);
- }
-
- /**
- * 获取虚拟商品分页列表
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function getVirtualGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'id desc', $field = '*', $alias = 'a', $join = null)
- {
- $list = model('goods_virtual')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
- return $this->success($list);
- }
-
- /**
- * 卡券数量
- * @param $condition
- */
- public function getVirtualGoodsCount($condition, $field = "*")
- {
- $count = model('goods_virtual')->getCount($condition, $field);
- return $this->success($count);
- }
- /************************************************************************* 购买的虚拟产品 end *******************************************************************/
-
- /**
- * 从excel中读取卡密数据
- * @param $path
- */
- public function importData($path)
- {
- $PHPReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
- //载入文件
- $PHPExcel = $PHPReader->load($path);
-
- //获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推
- $currentSheet = $PHPExcel->getSheet(0);
-
- //获取总行数
- $allRow = $currentSheet->getHighestRow();
-
- if ($allRow < 2) {
- return $this->error('', '导入了一个空文件');
- }
- $data = [];
- for ($i = 2; $i <= $allRow; $i++) {
- //卡号
- $cardno = $PHPExcel->getActiveSheet()->getCell('A' . $i)->getValue();
- //卡号
- $password = $PHPExcel->getActiveSheet()->getCell('B' . $i)->getValue();
- $data[] = $cardno . ' ' . $password;
- }
- return $this->success(implode("\n", $data));
- }
-
- /**
- * 重新统计库存
- * @param $goods_id
- */
- public function statisticsStock($goods_id)
- {
- try {
- model('goods_sku')->startTrans();
- $goods_sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], 'sku_id,goods_class,site_id');
- $goods_sku_ids = array_column($goods_sku_list, 'sku_id');
- // 先删除已不存在的sku
- model('goods_virtual')->delete([ [ 'order_id', '=', 0 ], [ 'goods_id', '=', $goods_id ], [ 'sku_id', 'not in', $goods_sku_ids ] ]);
- // 重新统计sku的库存
-
- $site_id = 0;
- $stock_sku_list = [];
- foreach ($goods_sku_list as $v) {
- $site_id = $v[ 'site_id' ];
- $sku_id = $v[ 'sku_id' ];
- $sku_stock = model('goods_virtual')->getCount([ [ 'order_id', '=', 0 ], [ 'goods_id', '=', $goods_id ], [ 'sku_id', '=', $sku_id ] ]);
-// model('goods_sku')->update([ 'stock' => $sku_stock ], [ [ 'goods_id', '=', $goods_id ], [ 'sku_id', '=', $sku_id ] ]);
- $stock_sku_list[] = [ 'sku_id' => $sku_id, 'stock' => $sku_stock, 'goods_class' => $v[ 'goods_class' ] ];
- }
- //设置库存
- $goods_stock_model = new GoodsStock();
- $result = $goods_stock_model->changeGoodsStock([
- 'site_id' => $site_id,
- 'goods_sku_list' => $stock_sku_list
- ]);
- // 重新统计spu的库存
-// $goods_stock = model('goods_sku')->getSum([ [ 'goods_id', '=', $goods_id ] ], 'stock');
-// model('goods')->update([ 'goods_stock' => $goods_stock ], [ [ 'goods_id', '=', $goods_id ] ]);
- model('goods_sku')->commit();
- } catch (\Exception $e) {
- model('goods_sku')->rollback();
- }
- }
-
- /**
- * 商品导入
- * @param $goods_data
- * @param $site_id
- * @return array
- */
- public function importGoods($goods_data, $site_id)
- {
- try {
- if (empty($goods_data[ 'goods_name' ])) return $this->error('', '商品名称不能为空');
- if (empty($goods_data[ 'goods_image' ])) return $this->error('', '商品主图不能为空');
- if (empty($goods_data[ 'category_1' ]) && empty($goods_data[ 'category_2' ]) && empty($goods_data[ 'category_3' ])) return $this->error('', '商品分类不能为空');
-
- // 处理商品分类
- $category_id = '';
- $category_json = [];
- if (!empty($goods_data[ 'category_3' ])) {
- $category_info = model('goods_category')->getInfo([ [ 'level', '=', 3 ], [ 'site_id', '=', $site_id ], [ 'category_full_name', '=', "{$goods_data['category_1']}/{$goods_data['category_2']}/{$goods_data['category_3']}" ] ], 'category_id_1,category_id_2,category_id_3');
- if (!empty($category_info)) {
- $category_id = "{$category_info['category_id_1']},{$category_info['category_id_2']},{$category_info['category_id_3']}";
- }
- }
- if (!empty($goods_data[ 'category_2' ]) && empty($category_id)) {
- $category_info = model('goods_category')->getInfo([ [ 'level', '=', 2 ], [ 'site_id', '=', $site_id ], [ 'category_full_name', '=', "{$goods_data['category_1']}/{$goods_data['category_2']}" ] ], 'category_id_1,category_id_2');
- if (!empty($category_info)) {
- $category_id = "{$category_info['category_id_1']},{$category_info['category_id_2']}";
- }
- }
- if (!empty($goods_data[ 'category_1' ]) && empty($category_id)) {
- $category_info = model('goods_category')->getInfo([ [ 'level', '=', 1 ], [ 'site_id', '=', $site_id ], [ 'category_name', '=', "{$goods_data['category_1']}" ] ], 'category_id_1');
- if (!empty($category_info)) {
- $category_id = "{$category_info['category_id_1']}";
- }
- }
- if (empty($category_id)) return $this->error('', '未找到所填商品分类');
- $category_json = [ $category_id ];
-
- $sku_data = [];
- $goods_spec_format = [];
- $tag = 0;
- // 处理sku数据
- if (isset($goods_data[ 'sku' ])) {
- foreach ($goods_data[ 'sku' ] as $sku_item) {
- if (empty($sku_item[ 'sku_data' ])) return $this->error('', '规格数据不能为空');
-
- $spec_name = '';
- $spec_data = explode(';', $sku_item[ 'sku_data' ]);
-
- $sku_spec_format = [];
- foreach ($spec_data as $item) {
- $spec_item = explode(':', $item);
- $spec_name .= ' ' . $spec_item[ 1 ];
-
- // 规格项
- $spec_index = array_search($spec_item[ 0 ], array_column($goods_spec_format, 'spec_name'));
- if (empty($goods_spec_format) || $spec_index === false) {
- $spec = [
- 'spec_id' => -( $tag + getMillisecond() ),
- 'spec_name' => $spec_item[ 0 ],
- 'value' => []
- ];
- $goods_spec_format[] = $spec;
- $tag++;
- } else {
- $spec = $goods_spec_format[ $spec_index ];
- }
- // 规格值
- $spec_index = array_search($spec_item[ 0 ], array_column($goods_spec_format, 'spec_name'));
- $spec_value_index = array_search($spec_item[ 1 ], array_column($spec[ 'value' ], 'spec_value_name'));
- if (empty($spec[ 'value' ]) || $spec_value_index === false) {
- $spec_value = [
- 'spec_id' => $spec[ 'spec_id' ],
- 'spec_name' => $spec[ 'spec_name' ],
- 'spec_value_id' => -( $tag + getMillisecond() ),
- 'spec_value_name' => $spec_item[ 1 ],
- 'image' => '',
- ];
- $goods_spec_format[ $spec_index ][ 'value' ][] = $spec_value;
- $tag++;
- } else {
- $spec_value = $spec[ 'value' ][ $spec_value_index ];
- }
-
- $sku_spec_format[] = [
- 'spec_id' => $spec[ 'spec_id' ],
- 'spec_name' => $spec[ 'spec_name' ],
- 'spec_value_id' => $spec_value[ 'spec_value_id' ],
- 'spec_value_name' => $spec_value[ 'spec_value_name' ],
- 'image' => '',
- ];
- }
-
- $sku_images_arr = explode(',', $sku_item[ 'sku_image' ]);
-
- $sku_temp = [
- 'spec_name' => trim($spec_name),
- 'sku_no' => $sku_item[ 'sku_code' ],
- 'sku_spec_format' => $sku_spec_format,
- 'price' => $sku_item[ 'price' ],
- 'market_price' => $sku_item[ 'market_price' ],
- 'cost_price' => $sku_item[ 'cost_price' ],
- 'stock_alarm' => $sku_item[ 'stock_alarm' ],
- 'sku_image' => empty($sku_item[ 'sku_image' ]) ? '' : $sku_images_arr[ 0 ],
- 'sku_images' => empty($sku_item[ 'sku_image' ]) ? '' : $sku_item[ 'sku_image' ],
- 'sku_images_arr' => empty($sku_item[ 'sku_image' ]) ? [] : $sku_images_arr,
- 'is_default' => 0,
- 'carmichael' => empty($sku_item[ 'carmichael' ]) ? [] : explode("\n", $sku_item[ 'carmichael' ])
- ];
-
- $sku_data[] = $sku_temp;
- }
- } else {
- $goods_img = explode(',', $goods_data[ 'goods_image' ]);
- $sku_data = [
- [
- 'sku_id' => 0,
- 'sku_name' => $goods_data[ 'goods_name' ],
- 'spec_name' => '',
- 'sku_spec_format' => '',
- 'price' => empty($goods_data[ 'price' ]) ? 0 : $goods_data[ 'price' ],
- 'market_price' => empty($goods_data[ 'market_price' ]) ? 0 : $goods_data[ 'market_price' ],
- 'cost_price' => empty($goods_data[ 'cost_price' ]) ? 0 : $goods_data[ 'cost_price' ],
- 'sku_no' => $goods_data[ 'goods_code' ],
- 'stock_alarm' => empty($goods_data[ 'stock_alarm' ]) ? 0 : $goods_data[ 'stock_alarm' ],
- 'sku_image' => $goods_img[ 0 ],
- 'sku_images' => $goods_data[ 'goods_image' ],
- 'carmichael' => empty($goods_data[ 'carmichael' ]) ? [] : explode("\n", $goods_data[ 'carmichael' ])
- ]
- ];
- }
-
- if (count($goods_spec_format) > 4) return $this->error('', '最多支持四种规格项');
-
- $data = [
- 'goods_name' => $goods_data[ 'goods_name' ],// 商品名称,
- 'goods_attr_class' => '',// 商品类型id,
- 'goods_attr_name' => '',// 商品类型名称,
- 'site_id' => $site_id,
- 'category_id' => ',' . $category_id . ',',
- 'category_json' => json_encode($category_json),
- 'goods_image' => $goods_data[ 'goods_image' ],// 商品主图路径
- 'goods_content' => '',// 商品详情
- 'goods_state' => 0, //$goods_data['goods_state'] == 1 || $goods_data['goods_state'] == '是' ? 1 : 0,// 商品状态(1.正常0下架)
- 'price' => empty($goods_data[ 'price' ]) ? 0 : $goods_data[ 'price' ],// 商品价格(取第一个sku)
- 'market_price' => empty($goods_data[ 'market_price' ]) ? 0 : $goods_data[ 'market_price' ],// 市场价格(取第一个sku)
- 'cost_price' => empty($goods_data[ 'cost_price' ]) ? 0 : $goods_data[ 'cost_price' ],// 成本价(取第一个sku)
- 'sku_no' => $goods_data[ 'goods_code' ],// 商品sku编码
- 'goods_stock_alarm' => empty($goods_data[ 'goods_stock_alarm' ]) ? 0 : $goods_data[ 'goods_stock_alarm' ],// 库存预警
- 'goods_spec_format' => empty($goods_spec_format) ? '' : json_encode($goods_spec_format, JSON_UNESCAPED_UNICODE),// 商品规格格式
- 'goods_attr_format' => '',// 商品参数格式
- 'introduction' => $goods_data[ 'introduction' ],// 促销语
- 'keywords' => $goods_data[ 'keywords' ],// 关键词
- 'unit' => $goods_data[ 'unit' ],// 单位
- 'sort' => '',// 排序,
- 'qr_id' => empty($goods_data[ 'qr_id' ]) ? 0 : $goods_data[ 'qr_id' ],// 社群二维码id
- 'template_id' => empty($goods_data[ 'template_id' ]) ? 0 : $goods_data[ 'template_id' ],// 海报id
- 'is_limit' => empty($goods_data[ 'is_limit' ]) ? 0 : $goods_data[ 'is_limit' ],// 是否限购
- 'limit_type' => empty($goods_data[ 'limit_type' ]) ? 0 : $goods_data[ 'limit_type' ],// 限购类型
- 'video_url' => '',// 视频
- 'goods_sku_data' => json_encode($sku_data, JSON_UNESCAPED_UNICODE),// SKU商品数据
- 'goods_service_ids' => '',// 商品服务id集合
- 'label_id' => '',// 商品分组id
- 'virtual_sale' => 0,// 虚拟销量
- 'max_buy' => 0,// 限购
- 'min_buy' => 0,// 起售
- 'recommend_way' => 0, // 推荐方式,1:新品,2:精品,3;推荐
- 'timer_on' => 0,//定时上架
- 'timer_off' => 0,//定时下架
- 'brand_id' => 0,
- 'is_consume_discount' => $goods_data[ 'is_consume_discount' ] == 1 || $goods_data[ 'is_consume_discount' ] == '是' ? 1 : 0, //是否参与会员折扣
- ];
-
- $res = $this->addGoods($data);
- return $res;
- } catch (\Exception $e) {
- return $this->error('', $e->getMessage());
- }
- }
-
- /**
- * 检测商品是否存在未完成的订单
- * @param $params
- * @return array
- */
- public function checkGoodsIsExistsOrder($params)
- {
- $condition = [
- [ 'og.site_id', '=', $params[ 'site_id' ] ],
- [ 'og.goods_id', '=', $params[ 'goods_id' ] ],
- [ 'o.order_status', 'not in', [ -1, 10 ] ] // 排除订单状态 -1:已关闭,10:已完成
- ];
-
- if (!empty($params[ 'sku_id' ])) {
- $condition[] = [ 'og.sku_id', 'in', $params[ 'sku_id' ] ];
- }
-
- $join = [
- [ 'order o', 'o.order_id = og.order_id', 'left' ]
- ];
-
- $order_model = new OrderCommon();
- $res = $order_model->getOrderGoodsCount($condition, 'order_goods_id', 'og', $join);
- if ($res[ 'data' ] > 0) {
- return $this->error('', '该商品存在未完成的订单,无法删除规格项');
- }
- return $this->success();
-
- }
-
+ 3, 'name' => '电子卡密' );
+
+ private $goods_state = array (
+ 1 => '销售中',
+ 0 => '仓库中'
+ );
+
+ public function getGoodsState()
+ {
+ return $this->goods_state;
+ }
+
+ public function getGoodsClass()
+ {
+ return $this->goods_class;
+ }
+
+ /**
+ * 商品添加
+ * @param $data
+ */
+ public function addGoods($data)
+ {
+ model('goods')->startTrans();
+
+ try {
+
+ if (!empty($data[ 'goods_attr_format' ])) {
+
+ $goods_attr_format = json_decode($data[ 'goods_attr_format' ], true);
+ $keys = array_column($goods_attr_format, 'sort');
+ if (!empty($keys)) {
+ array_multisort($keys, SORT_ASC, SORT_NUMERIC, $goods_attr_format);
+ $data[ 'goods_attr_format' ] = json_encode($goods_attr_format);
+ }
+ }
+
+ $goods_image = $data[ 'goods_image' ];
+ $first_image = explode(",", $goods_image)[ 0 ];
+
+ //SKU商品数据
+ if (!empty($data[ 'goods_sku_data' ])) {
+ $data[ 'goods_sku_data' ] = json_decode($data[ 'goods_sku_data' ], true);
+ }
+
+ //获取标签名称
+ $label_name = '';
+ if ($data[ 'label_id' ]) {
+ $label_info = model('goods_label')->getInfo([ [ 'id', '=', $data[ 'label_id' ] ] ], 'label_name');
+ $label_name = $label_info[ 'label_name' ] ?? '';
+ }
+ $brand_name = '';
+ if ($data[ 'brand_id' ]) {
+ $brand_info = model('goods_brand')->getInfo([ [ 'brand_id', '=', $data[ 'brand_id' ] ] ], 'brand_name');
+ $brand_name = $brand_info[ 'brand_name' ] ?? '';
+ }
+ $goods_data = array (
+ 'goods_image' => $goods_image,
+ 'price' => $data[ 'goods_sku_data' ][ 0 ][ 'price' ],
+ 'market_price' => $data[ 'goods_sku_data' ][ 0 ][ 'market_price' ],
+ 'cost_price' => $data[ 'goods_sku_data' ][ 0 ][ 'cost_price' ],
+ 'goods_spec_format' => $data[ 'goods_spec_format' ],
+ 'category_id' => $data[ 'category_id' ],
+ 'category_json' => $data[ 'category_json' ],
+ 'label_id' => $data[ 'label_id' ],
+ 'label_name' => $label_name,
+ 'timer_on' => $data[ 'timer_on' ],
+ 'timer_off' => $data[ 'timer_off' ],
+ 'sale_show' => $data[ 'sale_show' ] ?? 1,
+ 'stock_show' => $data[ 'stock_show' ] ?? 1,
+ 'market_price_show' => $data[ 'market_price_show' ] ?? 1,
+ 'barrage_show' => $data[ 'barrage_show' ] ?? 1,
+ 'is_consume_discount' => $data[ 'is_consume_discount' ],
+ );
+
+ $common_data = array (
+ 'goods_name' => $data[ 'goods_name' ],
+ 'goods_class' => $this->goods_class[ 'id' ],
+ 'goods_class_name' => $this->goods_class[ 'name' ],
+ 'goods_attr_class' => $data[ 'goods_attr_class' ],
+ 'goods_attr_name' => $data[ 'goods_attr_name' ],
+ 'is_limit' => $data[ 'is_limit' ] ?? 0,
+ 'limit_type' => $data[ 'limit_type' ] ?? 1,
+ 'site_id' => $data[ 'site_id' ],
+ 'goods_content' => $data[ 'goods_content' ],
+ 'goods_state' => $data[ 'goods_state' ],
+ 'goods_stock_alarm' => $data[ 'goods_stock_alarm' ],
+ 'is_virtual' => 1,
+ 'virtual_indate' => 0,
+ 'goods_attr_format' => $data[ 'goods_attr_format' ],
+ 'introduction' => $data[ 'introduction' ],
+ 'keywords' => $data[ 'keywords' ],
+ 'unit' => $data[ 'unit' ],
+ 'brand_id' => $data[ 'brand_id' ],//品牌id
+ 'brand_name' => $brand_name,//品牌名称
+ 'video_url' => $data[ 'video_url' ],
+ 'sort' => $data[ 'sort' ],
+ 'goods_service_ids' => $data[ 'goods_service_ids' ],
+ 'create_time' => time(),
+ 'virtual_sale' => $data[ 'virtual_sale' ],
+ 'max_buy' => $data[ 'max_buy' ],
+ 'min_buy' => $data[ 'min_buy' ],
+ 'recommend_way' => $data[ 'recommend_way' ],
+ 'qr_id' => $data[ 'qr_id' ] ?? 0,
+ 'template_id' => $data[ 'template_id' ] ?? 0,
+ 'form_id' => $data[ 'form_id' ] ?? 0,
+ 'sale_channel' => $data[ 'sale_channel' ] ?? 'all',
+ 'sale_store' => $data[ 'sale_store' ] ?? 'all',
+ 'supplier_id' => $data[ 'supplier_id' ] ?? 0
+ );
+
+ $goods_id = model('goods')->add(array_merge($goods_data, $common_data));
+
+ $goods_stock = 0;
+
+ //添加sku商品
+ foreach ($data[ 'goods_sku_data' ] as $item) {
+// $carmichael = 0;
+// if (isset($item[ 'carmichael' ])) {
+// if (is_array($item[ 'carmichael' ])) {
+// $carmichael = count($item[ 'carmichael' ]);
+// }
+// }
+ $sku_data = array (
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'spec_name' => $item[ 'spec_name' ],
+ 'sku_no' => $item[ 'sku_no' ],
+ 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
+ 'price' => $item[ 'price' ],
+ 'market_price' => $item[ 'market_price' ],
+ 'cost_price' => $item[ 'cost_price' ],
+ 'discount_price' => $item[ 'price' ],//sku折扣价(默认等于单价)
+// 'stock' => $carmichael,
+ 'stock_alarm' => $item[ 'stock_alarm' ],
+ 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
+ 'sku_images' => $item[ 'sku_images' ],
+ 'goods_id' => $goods_id,
+ 'is_default' => $item[ 'is_default' ] ?? 0,
+ 'is_consume_discount' => $data[ 'is_consume_discount' ],
+ 'site_id' => $data[ 'site_id' ]
+ );
+ $sku_data = array_merge($sku_data, $common_data);
+ $sku_id = model('goods_sku')->add($sku_data);
+
+ // 添加到虚拟商品表
+ if (isset($item[ 'carmichael' ])) {
+ if (is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
+ $goods_stock += count($item[ 'carmichael' ]);
+ $virtual_goods = [];
+ foreach ($item[ 'carmichael' ] as $carmichael_item) {
+ $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
+ $card = explode(' ', $carmichael_item);
+ $card_arr = [
+ 'cardno' => $card[ 0 ] ?? '',
+ 'password' => $card[ 1 ] ?? ''
+ ];
+ $virtual_goods[] = [
+ 'site_id' => $data[ 'site_id' ],
+ 'sku_id' => $sku_id,
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'card_info' => json_encode($card_arr),
+ 'goods_id' => $goods_id
+ ];
+ }
+ model('goods_virtual')->addList($virtual_goods);
+ }
+ }
+ }
+
+ // 赋值第一个商品sku_id
+ $first_info = model('goods_sku')->getFirstData([ 'goods_id' => $goods_id ], 'sku_id', 'is_default desc,sku_id asc');
+ model('goods')->update([ 'sku_id' => $first_info[ 'sku_id' ] ], [ [ 'goods_id', '=', $goods_id ] ]);
+
+ if (!empty($data[ 'goods_spec_format' ])) {
+ // 刷新SKU商品规格项 / 规格值JSON字符串
+ $this->dealGoodsSkuSpecFormat($goods_id, $data[ 'goods_spec_format' ]);
+ }
+
+ $cron = new Cron();
+ //定时上下架
+ if ($goods_data[ 'timer_on' ] > 0) {
+ $cron->addCron(1, 0, "商品定时上架", "CronGoodsTimerOn", $goods_data[ 'timer_on' ], $goods_id);
+ }
+ if ($goods_data[ 'timer_off' ] > 0) {
+ $cron->addCron(1, 0, "商品定时下架", "CronGoodsTimerOff", $goods_data[ 'timer_off' ], $goods_id);
+ }
+
+ //添加统计
+ $stat = new Stat();
+// $stat->addShopStat([ 'add_goods_count' => 1, 'site_id' => $data[ 'site_id' ] ]);
+ $stat->switchStat([ 'type' => 'add_goods', 'data' => [ 'add_goods_count' => 1, 'site_id' => $data[ 'site_id' ] ] ]);
+
+ //同步计算卡密库存数据
+ $this->statisticsStock($goods_id);
+ model('goods')->commit();
+
+ return $this->success($goods_id);
+ } catch (\Exception $e) {
+ model('goods')->rollback();
+ return $this->error($e->getMessage());
+ }
+ }
+
+ /**
+ * 商品编辑
+ * @param $data
+ */
+ public function editGoods($data)
+ {
+
+ model('goods')->startTrans();
+
+ try {
+
+ if (!empty($data[ 'goods_attr_format' ])) {
+
+ $goods_attr_format = json_decode($data[ 'goods_attr_format' ], true);
+ $keys = array_column($goods_attr_format, 'sort');
+ if (!empty($keys)) {
+ array_multisort($keys, SORT_ASC, SORT_NUMERIC, $goods_attr_format);
+ $data[ 'goods_attr_format' ] = json_encode($goods_attr_format);
+ }
+ }
+
+ $goods_id = $data[ 'goods_id' ];
+ $goods_image = $data[ 'goods_image' ];
+ $first_image = explode(",", $goods_image)[ 0 ];
+
+ //SKU商品数据
+ if (!empty($data[ 'goods_sku_data' ])) {
+ $data[ 'goods_sku_data' ] = json_decode($data[ 'goods_sku_data' ], true);
+ }
+
+ //获取标签名称
+ $label_name = '';
+ if ($data[ 'label_id' ]) {
+ $label_info = model('goods_label')->getInfo([ [ 'id', '=', $data[ 'label_id' ] ] ], 'label_name');
+ $label_name = $label_info[ 'label_name' ] ?? '';
+ }
+ $brand_name = '';
+ if ($data[ 'brand_id' ]) {
+ $brand_info = model('goods_brand')->getInfo([ [ 'brand_id', '=', $data[ 'brand_id' ] ] ], 'brand_name');
+ $brand_name = $brand_info[ 'brand_name' ] ?? '';
+ }
+ $goods_data = array (
+ 'goods_image' => $goods_image,
+ 'price' => $data[ 'goods_sku_data' ][ 0 ][ 'price' ],
+ 'market_price' => $data[ 'goods_sku_data' ][ 0 ][ 'market_price' ],
+ 'cost_price' => $data[ 'goods_sku_data' ][ 0 ][ 'cost_price' ],
+ 'goods_spec_format' => $data[ 'goods_spec_format' ],
+ 'category_id' => $data[ 'category_id' ],
+ 'category_json' => $data[ 'category_json' ],
+ 'label_id' => $data[ 'label_id' ],
+ 'label_name' => $label_name,
+ 'timer_on' => $data[ 'timer_on' ],
+ 'timer_off' => $data[ 'timer_off' ],
+ 'sale_show' => $data[ 'sale_show' ],
+ 'stock_show' => $data[ 'stock_show' ],
+ 'market_price_show' => $data[ 'market_price_show' ],
+ 'barrage_show' => $data[ 'barrage_show' ],
+ 'is_consume_discount' => $data[ 'is_consume_discount' ],
+ );
+
+ $common_data = array (
+ 'goods_name' => $data[ 'goods_name' ],
+ 'goods_class' => $this->goods_class[ 'id' ],
+ 'goods_class_name' => $this->goods_class[ 'name' ],
+ 'goods_attr_class' => $data[ 'goods_attr_class' ],
+ 'goods_attr_name' => $data[ 'goods_attr_name' ],
+ 'is_limit' => $data[ 'is_limit' ] ?? 0,
+ 'limit_type' => $data[ 'limit_type' ] ?? 1,
+ 'site_id' => $data[ 'site_id' ],
+ 'goods_content' => $data[ 'goods_content' ],
+ 'goods_state' => $data[ 'goods_state' ],
+ 'goods_stock_alarm' => $data[ 'goods_stock_alarm' ],
+ 'is_virtual' => 1,
+ 'virtual_indate' => 0,
+ 'goods_attr_format' => $data[ 'goods_attr_format' ],
+ 'introduction' => $data[ 'introduction' ],
+ 'keywords' => $data[ 'keywords' ],
+ 'unit' => $data[ 'unit' ],
+ 'video_url' => $data[ 'video_url' ],
+ 'sort' => $data[ 'sort' ],
+ 'goods_service_ids' => $data[ 'goods_service_ids' ],
+ 'brand_id' => $data[ 'brand_id' ],//品牌id
+ 'brand_name' => $brand_name,//品牌名称
+ 'modify_time' => time(),
+ 'virtual_sale' => $data[ 'virtual_sale' ],
+ 'max_buy' => $data[ 'max_buy' ],
+ 'min_buy' => $data[ 'min_buy' ],
+ 'recommend_way' => $data[ 'recommend_way' ],
+ 'qr_id' => $data[ 'qr_id' ] ?? 0,
+ 'template_id' => $data[ 'template_id' ] ?? 0,
+ 'form_id' => $data[ 'form_id' ] ?? 0,
+ 'sale_channel' => $data[ 'sale_channel' ] ?? 'all',
+ 'sale_store' => $data[ 'sale_store' ] ?? 'all',
+ 'supplier_id' => $data[ 'supplier_id' ] ?? 0
+ );
+
+ model('goods')->update(array_merge($goods_data, $common_data), [ [ 'goods_id', '=', $goods_id ], [ 'goods_class', '=', $this->goods_class[ 'id' ] ] ]);
+
+ $goods_stock = 0;
+
+ // 如果只编辑价格库存就是修改,如果添加规格项/值就需要重新生成
+ if (!empty($data[ 'goods_sku_data' ][ 0 ][ 'sku_id' ])) {
+
+ if ($data[ 'spec_type_status' ] == 1) {
+ $sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], 'sku_id');
+ $sku_id_arr = array_column($sku_list, 'sku_id', 'sku_id');
+ //添加sku商品
+ foreach ($data[ 'goods_sku_data' ] as $item) {
+ $carmichael = 0;
+ if (isset($item[ 'carmichael' ])) {
+ if (is_array($item[ 'carmichael' ])) {
+ $carmichael = count($item[ 'carmichael' ]);
+ }
+ }
+ $sku_data = array (
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'spec_name' => $item[ 'spec_name' ],
+ 'sku_no' => $item[ 'sku_no' ],
+ 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
+ 'price' => $item[ 'price' ],
+ 'market_price' => $item[ 'market_price' ],
+ 'cost_price' => $item[ 'cost_price' ],
+ 'discount_price' => $item[ 'price' ],//sku折扣价(默认等于单价)
+// 'stock' => $carmichael,
+ 'stock_alarm' => $item[ 'stock_alarm' ],
+ 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
+ 'sku_images' => $item[ 'sku_images' ],
+ 'goods_id' => $goods_id,
+ 'is_default' => $item[ 'is_default' ] ?? 0,
+ 'is_consume_discount' => $data[ 'is_consume_discount' ]
+ );
+ $sku_data = array_merge($sku_data, $common_data);
+ if (!empty($item[ 'sku_id' ]) && in_array($item[ 'sku_id' ], $sku_id_arr)) {
+ $sku_id = $item[ 'sku_id' ];
+ model('goods_sku')->update($sku_data, [ [ 'sku_id', '=', $sku_id ] ]);
+ unset($sku_id_arr[ $sku_id ]);
+ } else {
+ $sku_id = model('goods_sku')->add($sku_data);
+ }
+
+ // 添加到虚拟商品表
+ if (isset($item[ 'carmichael' ])) {
+ if (is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
+ $goods_stock += count($item[ 'carmichael' ]);
+ $virtual_goods = [];
+ foreach ($item[ 'carmichael' ] as $carmichael_item) {
+ $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
+ $card = explode(' ', $carmichael_item);
+ $card_arr = [
+ 'cardno' => $card[ 0 ] ?? '',
+ 'password' => $card[ 1 ] ?? ''
+ ];
+ $virtual_goods[] = [
+ 'site_id' => $data[ 'site_id' ],
+ 'sku_id' => $sku_id,
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'card_info' => json_encode($card_arr),
+ 'goods_id' => $goods_id
+ ];
+ }
+ model('goods_virtual')->addList($virtual_goods);
+ }
+ }
+ }
+ //删除已经不存在的sku
+ if (!empty($sku_id_arr)) {
+ $check = $this->checkGoodsIsExistsOrder([ 'site_id' => $data[ 'site_id' ], 'goods_id' => $goods_id, 'sku_id' => implode(",", $sku_id_arr) ]);
+ if ($check[ 'code' ] < 0) {
+ model('goods')->rollback();
+ return $check;
+ }
+ model('goods_sku')->delete([ [ 'sku_id', 'in', $sku_id_arr ] ]);
+ }
+ } else {
+ $discount_model = new Discount();
+ $sku_id_arr = [];
+ foreach ($data[ 'goods_sku_data' ] as $item) {
+ $discount_info = [];
+ if (!empty($item[ 'sku_id' ])) {
+ $discount_info_result = $discount_model->getDiscountGoodsInfo([ [ 'pdg.sku_id', '=', $item[ 'sku_id' ] ], [ 'pd.status', '=', 1 ] ], 'id');
+ $discount_info = $discount_info_result[ 'data' ];
+ }
+
+ $carmichael = 0;
+ if (isset($item[ 'carmichael' ])) {
+ if (is_array($item[ 'carmichael' ])) {
+ $carmichael = count($item[ 'carmichael' ]);
+ }
+ }
+
+ $sku_data = array (
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'spec_name' => $item[ 'spec_name' ],
+ 'sku_no' => $item[ 'sku_no' ],
+ 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
+ 'price' => $item[ 'price' ],
+ 'market_price' => $item[ 'market_price' ],
+ 'cost_price' => $item[ 'cost_price' ],
+// 'stock' => $carmichael,
+ 'stock_alarm' => $item[ 'stock_alarm' ],
+ 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
+ 'sku_images' => $item[ 'sku_images' ],
+ 'goods_id' => $goods_id,
+ 'is_default' => $item[ 'is_default' ] ?? 0,
+ 'is_consume_discount' => $data[ 'is_consume_discount' ]
+ );
+ if (empty($discount_info)) {
+ $sku_data[ 'discount_price' ] = $item[ 'price' ];
+ }
+ if (!empty($item[ 'sku_id' ])) {
+ $sku_id = $item[ 'sku_id' ];
+ $sku_id_arr[] = $item[ 'sku_id' ];
+ model('goods_sku')->update(array_merge($sku_data, $common_data), [ [ 'sku_id', '=', $item[ 'sku_id' ] ], [ 'goods_class', '=', $this->goods_class[ 'id' ] ] ]);
+ } else {
+ $sku_id = model('goods_sku')->add(array_merge($sku_data, $common_data));
+ $sku_id_arr[] = $sku_id;
+ }
+
+ // 添加到虚拟商品表
+ if (isset($item[ 'carmichael' ])) {
+ if (is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
+ $goods_stock += count($item[ 'carmichael' ]);
+ $virtual_goods = [];
+ foreach ($item[ 'carmichael' ] as $carmichael_item) {
+ $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
+ $card = explode(' ', $carmichael_item);
+ $card_arr = [
+ 'cardno' => $card[ 0 ] ?? '',
+ 'password' => $card[ 1 ] ?? ''
+ ];
+ $virtual_goods[] = [
+ 'site_id' => $data[ 'site_id' ],
+ 'sku_id' => $sku_id,
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'card_info' => json_encode($card_arr),
+ 'goods_id' => $goods_id
+ ];
+ }
+ model('goods_virtual')->addList($virtual_goods);
+ }
+ }
+ }
+
+ // 移除不存在的商品SKU
+ $sku_id_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], 'sku_id');
+ $sku_id_list = array_column($sku_id_list, 'sku_id');
+ foreach ($sku_id_list as $k => $v) {
+ foreach ($sku_id_arr as $ck => $cv) {
+ if ($v == $cv) {
+ unset($sku_id_list[ $k ]);
+ }
+ }
+ }
+
+ $sku_id_list = array_values($sku_id_list);
+ if (!empty($sku_id_list)) {
+ $check = $this->checkGoodsIsExistsOrder([ 'site_id' => $data[ 'site_id' ], 'goods_id' => $goods_id, 'sku_id' => implode(",", $sku_id_list) ]);
+ if ($check[ 'code' ] < 0) {
+ model('goods')->rollback();
+ return $check;
+ }
+ model('goods_sku')->delete([ [ 'sku_id', 'in', implode(",", $sku_id_list) ] ]);
+ }
+ }
+
+ } else {
+ $check = $this->checkGoodsIsExistsOrder([ 'site_id' => $data[ 'site_id' ], 'goods_id' => $goods_id ]);
+ if ($check[ 'code' ] < 0) {
+ model('goods')->rollback();
+ return $check;
+ }
+
+ model('goods_sku')->delete([ [ 'goods_id', '=', $goods_id ] ]);
+
+ $sku_arr = array ();
+ //添加sku商品
+ foreach ($data[ 'goods_sku_data' ] as $item) {
+ $sku_data = array (
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'spec_name' => $item[ 'spec_name' ],
+ 'sku_no' => $item[ 'sku_no' ],
+ 'sku_spec_format' => !empty($item[ 'sku_spec_format' ]) ? json_encode($item[ 'sku_spec_format' ]) : "",
+ 'price' => $item[ 'price' ],
+ 'market_price' => $item[ 'market_price' ],
+ 'cost_price' => $item[ 'cost_price' ],
+ 'discount_price' => $item[ 'price' ],//sku折扣价(默认等于单价)
+// 'stock' => $item[ 'stock' ],
+ 'stock_alarm' => $item[ 'stock_alarm' ],
+ 'sku_image' => !empty($item[ 'sku_image' ]) ? $item[ 'sku_image' ] : $first_image,
+ 'sku_images' => $item[ 'sku_images' ],
+ 'goods_id' => $goods_id,
+ 'is_default' => $item[ 'is_default' ] ?? 0,
+ 'is_consume_discount' => $data[ 'is_consume_discount' ]
+ );
+ $sku_data = array_merge($sku_data, $common_data);
+ $sku_id = model('goods_sku')->add($sku_data);
+
+ // 添加到虚拟商品表
+ if (isset($item[ 'carmichael' ]) && is_array($item[ 'carmichael' ]) && count($item[ 'carmichael' ])) {
+ $goods_stock += count($item[ 'carmichael' ]);
+ $virtual_goods = [];
+ foreach ($item[ 'carmichael' ] as $carmichael_item) {
+ $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
+ $card = explode(' ', $carmichael_item);
+ $card_arr = [
+ 'cardno' => $card[ 0 ] ?? '',
+ 'password' => $card[ 1 ] ?? ''
+ ];
+ $virtual_goods[] = [
+ 'site_id' => $data[ 'site_id' ],
+ 'sku_id' => $sku_id,
+ 'sku_name' => $data[ 'goods_name' ] . ' ' . $item[ 'spec_name' ],
+ 'card_info' => json_encode($card_arr),
+ 'goods_id' => $goods_id
+ ];
+ }
+ model('goods_virtual')->addList($virtual_goods);
+ }
+ }
+ }
+
+ // 赋值第一个商品sku_id
+ $first_info = model('goods_sku')->getFirstData([ 'goods_id' => $goods_id ], 'sku_id', 'is_default desc,sku_id asc');
+ model('goods')->update([ 'sku_id' => $first_info[ 'sku_id' ] ], [ [ 'goods_id', '=', $goods_id ] ]);
+
+ if (!empty($data[ 'goods_spec_format' ])) {
+ // 刷新SKU商品规格项 / 规格值JSON字符串
+ $this->dealGoodsSkuSpecFormat($goods_id, $data[ 'goods_spec_format' ]);
+ }
+
+ $cron = new Cron();
+ $cron->deleteCron([ [ 'event', '=', 'CronGoodsTimerOn' ], [ 'relate_id', '=', $goods_id ] ]);
+ $cron->deleteCron([ [ 'event', '=', 'CronGoodsTimerOff' ], [ 'relate_id', '=', $goods_id ] ]);
+ //定时上下架
+ if ($goods_data[ 'timer_on' ] > 0) {
+ $cron->addCron(1, 0, "商品定时上架", "CronGoodsTimerOn", $goods_data[ 'timer_on' ], $goods_id);
+ }
+ if ($goods_data[ 'timer_off' ] > 0) {
+ $cron->addCron(1, 0, "商品定时下架", "CronGoodsTimerOff", $goods_data[ 'timer_off' ], $goods_id);
+ }
+
+ $this->statisticsStock($goods_id);
+
+ model('goods')->commit();
+ return $this->success($goods_id);
+ } catch (\Exception $e) {
+ model('goods')->rollback();
+ return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
+ }
+ }
+
+ /**
+ * 获取商品详情
+ * @param $goods_id
+ * @return array
+ */
+ public function getGoodsDetail($goods_id, $site_id)
+ {
+ $info = model('goods')->getInfo([ [ 'is_delete', '=', 0 ], [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $site_id ], [ 'goods_class', '=', 3 ] ], "*");
+ $field = 'sku_id, sku_name,spec_name, sku_no, sku_spec_format, price, market_price, cost_price, discount_price, stock,
+ weight, volume, sku_image, sku_images, sort,member_price,fenxiao_price';
+ $sku_data = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], $field);
+
+ if (!empty($sku_data)) {
+ foreach ($sku_data as $k => $v) {
+ $sku_data[ $k ][ 'member_price' ] = $v[ 'member_price' ] == '' ? '' : json_decode($v[ 'member_price' ], true);
+ $sku_data[ $k ][ 'stock' ] = numberFormat($sku_data[ $k ][ 'stock' ]);
+ }
+ }
+ if (!empty($info)) {
+ if (isset($info[ 'goods_stock' ])) {
+ $info[ 'goods_stock' ] = numberFormat($info[ 'goods_stock' ]);
+ }
+ if (isset($info[ 'sale_num' ])) {
+ $info[ 'sale_num' ] = numberFormat($info[ 'sale_num' ]);
+ }
+ if (isset($info[ 'virtual_sale' ])) {
+ $info[ 'virtual_sale' ] = numberFormat($info[ 'virtual_sale' ]);
+ }
+ if (isset($info[ 'real_stock' ])) {
+ $info[ 'real_stock' ] = numberFormat($info[ 'real_stock' ]);
+ }
+ $info[ 'sku_data' ] = $sku_data;
+ }
+ return $this->success($info);
+ }
+
+ /**
+ * 刷新SKU商品规格项/规格值JSON字符串
+ * @param int $goods_id 商品id
+ * @param string $goods_spec_format 商品完整规格项/规格值json
+ */
+ private function dealGoodsSkuSpecFormat($goods_id, $goods_spec_format)
+ {
+ if (empty($goods_spec_format)) return;
+
+ $goods_spec_format = json_decode($goods_spec_format, true);
+
+ //根据goods_id查询sku商品列表,查询:sku_id、sku_spec_format 列
+ $sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ], [ 'sku_spec_format', '<>', '' ] ], 'sku_id,sku_spec_format', 'sku_id asc');
+ if (!empty($sku_list)) {
+
+// $temp = 0;//测试性能,勿删
+
+ //循环SKU商品列表
+ foreach ($sku_list as $k => $v) {
+// $temp++;
+
+ $sku_format = $goods_spec_format;//最终要存储的值
+ $current_format = json_decode($v[ 'sku_spec_format' ], true);//当前SKU商品规格值json
+
+ $selected_data = [];//已选规格/规格值json
+
+ //1、找出已选规格/规格值json
+
+ //循环完整商品规格json
+ foreach ($sku_format as $sku_k => $sku_v) {
+// $temp++;
+
+ //循环当前SKU商品规格json
+ foreach ($current_format as $current_k => $current_v) {
+// $temp++;
+
+ //匹配规格项
+ if ($current_v[ 'spec_id' ] == $sku_v[ 'spec_id' ]) {
+
+ //循环规格值
+ foreach ($sku_v[ 'value' ] as $sku_value_k => $sku_value_v) {
+// $temp++;
+
+ //匹配规格值id
+ if ($current_v[ 'spec_value_id' ] == $sku_value_v[ 'spec_value_id' ]) {
+ $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'selected' ] = true;
+ $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'sku_id' ] = $v[ 'sku_id' ];
+ $selected_data[] = $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ];
+ break;
+ }
+ }
+
+ }
+
+ }
+ }
+
+ //2、找出未选中的规格/规格值json
+ foreach ($sku_format as $sku_k => $sku_v) {
+// $temp++;
+
+ foreach ($sku_v[ 'value' ] as $sku_value_k => $sku_value_v) {
+// $temp++;
+
+ if (!isset($sku_value_v[ 'selected' ])) {
+
+ $refer_data = [];//参考已选中的规格/规格值json
+ $refer_data[] = $sku_value_v;
+
+// 根据已选中的规格值进行参考
+ foreach ($selected_data as $selected_k => $selected_v) {
+// $temp++;
+// 排除自身,然后进行参考
+ if ($selected_v[ 'spec_id' ] != $sku_value_v[ 'spec_id' ]) {
+ $refer_data[] = $selected_v;
+ }
+ }
+
+ foreach ($sku_list as $again_k => $again_v) {
+// $temp++;
+
+ //排除当前SKU商品
+ if ($again_v[ 'sku_id' ] != $v[ 'sku_id' ]) {
+
+ $current_format_again = json_decode($again_v[ 'sku_spec_format' ], true);
+ $count = count($current_format_again);//规格总数量
+ $curr_count = 0;//当前匹配规格数量
+
+ //循环当前SKU商品规格json
+ foreach ($current_format_again as $current_again_k => $current_again_v) {
+// $temp++;
+
+ foreach ($refer_data as $fan_k => $fan_v) {
+// $temp++;
+
+ if ($current_again_v[ 'spec_value_id' ] == $fan_v[ 'spec_value_id' ]) {
+ $curr_count++;
+ }
+ }
+
+ }
+
+// 匹配数量跟规格总数一致表示匹配成功
+ if ($curr_count == $count) {
+ $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'selected' ] = false;
+ $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'sku_id' ] = $again_v[ 'sku_id' ];
+ break;
+ }
+ }
+
+ }
+
+ //没有匹配到规格值,则禁用
+ if (!isset($sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'selected' ])) {
+ $sku_format[ $sku_k ][ 'value' ][ $sku_value_k ][ 'disabled' ] = false;
+ }
+
+ }
+ }
+ }
+
+// var_dump($sku_format);
+// var_dump("=========");
+ //修改ns_goods_sku表表中的goods_spec_format字段,将$sku_format值传入
+ model('goods_sku')->update([ 'goods_spec_format' => json_encode($sku_format) ], [ [ 'sku_id', '=', $v[ 'sku_id' ] ] ]);
+
+ }
+
+// var_dump("性能:" . $temp);
+
+ }
+
+ }
+
+ /************************************************************************* 购买的虚拟产品 start *******************************************************************/
+ /**
+ * 生成购买的虚拟产品
+ * @param $site_id
+ * @param $order_id
+ * @param $order_no
+ * @param $sku_id
+ * @param $sku_name
+ * @param $code
+ * @param $member_id
+ * @param $sku_image
+ */
+ public function addGoodsVirtual($site_id, $goods_id, $sku_id, $data)
+ {
+ if (is_array($data) && count($data)) {
+ $virtual_goods = [];
+ foreach ($data as $carmichael_item) {
+ $carmichael_item = htmlspecialchars(addslashes($carmichael_item));
+ $card = explode(' ', $carmichael_item);
+ $card_arr = [
+ 'cardno' => $card[ 0 ] ?? '',
+ 'password' => $card[ 1 ] ?? ''
+ ];
+ $virtual_goods[] = [
+ 'site_id' => $site_id,
+ 'sku_id' => $sku_id,
+ 'card_info' => json_encode($card_arr),
+ 'goods_id' => $goods_id
+ ];
+ }
+ model("goods_virtual")->startTrans();
+ try {
+ $res = model("goods_virtual")->addList($virtual_goods);
+// model('goods')->setInc([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $site_id ] ], 'goods_stock', count($virtual_goods)); // 增加商品总库存
+// model('goods_sku')->setInc([ [ 'sku_id', '=', $sku_id ], [ 'site_id', '=', $site_id ] ], 'stock', count($virtual_goods)); // 增加sku库存
+ //同步计算卡密库存数据
+ $this->statisticsStock($goods_id);
+ model("goods_virtual")->commit();
+ return $this->success($res);
+ } catch (\Exception $e) {
+ model("goods_virtual")->rollback();
+ return $this->error('', $e->getMessage());
+ }
+ } else {
+ return $this->error('', '请输入要添加的卡密数据');
+ }
+ }
+
+ /**
+ * 编辑卡密数据
+ * @param $data
+ * @param $condition
+ * @return array
+ */
+ public function updateGoodsVirtual($data, $condition)
+ {
+ $res = model("goods_virtual")->update($data, $condition);
+ return $this->success();
+ }
+
+ /**
+ * 删除
+ * @param $condition
+ */
+ public function deleteGoodsVirtual($condition)
+ {
+ $res = model("goods_virtual")->delete($condition);
+ if ($res === false)
+ return $this->error();
+
+ $check_condition = array_column($condition, 2, 0);
+ $goods_id = $check_condition[ 'goods_id' ] ?? 0;
+ if ($goods_id) $this->statisticsStock($goods_id);
+
+ return $this->success();
+ }
+
+
+ /**
+ * 虚拟商品详情
+ * @param $condition
+ */
+ public function getVirtualGoodsInfo($condition, $field = "*")
+ {
+ $info = model('goods_virtual')->getInfo($condition, $field);
+ return $this->success($info);
+ }
+
+ /**
+ * 获取虚拟商品分页列表
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function getVirtualGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'id desc', $field = '*', $alias = 'a', $join = null)
+ {
+ $list = model('goods_virtual')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
+ return $this->success($list);
+ }
+
+ /**
+ * 卡券数量
+ * @param $condition
+ */
+ public function getVirtualGoodsCount($condition, $field = "*")
+ {
+ $count = model('goods_virtual')->getCount($condition, $field);
+ return $this->success($count);
+ }
+ /************************************************************************* 购买的虚拟产品 end *******************************************************************/
+
+ /**
+ * 从excel中读取卡密数据
+ * @param $path
+ */
+ public function importData($path)
+ {
+ $PHPReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
+ //载入文件
+ $PHPExcel = $PHPReader->load($path);
+
+ //获取表中的第一个工作表,如果要获取第二个,把0改为1,依次类推
+ $currentSheet = $PHPExcel->getSheet(0);
+
+ //获取总行数
+ $allRow = $currentSheet->getHighestRow();
+
+ if ($allRow < 2) {
+ return $this->error('', '导入了一个空文件');
+ }
+ $data = [];
+ for ($i = 2; $i <= $allRow; $i++) {
+ //卡号
+ $cardno = $PHPExcel->getActiveSheet()->getCell('A' . $i)->getValue();
+ //卡号
+ $password = $PHPExcel->getActiveSheet()->getCell('B' . $i)->getValue();
+ $data[] = $cardno . ' ' . $password;
+ }
+ return $this->success(implode("\n", $data));
+ }
+
+ /**
+ * 重新统计库存
+ * @param $goods_id
+ */
+ public function statisticsStock($goods_id)
+ {
+ try {
+ model('goods_sku')->startTrans();
+ $goods_sku_list = model('goods_sku')->getList([ [ 'goods_id', '=', $goods_id ] ], 'sku_id,goods_class,site_id');
+ $goods_sku_ids = array_column($goods_sku_list, 'sku_id');
+ // 先删除已不存在的sku
+ model('goods_virtual')->delete([ [ 'order_id', '=', 0 ], [ 'goods_id', '=', $goods_id ], [ 'sku_id', 'not in', $goods_sku_ids ] ]);
+ // 重新统计sku的库存
+
+ $site_id = 0;
+ $stock_sku_list = [];
+ foreach ($goods_sku_list as $v) {
+ $site_id = $v[ 'site_id' ];
+ $sku_id = $v[ 'sku_id' ];
+ $sku_stock = model('goods_virtual')->getCount([ [ 'order_id', '=', 0 ], [ 'goods_id', '=', $goods_id ], [ 'sku_id', '=', $sku_id ] ]);
+// model('goods_sku')->update([ 'stock' => $sku_stock ], [ [ 'goods_id', '=', $goods_id ], [ 'sku_id', '=', $sku_id ] ]);
+ $stock_sku_list[] = [ 'sku_id' => $sku_id, 'stock' => $sku_stock, 'goods_class' => $v[ 'goods_class' ] ];
+ }
+ //设置库存
+ $goods_stock_model = new GoodsStock();
+ $result = $goods_stock_model->changeGoodsStock([
+ 'site_id' => $site_id,
+ 'goods_sku_list' => $stock_sku_list
+ ]);
+ // 重新统计spu的库存
+// $goods_stock = model('goods_sku')->getSum([ [ 'goods_id', '=', $goods_id ] ], 'stock');
+// model('goods')->update([ 'goods_stock' => $goods_stock ], [ [ 'goods_id', '=', $goods_id ] ]);
+ model('goods_sku')->commit();
+ } catch (\Exception $e) {
+ model('goods_sku')->rollback();
+ }
+ }
+
+ /**
+ * 商品导入
+ * @param $goods_data
+ * @param $site_id
+ * @return array
+ */
+ public function importGoods($goods_data, $site_id)
+ {
+ try {
+ if (empty($goods_data[ 'goods_name' ])) return $this->error('', '商品名称不能为空');
+ if (empty($goods_data[ 'goods_image' ])) return $this->error('', '商品主图不能为空');
+ if (empty($goods_data[ 'category_1' ]) && empty($goods_data[ 'category_2' ]) && empty($goods_data[ 'category_3' ])) return $this->error('', '商品分类不能为空');
+
+ // 处理商品分类
+ $category_id = '';
+ $category_json = [];
+ if (!empty($goods_data[ 'category_3' ])) {
+ $category_info = model('goods_category')->getInfo([ [ 'level', '=', 3 ], [ 'site_id', '=', $site_id ], [ 'category_full_name', '=', "{$goods_data['category_1']}/{$goods_data['category_2']}/{$goods_data['category_3']}" ] ], 'category_id_1,category_id_2,category_id_3');
+ if (!empty($category_info)) {
+ $category_id = "{$category_info['category_id_1']},{$category_info['category_id_2']},{$category_info['category_id_3']}";
+ }
+ }
+ if (!empty($goods_data[ 'category_2' ]) && empty($category_id)) {
+ $category_info = model('goods_category')->getInfo([ [ 'level', '=', 2 ], [ 'site_id', '=', $site_id ], [ 'category_full_name', '=', "{$goods_data['category_1']}/{$goods_data['category_2']}" ] ], 'category_id_1,category_id_2');
+ if (!empty($category_info)) {
+ $category_id = "{$category_info['category_id_1']},{$category_info['category_id_2']}";
+ }
+ }
+ if (!empty($goods_data[ 'category_1' ]) && empty($category_id)) {
+ $category_info = model('goods_category')->getInfo([ [ 'level', '=', 1 ], [ 'site_id', '=', $site_id ], [ 'category_name', '=', "{$goods_data['category_1']}" ] ], 'category_id_1');
+ if (!empty($category_info)) {
+ $category_id = "{$category_info['category_id_1']}";
+ }
+ }
+ if (empty($category_id)) return $this->error('', '未找到所填商品分类');
+ $category_json = [ $category_id ];
+
+ $sku_data = [];
+ $goods_spec_format = [];
+ $tag = 0;
+ // 处理sku数据
+ if (isset($goods_data[ 'sku' ])) {
+ foreach ($goods_data[ 'sku' ] as $sku_item) {
+ if (empty($sku_item[ 'sku_data' ])) return $this->error('', '规格数据不能为空');
+
+ $spec_name = '';
+ $spec_data = explode(';', $sku_item[ 'sku_data' ]);
+
+ $sku_spec_format = [];
+ foreach ($spec_data as $item) {
+ $spec_item = explode(':', $item);
+ $spec_name .= ' ' . $spec_item[ 1 ];
+
+ // 规格项
+ $spec_index = array_search($spec_item[ 0 ], array_column($goods_spec_format, 'spec_name'));
+ if (empty($goods_spec_format) || $spec_index === false) {
+ $spec = [
+ 'spec_id' => -( $tag + getMillisecond() ),
+ 'spec_name' => $spec_item[ 0 ],
+ 'value' => []
+ ];
+ $goods_spec_format[] = $spec;
+ $tag++;
+ } else {
+ $spec = $goods_spec_format[ $spec_index ];
+ }
+ // 规格值
+ $spec_index = array_search($spec_item[ 0 ], array_column($goods_spec_format, 'spec_name'));
+ $spec_value_index = array_search($spec_item[ 1 ], array_column($spec[ 'value' ], 'spec_value_name'));
+ if (empty($spec[ 'value' ]) || $spec_value_index === false) {
+ $spec_value = [
+ 'spec_id' => $spec[ 'spec_id' ],
+ 'spec_name' => $spec[ 'spec_name' ],
+ 'spec_value_id' => -( $tag + getMillisecond() ),
+ 'spec_value_name' => $spec_item[ 1 ],
+ 'image' => '',
+ ];
+ $goods_spec_format[ $spec_index ][ 'value' ][] = $spec_value;
+ $tag++;
+ } else {
+ $spec_value = $spec[ 'value' ][ $spec_value_index ];
+ }
+
+ $sku_spec_format[] = [
+ 'spec_id' => $spec[ 'spec_id' ],
+ 'spec_name' => $spec[ 'spec_name' ],
+ 'spec_value_id' => $spec_value[ 'spec_value_id' ],
+ 'spec_value_name' => $spec_value[ 'spec_value_name' ],
+ 'image' => '',
+ ];
+ }
+
+ $sku_images_arr = explode(',', $sku_item[ 'sku_image' ]);
+
+ $sku_temp = [
+ 'spec_name' => trim($spec_name),
+ 'sku_no' => $sku_item[ 'sku_code' ],
+ 'sku_spec_format' => $sku_spec_format,
+ 'price' => $sku_item[ 'price' ],
+ 'market_price' => $sku_item[ 'market_price' ],
+ 'cost_price' => $sku_item[ 'cost_price' ],
+ 'stock_alarm' => $sku_item[ 'stock_alarm' ],
+ 'sku_image' => empty($sku_item[ 'sku_image' ]) ? '' : $sku_images_arr[ 0 ],
+ 'sku_images' => empty($sku_item[ 'sku_image' ]) ? '' : $sku_item[ 'sku_image' ],
+ 'sku_images_arr' => empty($sku_item[ 'sku_image' ]) ? [] : $sku_images_arr,
+ 'is_default' => 0,
+ 'carmichael' => empty($sku_item[ 'carmichael' ]) ? [] : explode("\n", $sku_item[ 'carmichael' ])
+ ];
+
+ $sku_data[] = $sku_temp;
+ }
+ } else {
+ $goods_img = explode(',', $goods_data[ 'goods_image' ]);
+ $sku_data = [
+ [
+ 'sku_id' => 0,
+ 'sku_name' => $goods_data[ 'goods_name' ],
+ 'spec_name' => '',
+ 'sku_spec_format' => '',
+ 'price' => empty($goods_data[ 'price' ]) ? 0 : $goods_data[ 'price' ],
+ 'market_price' => empty($goods_data[ 'market_price' ]) ? 0 : $goods_data[ 'market_price' ],
+ 'cost_price' => empty($goods_data[ 'cost_price' ]) ? 0 : $goods_data[ 'cost_price' ],
+ 'sku_no' => $goods_data[ 'goods_code' ],
+ 'stock_alarm' => empty($goods_data[ 'stock_alarm' ]) ? 0 : $goods_data[ 'stock_alarm' ],
+ 'sku_image' => $goods_img[ 0 ],
+ 'sku_images' => $goods_data[ 'goods_image' ],
+ 'carmichael' => empty($goods_data[ 'carmichael' ]) ? [] : explode("\n", $goods_data[ 'carmichael' ])
+ ]
+ ];
+ }
+
+ if (count($goods_spec_format) > 4) return $this->error('', '最多支持四种规格项');
+
+ $data = [
+ 'goods_name' => $goods_data[ 'goods_name' ],// 商品名称,
+ 'goods_attr_class' => '',// 商品类型id,
+ 'goods_attr_name' => '',// 商品类型名称,
+ 'site_id' => $site_id,
+ 'category_id' => ',' . $category_id . ',',
+ 'category_json' => json_encode($category_json),
+ 'goods_image' => $goods_data[ 'goods_image' ],// 商品主图路径
+ 'goods_content' => '',// 商品详情
+ 'goods_state' => 0, //$goods_data['goods_state'] == 1 || $goods_data['goods_state'] == '是' ? 1 : 0,// 商品状态(1.正常0下架)
+ 'price' => empty($goods_data[ 'price' ]) ? 0 : $goods_data[ 'price' ],// 商品价格(取第一个sku)
+ 'market_price' => empty($goods_data[ 'market_price' ]) ? 0 : $goods_data[ 'market_price' ],// 市场价格(取第一个sku)
+ 'cost_price' => empty($goods_data[ 'cost_price' ]) ? 0 : $goods_data[ 'cost_price' ],// 成本价(取第一个sku)
+ 'sku_no' => $goods_data[ 'goods_code' ],// 商品sku编码
+ 'goods_stock_alarm' => empty($goods_data[ 'goods_stock_alarm' ]) ? 0 : $goods_data[ 'goods_stock_alarm' ],// 库存预警
+ 'goods_spec_format' => empty($goods_spec_format) ? '' : json_encode($goods_spec_format, JSON_UNESCAPED_UNICODE),// 商品规格格式
+ 'goods_attr_format' => '',// 商品参数格式
+ 'introduction' => $goods_data[ 'introduction' ],// 促销语
+ 'keywords' => $goods_data[ 'keywords' ],// 关键词
+ 'unit' => $goods_data[ 'unit' ],// 单位
+ 'sort' => '',// 排序,
+ 'qr_id' => empty($goods_data[ 'qr_id' ]) ? 0 : $goods_data[ 'qr_id' ],// 社群二维码id
+ 'template_id' => empty($goods_data[ 'template_id' ]) ? 0 : $goods_data[ 'template_id' ],// 海报id
+ 'is_limit' => empty($goods_data[ 'is_limit' ]) ? 0 : $goods_data[ 'is_limit' ],// 是否限购
+ 'limit_type' => empty($goods_data[ 'limit_type' ]) ? 0 : $goods_data[ 'limit_type' ],// 限购类型
+ 'video_url' => '',// 视频
+ 'goods_sku_data' => json_encode($sku_data, JSON_UNESCAPED_UNICODE),// SKU商品数据
+ 'goods_service_ids' => '',// 商品服务id集合
+ 'label_id' => '',// 商品分组id
+ 'virtual_sale' => 0,// 虚拟销量
+ 'max_buy' => 0,// 限购
+ 'min_buy' => 0,// 起售
+ 'recommend_way' => 0, // 推荐方式,1:新品,2:精品,3;推荐
+ 'timer_on' => 0,//定时上架
+ 'timer_off' => 0,//定时下架
+ 'brand_id' => 0,
+ 'is_consume_discount' => $goods_data[ 'is_consume_discount' ] == 1 || $goods_data[ 'is_consume_discount' ] == '是' ? 1 : 0, //是否参与会员折扣
+ ];
+
+ $res = $this->addGoods($data);
+ return $res;
+ } catch (\Exception $e) {
+ return $this->error('', $e->getMessage());
+ }
+ }
+
+ /**
+ * 检测商品是否存在未完成的订单
+ * @param $params
+ * @return array
+ */
+ public function checkGoodsIsExistsOrder($params)
+ {
+ $condition = [
+ [ 'og.site_id', '=', $params[ 'site_id' ] ],
+ [ 'og.goods_id', '=', $params[ 'goods_id' ] ],
+ [ 'o.order_status', 'not in', [ -1, 10 ] ] // 排除订单状态 -1:已关闭,10:已完成
+ ];
+
+ if (!empty($params[ 'sku_id' ])) {
+ $condition[] = [ 'og.sku_id', 'in', $params[ 'sku_id' ] ];
+ }
+
+ $join = [
+ [ 'order o', 'o.order_id = og.order_id', 'left' ]
+ ];
+
+ $order_model = new OrderCommon();
+ $res = $order_model->getOrderGoodsCount($condition, 'order_goods_id', 'og', $join);
+ if ($res[ 'data' ] > 0) {
+ return $this->error('', '该商品存在未完成的订单,无法删除规格项');
+ }
+ return $this->success();
+
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/virtualcard/shop/controller/Goods.php b/src/addon/virtualcard/shop/controller/Goods.php
index 260bc681f..d20af3db6 100644
--- a/src/addon/virtualcard/shop/controller/Goods.php
+++ b/src/addon/virtualcard/shop/controller/Goods.php
@@ -1,460 +1,452 @@
-replace = [
- 'ADDON_VIRTUALCARD_CSS' => __ROOT__ . '/addon/virtualcard/shop/view/public/css',
- 'ADDON_VIRTUALCARD_JS' => __ROOT__ . '/addon/virtualcard/shop/view/public/js',
- 'ADDON_VIRTUALCARD_IMG' => __ROOT__ . '/addon/virtualcard/shop/view/public/img',
- ];
- parent::__construct($app);
- }
-
- /**
- * 添加商品
- * @return mixed
- */
- public function addGoods()
- {
- if (request()->isJson()) {
-
- $category_id = input('category_id', 0);// 分类id
- $category_json = json_encode($category_id);//分类字符串
- $category_id = ',' . implode(',', $category_id) . ',';
-
- $data = [
- 'goods_name' => input('goods_name', ''),// 商品名称,
- 'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
- 'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
- 'is_limit' => input('is_limit', '0'),// 商品是否开启限购,
- 'limit_type' => input('limit_type', '1'),// 限购类型,
- 'site_id' => $this->site_id,
- 'category_id' => $category_id,
- 'category_json' => $category_json,
- 'goods_image' => input('goods_image', ''),// 商品主图路径
- 'goods_content' => input('goods_content', ''),// 商品详情
- 'goods_state' => input('goods_state', ''),// 商品状态(1.正常0下架)
- 'price' => input('price', 0),// 商品价格(取第一个sku)
- 'market_price' => input('market_price', 0),// 市场价格(取第一个sku)
- 'cost_price' => input('cost_price', 0),// 成本价(取第一个sku)
- 'sku_no' => input('sku_no', ''),// 商品sku编码
- 'weight' => input('weight', ''),// 重量
- 'volume' => input('volume', ''),// 体积
- 'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
- 'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
- 'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
- 'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
- 'introduction' => input('introduction', ''),// 促销语
- 'keywords' => input('keywords', ''),// 关键词
- 'brand_id' => input('brand_id', 0),//品牌id
- 'unit' => input('unit', ''),// 单位
- 'sort' => input('sort', 0),// 排序,
- 'video_url' => input('video_url', ''),// 视频
- 'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
- 'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
- 'label_id' => input('label_id', ''),// 商品分组id
- 'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
- 'max_buy' => input('max_buy', 0),// 限购
- 'min_buy' => input('min_buy', 0),// 起售
- 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐
- 'timer_on' => strtotime(input('timer_on', 0)),//定时上架
- 'timer_off' => strtotime(input('timer_off', 0)),//定时下架
- 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
- 'qr_id' => input('qr_id', 0),//社群二维码id
- 'template_id' => input('template_id', 0),//商品海报id
- 'sale_show' => input('sale_show', 0),//
- 'stock_show' => input('stock_show', 0),//
- 'market_price_show' => input('market_price_show', 0),//
- 'barrage_show' => input('barrage_show', 0),//
- 'form_id' => input('form_id', 0),
- 'sale_channel' => input('sale_channel', 'all'),
- 'sale_store' => input('sale_store', 'all'),
- 'supplier_id' => input('supplier_id', 0)
- ];
-
- $virtual_goods_model = new VirtualGoodsModel();
- $res = $virtual_goods_model->addGoods($data);
- return $res;
- } else {
-
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
-
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate');
- $goods_category_list = $goods_category_list[ 'data' ];
- $this->assign('goods_category_list', $goods_category_list);
-
- //获取商品类型
- $goods_attr_model = new GoodsAttributeModel();
- $attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
- $this->assign('attr_class_list', $attr_class_list);
-
- // 商品服务
- $goods_service_model = new GoodsServiceModel();
- $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
- $this->assign('service_list', $service_list);
-
- // 商品标签
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
- $this->assign('label_list', $label_list);
- // 商品品牌
- $goods_brand_model = new GoodsBrandModel();
- $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id,brand_name', 'sort asc')[ 'data' ];
- $this->assign('brand_list', $brand_list);
- //商品默认排序值
- $config_model = new ConfigModel();
- $sort_config = $config_model->getGoodsSort($this->site_id)[ 'data' ][ 'value' ];
- $this->assign('sort_config', $sort_config);
-
- //获取商品海报
- $poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
- if (!empty($poster_list)) {
- $poster_list = $poster_list[ 'data' ];
- }
- $this->assign('poster_list', $poster_list);
-
- $form_is_exit = addon_is_exit('form', $this->site_id);
- if ($form_is_exit) {
- $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
- $this->assign('form_list', $form_list);
- }
- $this->assign('form_is_exit', $form_is_exit);
-
- $this->assign('all_goodsclass', event('GoodsClass'));
- $this->assign('goods_class', ( new VirtualGoodsModel() )->getGoodsClass());
-
- $this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
-
- $is_install_supply = addon_is_exit('supply');
- if ($is_install_supply) {
- $supplier_model = new SupplierModel();
- $supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
- $this->assign('supplier_list', $supplier_list);
- }
- $this->assign('is_install_supply', $is_install_supply);
-
- return $this->fetch('goods/add_goods');
- }
- }
-
- /**
- * 编辑商品
- * @return mixed
- */
- public function editGoods()
- {
- $virtual_goods_model = new VirtualGoodsModel();
- if (request()->isJson()) {
-
- $category_id = input('category_id', 0);// 分类id
- $category_json = json_encode($category_id);//分类字符串
- $category_id = ',' . implode(',', $category_id) . ',';
-
- $data = [
- 'goods_id' => input('goods_id', 0),// 商品id
- 'goods_name' => input('goods_name', ''),// 商品名称,
- 'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
- 'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
- 'is_limit' => input('is_limit', '0'),// 商品是否开启限购,
- 'limit_type' => input('limit_type', '1'),// 限购类型,
- 'site_id' => $this->site_id,
- 'category_id' => $category_id,
- 'category_json' => $category_json,
- 'goods_image' => input('goods_image', ''),// 商品主图路径
- 'goods_content' => input('goods_content', ''),// 商品详情
- 'goods_state' => input('goods_state', ''),// 商品状态(1.正常0下架)
- 'price' => input('price', 0),// 商品价格(取第一个sku)
- 'market_price' => input('market_price', 0),// 市场价格(取第一个sku)
- 'cost_price' => input('cost_price', 0),// 成本价(取第一个sku)
- 'sku_no' => input('sku_no', ''),// 商品sku编码
- 'weight' => input('weight', ''),// 重量
- 'volume' => input('volume', ''),// 体积
- 'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
- 'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
- 'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
- 'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
- 'introduction' => input('introduction', ''),// 促销语
- 'keywords' => input('keywords', ''),// 关键词
- 'unit' => input('unit', ''),// 单位
- 'sort' => input('sort', 0),// 排序,
- 'video_url' => input('video_url', ''),// 视频
- 'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
- 'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
- 'label_id' => input('label_id', ''),// 商品分组id
- 'brand_id' => input('brand_id', 0),//品牌id
- 'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
- 'max_buy' => input('max_buy', 0),// 限购
- 'min_buy' => input('min_buy', 0),// 起售
- 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐
- 'timer_on' => strtotime(input('timer_on', 0)),//定时上架
- 'timer_off' => strtotime(input('timer_off', 0)),//定时下架
- 'spec_type_status' => input('spec_type_status', 0),
- 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
- 'qr_id' => input('qr_id', 0),//社群二维码id
- 'template_id' => input('template_id', 0),//商品海报id
- 'sale_show' => input('sale_show', 0),//
- 'stock_show' => input('stock_show', 0),//
- 'market_price_show' => input('market_price_show', 0),//
- 'barrage_show' => input('barrage_show', 0),//
- 'form_id' => input('form_id', 0),
- 'sale_channel' => input('sale_channel', 'all'),
- 'sale_store' => input('sale_store', 'all'),
- 'supplier_id' => input('supplier_id', 0)
- ];
- $res = $virtual_goods_model->editGoods($data);
- return $res;
- } else {
- $goods_model = new GoodsModel();
- $goods_id = input('goods_id', 0);
- $goods_info = $goods_model->editGetGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
- if (empty($goods_info)) $this->error('未获取到商品数据', href_url('shop/goods/lists'));
-
- $goods_sku_list = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,sku_name,sku_no,sku_spec_format,price,market_price,cost_price,stock,virtual_indate,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default', '')[ 'data' ];
- $goods_info[ 'sku_list' ] = $goods_sku_list;
- $this->assign('goods_info', $goods_info);
-
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
- $this->assign('goods_category_list', $goods_category_list);
-
- //获取商品类型
- $goods_attr_model = new GoodsAttributeModel();
- $attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
- $this->assign('attr_class_list', $attr_class_list);
-
- // 商品服务
- $goods_service_model = new GoodsServiceModel();
- $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
- $this->assign('service_list', $service_list);
-
- // 商品标签
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
- $this->assign('label_list', $label_list);
- //获取品牌
- $goods_brand_model = new GoodsBrandModel();
- $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id, brand_name')[ 'data' ];
- $this->assign('brand_list', $brand_list);
-
- //获取商品海报
- $poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
- if (!empty($poster_list)) {
- $poster_list = $poster_list[ 'data' ];
- }
- $this->assign('poster_list', $poster_list);
-
- $form_is_exit = addon_is_exit('form', $this->site_id);
- if ($form_is_exit) {
- $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
- $this->assign('form_list', $form_list);
- }
- $this->assign('form_is_exit', $form_is_exit);
-
- $store_is_exit = addon_is_exit('store', $this->site_id);
- if ($store_is_exit && $goods_info[ 'sale_store' ] != 'all') {
- $store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'store_id', 'in', $goods_info[ 'sale_store' ] ] ], 'store_id,store_name,status,address,full_address,is_frozen');
- $this->assign('store_list', $store_list[ 'data' ]);
- }
- $this->assign('store_is_exit', $store_is_exit);
-
- $is_install_supply = addon_is_exit('supply');
- if ($is_install_supply) {
- $supplier_model = new SupplierModel();
- $supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
- $this->assign('supplier_list', $supplier_list);
- }
- $this->assign('is_install_supply', $is_install_supply);
-
- return $this->fetch('goods/edit_goods');
- }
- }
-
- /**
- * 卡密管理
- * @return array|mixed|void
- */
- public function carmichael()
- {
- $virtual_goods_model = new VirtualGoodsModel();
- if (request()->isJson()) {
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $goods_id = input('goods_id', 0);
- $is_sold = input('is_sold', 0);
- $condition = [
- [ 'gv.goods_id', '=', $goods_id ],
- [ 'gv.site_id', '=', $this->site_id ]
- ];
- if ($is_sold) {
- $condition[] = [ 'gv.order_id', '<>', 0 ];
- } else {
- $condition[] = [ 'gv.order_id', '=', 0 ];
- }
- $join = [
- [ 'goods_sku gs', 'gs.sku_id = gv.sku_id', 'left' ],
- [ 'member m', 'm.member_id = gv.member_id', 'left' ],
- ];
- $field = 'gv.id,gv.sku_name,gv.card_info,gv.order_id,gv.sku_id,gv.sold_time,gs.spec_name,m.nickname, m.headimg';
- $res = $virtual_goods_model->getVirtualGoodsPageList($condition, $page, $page_size, 'id desc,sold_time desc', $field, 'gv', $join);
- return $res;
- }
- $goods_id = input('goods_id', 0);
- $this->assign('goods_id', $goods_id);
-
- $goods_info = $virtual_goods_model->getGoodsDetail($goods_id, $this->site_id);
- if (empty($goods_info[ 'data' ])) $this->error('未获取到商品信息');
- $this->assign('goods', $goods_info[ 'data' ]);
- $temp_condition = array (
- [ 'goods_id', '=', $goods_id ],
- [ 'site_id', '=', $this->site_id ],
- [ 'order_id', '=', 0 ]
- );
- $this->assign('stock', $virtual_goods_model->getVirtualGoodsCount($temp_condition)[ 'data' ] ?? 0);
- return $this->fetch('goods/carmichael');
- }
-
- /**
- * 下载卡密导入模板
- * @throws \PHPExcel_Exception
- * @throws \PHPExcel_Reader_Exception
- * @throws \PHPExcel_Writer_Exception
- */
- public function downloadTemplate()
- {
- // 实例化excel
- $phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
-
- $phpExcel->getProperties()->setTitle('卡密数据导入模板');
- $phpExcel->getProperties()->setSubject('卡密数据导入模板');
- // 对单元格设置居中效果
- $phpExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
- $phpExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
-
- //单独添加列名称
- $phpExcel->setActiveSheetIndex(0);
- $phpExcel->getActiveSheet()->setCellValue('A1', '卡号');//可以指定位置
- $phpExcel->getActiveSheet()->setCellValue('B1', '密码');
-
- // 设置第一个sheet为工作的sheet
- $phpExcel->setActiveSheetIndex(0);
- // 保存Excel 2007格式文件,保存路径为当前路径,名字为export.xlsx
- $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
- $file = date('卡密数据导入模板', time()) . '.xlsx';
- $objWriter->save($file);
-
- header('Content-type:application/octet-stream');
-
- $filename = basename($file);
- header('Content-Disposition:attachment;filename = ' . $filename);
- header('Accept-ranges:bytes');
- header('Accept-length:' . filesize($file));
- readfile($file);
- unlink($file);
- exit;
- }
-
- /**
- * 添加卡密
- * @return array
- */
- public function addCarmichael()
- {
- if (request()->isJson()) {
- $virtual_goods_model = new VirtualGoodsModel();
- $goods_id = input('goods_id', 0);
- $sku_id = input('sku_id', 0);
- $data = input('data', '');
- $carmichael = explode(',', $data);
- $res = $virtual_goods_model->addGoodsVirtual($this->site_id, $goods_id, $sku_id, $carmichael);
- return $res;
- }
- }
-
- /**
- * 导入数据
- */
- public function import()
- {
- if (request()->isJson()) {
- $virtual_goods_model = new VirtualGoodsModel();
- $path = input('path', '');
- $res = $virtual_goods_model->importData($path);
- return $res;
- }
- }
-
- /**
- * 删除卡密
- */
- public function deleteGoodsVirtual()
- {
- if (request()->isJson()) {
- $ids = input('id', '');
- $goods_id = input('goods_id', '');
- $virtual_goods_model = new VirtualGoodsModel();
- $res = $virtual_goods_model->deleteGoodsVirtual([ [ 'order_id', '=', 0 ], [ 'id', 'in', $ids ], [ 'site_id', '=', $this->site_id ], [ 'goods_id', '=', $goods_id ] ]);
- return $res;
- }
- }
-
- /**
- * 编辑卡密
- * @return array
- */
- public function editGoodsVirtual()
- {
- if (request()->isJson()) {
- $virtual_goods_model = new VirtualGoodsModel();
- $id = input('id', '');
- $card_info = [
- 'cardno' => input('cardno', ''),
- 'password' => input('password', '')
- ];
- $res = $virtual_goods_model->updateGoodsVirtual([ 'card_info' => json_encode($card_info) ], [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', 0 ] ]);
- return $res;
- }
- }
+replace = [
+ 'ADDON_VIRTUALCARD_CSS' => __ROOT__ . '/addon/virtualcard/shop/view/public/css',
+ 'ADDON_VIRTUALCARD_JS' => __ROOT__ . '/addon/virtualcard/shop/view/public/js',
+ 'ADDON_VIRTUALCARD_IMG' => __ROOT__ . '/addon/virtualcard/shop/view/public/img',
+ ];
+ parent::__construct($app);
+ }
+
+ /**
+ * 添加商品
+ * @return mixed
+ */
+ public function addGoods()
+ {
+ if (request()->isJson()) {
+
+ $category_id = input('category_id', 0);// 分类id
+ $category_json = json_encode($category_id);//分类字符串
+ $category_id = ',' . implode(',', $category_id) . ',';
+
+ $data = [
+ 'goods_name' => input('goods_name', ''),// 商品名称,
+ 'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
+ 'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
+ 'is_limit' => input('is_limit', '0'),// 商品是否开启限购,
+ 'limit_type' => input('limit_type', '1'),// 限购类型,
+ 'site_id' => $this->site_id,
+ 'category_id' => $category_id,
+ 'category_json' => $category_json,
+ 'goods_image' => input('goods_image', ''),// 商品主图路径
+ 'goods_content' => input('goods_content', ''),// 商品详情
+ 'goods_state' => input('goods_state', ''),// 商品状态(1.正常0下架)
+ 'price' => input('price', 0),// 商品价格(取第一个sku)
+ 'market_price' => input('market_price', 0),// 市场价格(取第一个sku)
+ 'cost_price' => input('cost_price', 0),// 成本价(取第一个sku)
+ 'sku_no' => input('sku_no', ''),// 商品sku编码
+ 'weight' => input('weight', ''),// 重量
+ 'volume' => input('volume', ''),// 体积
+ 'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
+ 'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
+ 'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
+ 'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
+ 'introduction' => input('introduction', ''),// 促销语
+ 'keywords' => input('keywords', ''),// 关键词
+ 'brand_id' => input('brand_id', 0),//品牌id
+ 'unit' => input('unit', ''),// 单位
+ 'sort' => input('sort', 0),// 排序,
+ 'video_url' => input('video_url', ''),// 视频
+ 'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
+ 'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
+ 'label_id' => input('label_id', ''),// 商品分组id
+ 'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
+ 'max_buy' => input('max_buy', 0),// 限购
+ 'min_buy' => input('min_buy', 0),// 起售
+ 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐
+ 'timer_on' => strtotime(input('timer_on', 0)),//定时上架
+ 'timer_off' => strtotime(input('timer_off', 0)),//定时下架
+ 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
+ 'qr_id' => input('qr_id', 0),//社群二维码id
+ 'template_id' => input('template_id', 0),//商品海报id
+ 'sale_show' => input('sale_show', 0),//
+ 'stock_show' => input('stock_show', 0),//
+ 'market_price_show' => input('market_price_show', 0),//
+ 'barrage_show' => input('barrage_show', 0),//
+ 'form_id' => input('form_id', 0),
+ 'sale_channel' => input('sale_channel', 'all'),
+ 'sale_store' => input('sale_store', 'all'),
+ 'supplier_id' => input('supplier_id', 0)
+ ];
+
+ $virtual_goods_model = new VirtualGoodsModel();
+ $res = $virtual_goods_model->addGoods($data);
+ return $res;
+ } else {
+
+ //获取一级商品分类
+ $goods_category_model = new GoodsCategoryModel();
+ $condition = [
+ [ 'pid', '=', 0 ],
+ [ 'site_id', '=', $this->site_id ]
+ ];
+
+ $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate');
+ $goods_category_list = $goods_category_list[ 'data' ];
+ $this->assign('goods_category_list', $goods_category_list);
+
+ //获取商品类型
+ $goods_attr_model = new GoodsAttributeModel();
+ $attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
+ $this->assign('attr_class_list', $attr_class_list);
+
+ // 商品服务
+ $goods_service_model = new GoodsServiceModel();
+ $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
+ $this->assign('service_list', $service_list);
+
+ // 商品标签
+ $goods_label_model = new GoodsLabelModel();
+ $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
+ $this->assign('label_list', $label_list);
+ // 商品品牌
+ $goods_brand_model = new GoodsBrandModel();
+ $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id,brand_name', 'sort asc')[ 'data' ];
+ $this->assign('brand_list', $brand_list);
+ //商品默认排序值
+ $config_model = new ConfigModel();
+ $sort_config = $config_model->getGoodsSort($this->site_id)[ 'data' ][ 'value' ];
+ $this->assign('sort_config', $sort_config);
+
+ //获取商品海报
+ $poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
+ if (!empty($poster_list)) {
+ $poster_list = $poster_list[ 'data' ];
+ }
+ $this->assign('poster_list', $poster_list);
+
+ $form_is_exit = addon_is_exit('form', $this->site_id);
+ if ($form_is_exit) {
+ $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
+ $this->assign('form_list', $form_list);
+ }
+ $this->assign('form_is_exit', $form_is_exit);
+
+ $this->assign('all_goodsclass', event('GoodsClass'));
+ $this->assign('goods_class', ( new VirtualGoodsModel() )->getGoodsClass());
+
+ $this->assign('store_is_exit', addon_is_exit('store', $this->site_id));
+
+ $is_install_supply = addon_is_exit('supply');
+ if ($is_install_supply) {
+ $supplier_model = new SupplierModel();
+ $supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
+ $this->assign('supplier_list', $supplier_list);
+ }
+ $this->assign('is_install_supply', $is_install_supply);
+
+ return $this->fetch('goods/add_goods');
+ }
+ }
+
+ /**
+ * 编辑商品
+ * @return mixed
+ */
+ public function editGoods()
+ {
+ $virtual_goods_model = new VirtualGoodsModel();
+ if (request()->isJson()) {
+
+ $category_id = input('category_id', 0);// 分类id
+ $category_json = json_encode($category_id);//分类字符串
+ $category_id = ',' . implode(',', $category_id) . ',';
+
+ $data = [
+ 'goods_id' => input('goods_id', 0),// 商品id
+ 'goods_name' => input('goods_name', ''),// 商品名称,
+ 'goods_attr_class' => input('goods_attr_class', ''),// 商品类型id,
+ 'goods_attr_name' => input('goods_attr_name', ''),// 商品类型名称,
+ 'is_limit' => input('is_limit', '0'),// 商品是否开启限购,
+ 'limit_type' => input('limit_type', '1'),// 限购类型,
+ 'site_id' => $this->site_id,
+ 'category_id' => $category_id,
+ 'category_json' => $category_json,
+ 'goods_image' => input('goods_image', ''),// 商品主图路径
+ 'goods_content' => input('goods_content', ''),// 商品详情
+ 'goods_state' => input('goods_state', ''),// 商品状态(1.正常0下架)
+ 'price' => input('price', 0),// 商品价格(取第一个sku)
+ 'market_price' => input('market_price', 0),// 市场价格(取第一个sku)
+ 'cost_price' => input('cost_price', 0),// 成本价(取第一个sku)
+ 'sku_no' => input('sku_no', ''),// 商品sku编码
+ 'weight' => input('weight', ''),// 重量
+ 'volume' => input('volume', ''),// 体积
+ 'goods_stock' => input('goods_stock', 0),// 商品库存(总和)
+ 'goods_stock_alarm' => input('goods_stock_alarm', 0),// 库存预警
+ 'goods_spec_format' => input('goods_spec_format', ''),// 商品规格格式
+ 'goods_attr_format' => input('goods_attr_format', ''),// 商品参数格式
+ 'introduction' => input('introduction', ''),// 促销语
+ 'keywords' => input('keywords', ''),// 关键词
+ 'unit' => input('unit', ''),// 单位
+ 'sort' => input('sort', 0),// 排序,
+ 'video_url' => input('video_url', ''),// 视频
+ 'goods_sku_data' => input('goods_sku_data', ''),// SKU商品数据
+ 'goods_service_ids' => input('goods_service_ids', ''),// 商品服务id集合
+ 'label_id' => input('label_id', ''),// 商品分组id
+ 'brand_id' => input('brand_id', 0),//品牌id
+ 'virtual_sale' => input('virtual_sale', 0),// 虚拟销量
+ 'max_buy' => input('max_buy', 0),// 限购
+ 'min_buy' => input('min_buy', 0),// 起售
+ 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐
+ 'timer_on' => strtotime(input('timer_on', 0)),//定时上架
+ 'timer_off' => strtotime(input('timer_off', 0)),//定时下架
+ 'spec_type_status' => input('spec_type_status', 0),
+ 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣
+ 'qr_id' => input('qr_id', 0),//社群二维码id
+ 'template_id' => input('template_id', 0),//商品海报id
+ 'sale_show' => input('sale_show', 0),//
+ 'stock_show' => input('stock_show', 0),//
+ 'market_price_show' => input('market_price_show', 0),//
+ 'barrage_show' => input('barrage_show', 0),//
+ 'form_id' => input('form_id', 0),
+ 'sale_channel' => input('sale_channel', 'all'),
+ 'sale_store' => input('sale_store', 'all'),
+ 'supplier_id' => input('supplier_id', 0)
+ ];
+ $res = $virtual_goods_model->editGoods($data);
+ return $res;
+ } else {
+ $goods_model = new GoodsModel();
+ $goods_id = input('goods_id', 0);
+ $goods_info = $goods_model->editGetGoodsInfo([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
+ if (empty($goods_info)) $this->error('未获取到商品数据', href_url('shop/goods/lists'));
+
+ $goods_sku_list = $goods_model->getGoodsSkuList([ [ 'goods_id', '=', $goods_id ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,sku_name,sku_no,sku_spec_format,price,market_price,cost_price,stock,virtual_indate,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default', '')[ 'data' ];
+ $goods_info[ 'sku_list' ] = $goods_sku_list;
+ $this->assign('goods_info', $goods_info);
+
+ //获取一级商品分类
+ $goods_category_model = new GoodsCategoryModel();
+ $condition = [
+ [ 'pid', '=', 0 ],
+ [ 'site_id', '=', $this->site_id ]
+ ];
+ $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')[ 'data' ];
+ $this->assign('goods_category_list', $goods_category_list);
+
+ //获取商品类型
+ $goods_attr_model = new GoodsAttributeModel();
+ $attr_class_list = $goods_attr_model->getAttrClassList([ [ 'site_id', '=', $this->site_id ] ], 'class_id,class_name')[ 'data' ];
+ $this->assign('attr_class_list', $attr_class_list);
+
+ // 商品服务
+ $goods_service_model = new GoodsServiceModel();
+ $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
+ $this->assign('service_list', $service_list);
+
+ // 商品标签
+ $goods_label_model = new GoodsLabelModel();
+ $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'sort ASC')[ 'data' ];
+ $this->assign('label_list', $label_list);
+ //获取品牌
+ $goods_brand_model = new GoodsBrandModel();
+ $brand_list = $goods_brand_model->getBrandList([ [ 'site_id', '=', $this->site_id ] ], 'brand_id, brand_name')[ 'data' ];
+ $this->assign('brand_list', $brand_list);
+
+ //获取商品海报
+ $poster_list = event('PosterTemplate', [ 'site_id' => $this->site_id ], true);
+ if (!empty($poster_list)) {
+ $poster_list = $poster_list[ 'data' ];
+ }
+ $this->assign('poster_list', $poster_list);
+
+ $form_is_exit = addon_is_exit('form', $this->site_id);
+ if ($form_is_exit) {
+ $form_list = ( new Form() )->getFormList([ [ 'site_id', '=', $this->site_id ], [ 'form_type', '=', 'goods' ], [ 'is_use', '=', 1 ] ], 'id desc', 'id, form_name')[ 'data' ];
+ $this->assign('form_list', $form_list);
+ }
+ $this->assign('form_is_exit', $form_is_exit);
+
+ $store_is_exit = addon_is_exit('store', $this->site_id);
+ if ($store_is_exit && $goods_info[ 'sale_store' ] != 'all') {
+ $store_list = ( new StoreModel() )->getStoreList([ [ 'site_id', '=', $this->site_id ], [ 'store_id', 'in', $goods_info[ 'sale_store' ] ] ], 'store_id,store_name,status,address,full_address,is_frozen');
+ $this->assign('store_list', $store_list[ 'data' ]);
+ }
+ $this->assign('store_is_exit', $store_is_exit);
+
+ $is_install_supply = addon_is_exit('supply');
+ if ($is_install_supply) {
+ $supplier_model = new SupplierModel();
+ $supplier_list = $supplier_model->getSupplyList([ [ 'supplier_site_id', '=', $this->site_id ] ], 'supplier_id,title', 'supplier_id desc')['data'];
+ $this->assign('supplier_list', $supplier_list);
+ }
+ $this->assign('is_install_supply', $is_install_supply);
+
+ return $this->fetch('goods/edit_goods');
+ }
+ }
+
+ /**
+ * 卡密管理
+ * @return array|mixed|void
+ */
+ public function carmichael()
+ {
+ $virtual_goods_model = new VirtualGoodsModel();
+ if (request()->isJson()) {
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $goods_id = input('goods_id', 0);
+ $is_sold = input('is_sold', 0);
+ $condition = [
+ [ 'gv.goods_id', '=', $goods_id ],
+ [ 'gv.site_id', '=', $this->site_id ]
+ ];
+ if ($is_sold) {
+ $condition[] = [ 'gv.order_id', '<>', 0 ];
+ } else {
+ $condition[] = [ 'gv.order_id', '=', 0 ];
+ }
+ $join = [
+ [ 'goods_sku gs', 'gs.sku_id = gv.sku_id', 'left' ],
+ [ 'member m', 'm.member_id = gv.member_id', 'left' ],
+ ];
+ $field = 'gv.id,gv.sku_name,gv.card_info,gv.order_id,gv.sku_id,gv.sold_time,gs.spec_name,m.nickname, m.headimg';
+ $res = $virtual_goods_model->getVirtualGoodsPageList($condition, $page, $page_size, 'id desc,sold_time desc', $field, 'gv', $join);
+ return $res;
+ }
+ $goods_id = input('goods_id', 0);
+ $this->assign('goods_id', $goods_id);
+
+ $goods_info = $virtual_goods_model->getGoodsDetail($goods_id, $this->site_id);
+ if (empty($goods_info[ 'data' ])) $this->error('未获取到商品信息');
+ $this->assign('goods', $goods_info[ 'data' ]);
+ $temp_condition = array (
+ [ 'goods_id', '=', $goods_id ],
+ [ 'site_id', '=', $this->site_id ],
+ [ 'order_id', '=', 0 ]
+ );
+ $this->assign('stock', $virtual_goods_model->getVirtualGoodsCount($temp_condition)[ 'data' ] ?? 0);
+ return $this->fetch('goods/carmichael');
+ }
+
+ /**
+ * 下载卡密导入模板
+ * @throws \PHPExcel_Exception
+ * @throws \PHPExcel_Reader_Exception
+ * @throws \PHPExcel_Writer_Exception
+ */
+ public function downloadTemplate()
+ {
+ // 实例化excel
+ $phpExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
+
+ $phpExcel->getProperties()->setTitle('卡密数据导入模板');
+ $phpExcel->getProperties()->setSubject('卡密数据导入模板');
+ // 对单元格设置居中效果
+ $phpExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
+ $phpExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
+
+ //单独添加列名称
+ $phpExcel->setActiveSheetIndex(0);
+ $phpExcel->getActiveSheet()->setCellValue('A1', '卡号');//可以指定位置
+ $phpExcel->getActiveSheet()->setCellValue('B1', '密码');
+
+ // 设置第一个sheet为工作的sheet
+ $phpExcel->setActiveSheetIndex(0);
+ // 保存Excel 2007格式文件,保存路径为当前路径,名字为export.xlsx
+ $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($phpExcel, 'Xlsx');
+ $file = date('卡密数据导入模板', time()) . '.xlsx';
+ $objWriter->save($file);
+
+ header('Content-type:application/octet-stream');
+
+ $filename = basename($file);
+ header('Content-Disposition:attachment;filename = ' . $filename);
+ header('Accept-ranges:bytes');
+ header('Accept-length:' . filesize($file));
+ readfile($file);
+ unlink($file);
+ exit;
+ }
+
+ /**
+ * 添加卡密
+ * @return array
+ */
+ public function addCarmichael()
+ {
+ if (request()->isJson()) {
+ $virtual_goods_model = new VirtualGoodsModel();
+ $goods_id = input('goods_id', 0);
+ $sku_id = input('sku_id', 0);
+ $data = input('data', '');
+ $carmichael = explode(',', $data);
+ $res = $virtual_goods_model->addGoodsVirtual($this->site_id, $goods_id, $sku_id, $carmichael);
+ return $res;
+ }
+ }
+
+ /**
+ * 导入数据
+ */
+ public function import()
+ {
+ if (request()->isJson()) {
+ $virtual_goods_model = new VirtualGoodsModel();
+ $path = input('path', '');
+ $res = $virtual_goods_model->importData($path);
+ return $res;
+ }
+ }
+
+ /**
+ * 删除卡密
+ */
+ public function deleteGoodsVirtual()
+ {
+ if (request()->isJson()) {
+ $ids = input('id', '');
+ $goods_id = input('goods_id', '');
+ $virtual_goods_model = new VirtualGoodsModel();
+ $res = $virtual_goods_model->deleteGoodsVirtual([ [ 'order_id', '=', 0 ], [ 'id', 'in', $ids ], [ 'site_id', '=', $this->site_id ], [ 'goods_id', '=', $goods_id ] ]);
+ return $res;
+ }
+ }
+
+ /**
+ * 编辑卡密
+ * @return array
+ */
+ public function editGoodsVirtual()
+ {
+ if (request()->isJson()) {
+ $virtual_goods_model = new VirtualGoodsModel();
+ $id = input('id', '');
+ $card_info = [
+ 'cardno' => input('cardno', ''),
+ 'password' => input('password', '')
+ ];
+ $res = $virtual_goods_model->updateGoodsVirtual([ 'card_info' => json_encode($card_info) ], [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ], [ 'order_id', '=', 0 ] ]);
+ return $res;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/addon/virtualevaluation/config/diy_view.php b/src/addon/virtualevaluation/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/virtualevaluation/config/diy_view.php
+++ b/src/addon/virtualevaluation/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/virtualevaluation/config/info.php b/src/addon/virtualevaluation/config/info.php
index 52eb46fcc..52abc6ff4 100644
--- a/src/addon/virtualevaluation/config/info.php
+++ b/src/addon/virtualevaluation/config/info.php
@@ -1,20 +1,12 @@
- 'virtualevaluation',
- 'title' => '虚拟评价',
- 'description' => '创建商品虚拟评价',
- 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
- 'status' => 1,
- 'author' => '',
- 'version' => '5.3.1',
- 'version_no' => '525231212001',
- 'content' => '',
+ 'virtualevaluation',
+ 'title' => '虚拟评价',
+ 'description' => '创建商品虚拟评价',
+ 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
+ 'status' => 1,
+ 'author' => '',
+ 'version' => '5.3.1',
+ 'version_no' => '525231212001',
+ 'content' => '',
];
\ No newline at end of file
diff --git a/src/addon/virtualevaluation/event/Install.php b/src/addon/virtualevaluation/event/Install.php
index 4ca6f934f..dd64c68a4 100644
--- a/src/addon/virtualevaluation/event/Install.php
+++ b/src/addon/virtualevaluation/event/Install.php
@@ -1,26 +1,18 @@
-getOrderEvaluateConfig($site_id)[ 'data' ][ 'value' ];
-
- if ($data[ 'dengji' ] == 1) {
- $evaluate_type = 3;
- } else if ($data[ 'dengji' ] == 2 || $data[ 'dengji' ] == 3) {
- $evaluate_type = 2;
- } else if ($data[ 'dengji' ] == 4 || $data[ 'dengji' ] == 5) {
- $evaluate_type = 1;
- }
- // 虚拟评价不需要审核
- $order_evaluate_config[ 'evaluate_audit' ] = 0;
-
- if (!empty($data[ 'goods_data' ])) {
- foreach ($data[ 'goods_data' ] as $k => $v) {
- $item = [
- 'order_id' => 0,
- 'order_no' => 0,
- 'member_id' => 0,
- 'member_name' => $data[ 'member_name' ],
- 'member_headimg' => $data[ 'member_headimg' ],
- 'is_anonymous' => 1,
- 'order_goods_id' => 0,
- 'goods_id' => $v[ 'goods_id' ],
- 'sku_id' => $v[ 'sku_id' ],
- 'site_id' => $site_id,
- 'sku_name' => $v[ 'goods_name' ],
- 'sku_price' => $v[ 'price' ],
- 'sku_image' => explode(',', $v[ 'goods_image' ])[ 0 ],
- 'content' => !empty($data[ 'content' ]) ? $data[ 'content' ] : '此用户没有填写评价。',
- 'images' => $data[ 'pingjia_img' ],
- 'scores' => $data[ 'dengji' ],
- 'explain_type' => $evaluate_type,
- 'is_audit' => $order_evaluate_config[ 'evaluate_audit' ] == 1 ? 0 : 1,
- 'create_time' => date_to_time($data[ 'evaluate_time' ]),
- ];
- $data_arr[] = $item;
-
- $evaluate = 0; //评价
- $evaluate_shaitu = 0; //晒图
- $evaluate_shipin = 0; //视频
- $evaluate_haoping = 0; //好评
- $evaluate_zhongping = 0; //中评
- $evaluate_chaping = 0; //差评
- $wait_evaluate_num = 0; //待审核数
- $success_evaluate_num = 1;
-
- if ($order_evaluate_config[ 'evaluate_audit' ] == 1) {
- $wait_evaluate_num = 1; //待审核数
- $success_evaluate_num = 0;
- } else {
- if ($evaluate_type == 1) {
- //好评
- $evaluate = 1; //评价
- $evaluate_haoping = 1; //好评
-
- } elseif ($evaluate_type == 2) {
- //中评
- $evaluate = 1; //评价
- $evaluate_zhongping = 1; //中评
-
- } elseif ($evaluate_type == 3) {
- //差评
- $evaluate = 1; //评价
- $evaluate_chaping = 1; //差评
- }
- if (!empty($data[ 'pingjia_img' ])) {
- $evaluate_shaitu = 1; //晒图
- }
- }
-
- Db::name('goods')->where([ [ 'goods_id', '=', $v[ 'goods_id' ] ] ])
- ->update(
- [
- "evaluate" => Db::raw('evaluate+' . $evaluate),
- "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
- "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
- "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
- "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
- "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
- "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
- ]);
- Db::name('goods_sku')->where([ [ 'sku_id', '=', $v[ 'sku_id' ] ] ])
- ->update(
- [
- "evaluate" => Db::raw('evaluate+' . $evaluate),
- "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
- "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
- "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
- "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
- "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
- "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
- ]);
- }
- $evaluate_id = model('goods_evaluate')->addList($data_arr);
- Cache::tag('goods_evaluate')->clear();
- return $this->success($evaluate_id);
- } else {
- return $this->error();
- }
-
- }
-
- public function batghAdd($data, $site_id)
- {
- $config_model = new ConfigModel();
- //订单评价设置
- $order_evaluate_config = $config_model->getOrderEvaluateConfig($site_id)[ 'data' ][ 'value' ];
-
- //虚拟评价不需要审核
- $order_evaluate_config[ 'evaluate_audit' ] = 0;
-
- $content_list = model('stock_content')->getList([ [ 'site_id', '=', $site_id ], [ 'stock_id', '=', $data[ 'stock_id' ] ] ], 'content');
- $pic_list = model('album_pic')->getList([ [ 'site_id', '=', $site_id ], [ 'album_id', '=', $data[ 'album_id' ] ] ], 'pic_path');
- $goods_data = model('goods')->getInfo([ [ 'goods_id', '=', $data[ 'goods_id' ] ], [ 'site_id', '=', $site_id ] ], 'sku_id,goods_id,goods_name,price,goods_image');
- if ($data[ 'number' ] > 100 || $data[ 'number' ] < 1) {
- return $this->error([], '评价数量大于1且小于100条');
- }
- if ($data[ 'number' ] >= 1) {
- for ($i = 0; $i < $data[ 'number' ]; $i++) {
- $dengji[ $i ] = $data[ 'pingfen' ][ array_rand($data[ 'pingfen' ]) ];
-
- if ($dengji[ $i ] == 1) {
- $evaluate_type[ $i ] = 3;
- } else if ($dengji[ $i ] == 2 || $dengji[ $i ] == 3) {
- $evaluate_type[ $i ] = 2;
- } else if ($dengji[ $i ] == 4 || $dengji[ $i ] == 5) {
- $evaluate_type[ $i ] = 1;
- }
-
- $item = [
- 'order_id' => 0,
- 'order_no' => 0,
- 'member_id' => 0,
- 'member_name' => $this->randNickName(),
- 'member_headimg' => $pic_list[ array_rand($pic_list) ][ 'pic_path' ],
- 'is_anonymous' => 1,
- 'order_goods_id' => 0,
- 'goods_id' => $goods_data[ 'goods_id' ],
- 'sku_id' => $goods_data[ 'sku_id' ],
- 'site_id' => $site_id,
- 'sku_name' => $goods_data[ 'goods_name' ],
- 'sku_price' => $goods_data[ 'price' ],
- 'sku_image' => explode(',', $goods_data[ 'goods_image' ])[ 0 ],
- 'content' => $content_list[ array_rand($content_list) ][ 'content' ],
- 'images' => '',
- 'scores' => $dengji[ $i ],
- 'explain_type' => $evaluate_type[ $i ],
- 'is_audit' => $order_evaluate_config[ 'evaluate_audit' ] == 1 ? 0 : 1,
- 'create_time' => mt_rand($data[ 'start_time' ], $data[ 'end_time' ]),
- ];
- $data_arr[] = $item;
-
- $evaluate = 0; //评价
- $evaluate_shaitu = 0; //晒图
- $evaluate_shipin = 0; //视频
- $evaluate_haoping = 0; //好评
- $evaluate_zhongping = 0; //中评
- $evaluate_chaping = 0; //差评
- $wait_evaluate_num = 0; //待审核数
- $success_evaluate_num = 1;
-
- if ($order_evaluate_config[ 'evaluate_audit' ] == 1) {
- $wait_evaluate_num = 1; //待审核数
- $success_evaluate_num = 0;
- } else {
- if ($evaluate_type[ $i ] == 1) {
- //好评
- $evaluate = 1; //评价
- $evaluate_haoping = 1; //好评
-
- } elseif ($evaluate_type[ $i ] == 2) {
- //中评
- $evaluate = 1; //评价
- $evaluate_zhongping = 1; //中评
-
- } elseif ($evaluate_type[ $i ] == 3) {
- //差评
- $evaluate = 1; //评价
- $evaluate_chaping = 1; //差评
- }
- if (!empty($item[ 'images' ])) {
- $evaluate_shaitu = 1; //晒图
- }
- }
-
- Db::name('goods')->where([ [ 'goods_id', '=', $goods_data[ 'goods_id' ] ] ])
- ->update(
- [
- "evaluate" => Db::raw('evaluate+' . $evaluate),
- "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
- "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
- "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
- "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
- "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
- "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
- ]);
- Db::name('goods_sku')->where([ [ 'sku_id', '=', $goods_data[ 'sku_id' ] ] ])
- ->update(
- [
- "evaluate" => Db::raw('evaluate+' . $evaluate),
- "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
- "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
- "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
- "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
- "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
- "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
- ]);
- }
- $evaluate_id = model('goods_evaluate')->addList($data_arr);
- Cache::tag('goods_evaluate')->clear();
- return $this->success($evaluate_id);
- } else {
- return $this->error();
- }
-
- }
-
- private function randNickName()
- {
- $nicheng_tou = array ( '快乐的', '冷静的', '醉熏的', '潇洒的', '糊涂的', '积极的', '冷酷的', '深情的', '粗暴的',
- '温柔的', '可爱的', '愉快的', '义气的', '认真的', '威武的', '帅气的', '传统的', '潇洒的', '漂亮的', '自然的',
- '专一的', '听话的', '昏睡的', '狂野的', '等待的', '搞怪的', '幽默的', '魁梧的', '活泼的', '开心的', '高兴的',
- '超帅的', '留胡子的', '坦率的', '直率的', '轻松的', '痴情的', '完美的', '精明的',
- '无聊的', '有魅力的', '丰富的', '繁荣的', '饱满的', '炙热的', '暴躁的', '碧蓝的', '俊逸的',
- '英勇的', '健忘的', '故意的', '无心的', '土豪的', '朴实的', '兴奋的', '幸福的', '淡定的', '不安的',
- '阔达的', '孤独的', '独特的', '疯狂的', '时尚的', '落后的', '风趣的', '忧伤的', '大胆的', '爱笑的', '矮小的',
- '健康的', '合适的', '玩命的', '沉默的', '斯文的', '香蕉', '苹果', '鲤鱼', '鳗鱼', '任性的', '细心的', '粗心的',
- '大意的', '甜甜的', '酷酷的', '健壮的', '英俊的', '霸气的', '阳光的', '默默的', '大力的', '孝顺的', '忧虑的', '着急的',
- '紧张的', '善良的', '凶狠的', '害怕的', '重要的', '危机的', '欢喜的', '欣慰的', '满意的', '跳跃的', '诚心的', '称心的',
- '如意的', '怡然的', '娇气的', '无奈的', '无语的', '激动的', '愤怒的', '美好的', '感动的', '激情的', '激昂的', '震动的',
- '虚拟的', '超级的', '寒冷的', '精明的', '明理的', '犹豫的', '忧郁的', '寂寞的', '奋斗的', '勤奋的', '现代的', '过时的',
- '稳重的', '热情的', '含蓄的', '开放的', '无辜的', '多情的', '纯真的', '拉长的', '热心的', '从容的', '体贴的', '风中的',
- '曾经的', '追寻的', '儒雅的', '优雅的', '开朗的', '外向的', '内向的', '清爽的', '文艺的', '长情的', '平常的', '单身的',
- '伶俐的', '高大的', '懦弱的', '柔弱的', '爱笑的', '乐观的', '耍酷的', '酷炫的', '神勇的', '年轻的', '唠叨的', '瘦瘦的',
- '无情的', '包容的', '顺心的', '畅快的', '舒适的', '靓丽的', '负责的', '背后的', '简单的', '谦让的', '彩色的', '缥缈的',
- '欢呼的', '生动的', '复杂的', '慈祥的', '仁爱的', '魔幻的', '虚幻的', '淡然的', '受伤的', '雪白的', '高高的', '糟糕的',
- '顺利的', '闪闪的', '羞涩的', '缓慢的', '迅速的', '优秀的', '聪明的', '含糊的', '俏皮的', '淡淡的', '坚强的', '平淡的',
- '欣喜的', '能干的', '灵巧的', '友好的', '机智的', '机灵的', '正直的', '谨慎的', '俭朴的', '殷勤的', '虚心的', '辛勤的',
- '自觉的', '无私的', '无限的', '踏实的', '老实的', '现实的', '可靠的', '务实的', '拼搏的', '个性的', '粗犷的', '活力的',
- '成就的', '勤劳的', '单纯的', '落寞的', '朴素的', '悲凉的', '忧心的', '洁净的', '清秀的', '自由的', '小巧的', '单薄的',
- '贪玩的', '刻苦的', '干净的', '壮观的', '和谐的', '文静的', '调皮的', '害羞的', '安详的', '自信的', '端庄的', '坚定的',
- '美满的', '舒心的', '温暖的', '专注的', '勤恳的', '美丽的', '腼腆的', '优美的', '甜美的', '甜蜜的', '整齐的', '动人的',
- '典雅的', '尊敬的', '舒服的', '妩媚的', '秀丽的', '喜悦的', '甜美的', '彪壮的', '强健的', '大方的', '俊秀的', '聪慧的',
- '迷人的', '陶醉的', '悦耳的', '动听的', '明亮的', '结实的', '魁梧的', '标致的', '清脆的', '敏感的', '光亮的', '大气的',
- '老迟到的', '知性的', '冷傲的', '呆萌的', '野性的', '隐形的', '笑点低的', '微笑的', '笨笨的', '难过的', '沉静的', '火星上的',
- '失眠的', '安静的', '纯情的', '要减肥的', '迷路的', '烂漫的', '哭泣的', '贤惠的', '苗条的', '温婉的', '发嗲的', '会撒娇的',
- '贪玩的', '执着的', '眯眯眼的', '花痴的', '想人陪的', '眼睛大的', '高贵的', '傲娇的', '心灵美的', '爱撒娇的', '细腻的', '天真的',
- '怕黑的', '感性的', '飘逸的', '怕孤独的', '忐忑的', '高挑的', '傻傻的', '冷艳的', '爱听歌的', '还单身的', '怕孤单的', '懵懂的' );
-
- $nicheng_wei = array ( '嚓茶', '凉面', '便当', '毛豆', '花生', '可乐', '灯泡', '哈密瓜', '野狼', '背包', '眼神', '缘分', '雪碧',
- '人生', '牛排', '蚂蚁', '飞鸟', '灰狼', '斑马', '汉堡', '悟空', '巨人', '绿茶', '自行车', '保温杯', '大碗', '墨镜', '魔镜',
- '煎饼', '月饼', '月亮', '星星', '芝麻', '啤酒', '玫瑰', '大叔', '小伙', '哈密瓜,数据线', '太阳', '树叶', '芹菜', '黄蜂', '蜜粉',
- '蜜蜂', '信封', '西装', '外套', '裙子', '大象', '猫咪', '母鸡', '路灯', '蓝天', '白云', '星月', '彩虹', '微笑', '摩托', '板栗', '高山',
- '大地', '大树', '电灯胆', '砖头', '楼房', '水池', '鸡翅', '蜻蜓', '红牛', '咖啡', '机器猫', '枕头', '大船', '诺言', '钢笔', '刺猬', '天空',
- '飞机', '大炮', '冬天', '洋葱', '春天', '夏天', '秋天', '冬日', '航空', '毛衣', '豌豆', '黑米', '玉米', '眼睛', '老鼠', '白羊', '帅哥', '美女',
- '季节', '鲜花', '服饰', '裙子', '白开水', '秀发', '大山', '火车', '汽车', '歌曲', '舞蹈', '老师', '导师', '方盒', '大米', '麦片', '水杯', '水壶',
- '手套', '鞋子', '自行车', '鼠标', '手机', '电脑', '书本', '奇迹', '身影', '香烟', '夕阳', '台灯', '宝贝', '未来', '皮带', '钥匙', '心锁', '故事',
- '花瓣', '滑板', '画笔', '画板', '学姐', '店员', '电源', '饼干', '宝马', '过客', '大白', '时光', '石头', '钻石', '河马', '犀牛', '西牛', '绿草',
- '抽屉', '柜子', '往事', '寒风', '路人', '橘子', '耳机', '鸵鸟', '朋友', '苗条', '铅笔', '钢笔', '硬币', '热狗', '大侠', '御姐', '萝莉', '毛巾',
- '期待', '盼望', '白昼', '黑夜', '大门', '黑裤', '钢铁侠', '哑铃', '板凳', '枫叶', '荷花', '乌龟', '仙人掌', '衬衫', '大神', '草丛', '早晨', '心情',
- '茉莉', '流沙', '蜗牛', '战斗机', '冥王星', '猎豹', '棒球', '篮球', '乐曲', '电话', '网络', '世界', '中心', '鱼', '鸡', '狗', '老虎', '鸭子', '雨',
- '羽毛', '翅膀', '外套', '火', '丝袜', '书包', '钢笔', '冷风', '八宝粥', '烤鸡', '大雁', '音响', '招牌', '胡萝卜', '冰棍', '帽子', '菠萝', '蛋挞', '香水',
- '泥猴桃', '吐司', '溪流', '黄豆', '樱桃', '小鸽子', '小蝴蝶', '爆米花', '花卷', '小鸭子', '小海豚', '日记本', '小熊猫', '小懒猪', '小懒虫', '荔枝', '镜子',
- '曲奇', '金针菇', '小松鼠', '小虾米', '酒窝', '紫菜', '金鱼', '柚子', '果汁', '百褶裙', '项链', '帆布鞋', '火龙果', '奇异果', '煎蛋', '唇彩', '小土豆', '高跟鞋',
- '戒指', '雪糕', '睫毛', '铃铛', '手链', '香氛', '红酒', '月光', '酸奶', '银耳汤', '咖啡豆', '小蜜蜂', '小蚂蚁', '蜡烛', '棉花糖', '向日葵', '水蜜桃', '小蝴蝶',
- '小刺猬', '小丸子', '指甲油', '康乃馨', '糖豆', '薯片', '口红', '超短裙', '乌冬面', '冰淇淋', '棒棒糖', '长颈鹿', '豆芽', '发箍', '发卡', '发夹', '发带', '铃铛',
- '小馒头', '小笼包', '小甜瓜', '冬瓜', '香菇', '小兔子', '含羞草', '短靴', '睫毛膏', '小蘑菇', '跳跳糖', '小白菜', '草莓', '柠檬', '月饼', '百合', '纸鹤', '小天鹅',
- '云朵', '芒果', '面包', '海燕', '小猫咪', '龙猫', '唇膏', '鞋垫', '羊', '黑猫', '白猫', '万宝路', '金毛', '山水', '音响' );
-
- $tou_num = rand(0, 331);
-
- $wei_num = rand(0, 325);
-
- $nicheng = $nicheng_tou[ $tou_num ] . $nicheng_wei[ $wei_num ];
-
- return $nicheng; //输出生成的昵称
- }
+getOrderEvaluateConfig($site_id)[ 'data' ][ 'value' ];
+
+ if ($data[ 'dengji' ] == 1) {
+ $evaluate_type = 3;
+ } else if ($data[ 'dengji' ] == 2 || $data[ 'dengji' ] == 3) {
+ $evaluate_type = 2;
+ } else if ($data[ 'dengji' ] == 4 || $data[ 'dengji' ] == 5) {
+ $evaluate_type = 1;
+ }
+ // 虚拟评价不需要审核
+ $order_evaluate_config[ 'evaluate_audit' ] = 0;
+
+ if (!empty($data[ 'goods_data' ])) {
+ foreach ($data[ 'goods_data' ] as $k => $v) {
+ $item = [
+ 'order_id' => 0,
+ 'order_no' => 0,
+ 'member_id' => 0,
+ 'member_name' => $data[ 'member_name' ],
+ 'member_headimg' => $data[ 'member_headimg' ],
+ 'is_anonymous' => 1,
+ 'order_goods_id' => 0,
+ 'goods_id' => $v[ 'goods_id' ],
+ 'sku_id' => $v[ 'sku_id' ],
+ 'site_id' => $site_id,
+ 'sku_name' => $v[ 'goods_name' ],
+ 'sku_price' => $v[ 'price' ],
+ 'sku_image' => explode(',', $v[ 'goods_image' ])[ 0 ],
+ 'content' => !empty($data[ 'content' ]) ? $data[ 'content' ] : '此用户没有填写评价。',
+ 'images' => $data[ 'pingjia_img' ],
+ 'scores' => $data[ 'dengji' ],
+ 'explain_type' => $evaluate_type,
+ 'is_audit' => $order_evaluate_config[ 'evaluate_audit' ] == 1 ? 0 : 1,
+ 'create_time' => date_to_time($data[ 'evaluate_time' ]),
+ ];
+ $data_arr[] = $item;
+
+ $evaluate = 0; //评价
+ $evaluate_shaitu = 0; //晒图
+ $evaluate_shipin = 0; //视频
+ $evaluate_haoping = 0; //好评
+ $evaluate_zhongping = 0; //中评
+ $evaluate_chaping = 0; //差评
+ $wait_evaluate_num = 0; //待审核数
+ $success_evaluate_num = 1;
+
+ if ($order_evaluate_config[ 'evaluate_audit' ] == 1) {
+ $wait_evaluate_num = 1; //待审核数
+ $success_evaluate_num = 0;
+ } else {
+ if ($evaluate_type == 1) {
+ //好评
+ $evaluate = 1; //评价
+ $evaluate_haoping = 1; //好评
+
+ } elseif ($evaluate_type == 2) {
+ //中评
+ $evaluate = 1; //评价
+ $evaluate_zhongping = 1; //中评
+
+ } elseif ($evaluate_type == 3) {
+ //差评
+ $evaluate = 1; //评价
+ $evaluate_chaping = 1; //差评
+ }
+ if (!empty($data[ 'pingjia_img' ])) {
+ $evaluate_shaitu = 1; //晒图
+ }
+ }
+
+ Db::name('goods')->where([ [ 'goods_id', '=', $v[ 'goods_id' ] ] ])
+ ->update(
+ [
+ "evaluate" => Db::raw('evaluate+' . $evaluate),
+ "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
+ "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
+ "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
+ "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
+ "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
+ "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
+ ]);
+ Db::name('goods_sku')->where([ [ 'sku_id', '=', $v[ 'sku_id' ] ] ])
+ ->update(
+ [
+ "evaluate" => Db::raw('evaluate+' . $evaluate),
+ "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
+ "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
+ "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
+ "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
+ "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
+ "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
+ ]);
+ }
+ $evaluate_id = model('goods_evaluate')->addList($data_arr);
+ Cache::tag('goods_evaluate')->clear();
+ return $this->success($evaluate_id);
+ } else {
+ return $this->error();
+ }
+
+ }
+
+ public function batghAdd($data, $site_id)
+ {
+ $config_model = new ConfigModel();
+ //订单评价设置
+ $order_evaluate_config = $config_model->getOrderEvaluateConfig($site_id)[ 'data' ][ 'value' ];
+
+ //虚拟评价不需要审核
+ $order_evaluate_config[ 'evaluate_audit' ] = 0;
+
+ $content_list = model('stock_content')->getList([ [ 'site_id', '=', $site_id ], [ 'stock_id', '=', $data[ 'stock_id' ] ] ], 'content');
+ $pic_list = model('album_pic')->getList([ [ 'site_id', '=', $site_id ], [ 'album_id', '=', $data[ 'album_id' ] ] ], 'pic_path');
+ $goods_data = model('goods')->getInfo([ [ 'goods_id', '=', $data[ 'goods_id' ] ], [ 'site_id', '=', $site_id ] ], 'sku_id,goods_id,goods_name,price,goods_image');
+ if ($data[ 'number' ] > 100 || $data[ 'number' ] < 1) {
+ return $this->error([], '评价数量大于1且小于100条');
+ }
+ if ($data[ 'number' ] >= 1) {
+ for ($i = 0; $i < $data[ 'number' ]; $i++) {
+ $dengji[ $i ] = $data[ 'pingfen' ][ array_rand($data[ 'pingfen' ]) ];
+
+ if ($dengji[ $i ] == 1) {
+ $evaluate_type[ $i ] = 3;
+ } else if ($dengji[ $i ] == 2 || $dengji[ $i ] == 3) {
+ $evaluate_type[ $i ] = 2;
+ } else if ($dengji[ $i ] == 4 || $dengji[ $i ] == 5) {
+ $evaluate_type[ $i ] = 1;
+ }
+
+ $item = [
+ 'order_id' => 0,
+ 'order_no' => 0,
+ 'member_id' => 0,
+ 'member_name' => $this->randNickName(),
+ 'member_headimg' => $pic_list[ array_rand($pic_list) ][ 'pic_path' ],
+ 'is_anonymous' => 1,
+ 'order_goods_id' => 0,
+ 'goods_id' => $goods_data[ 'goods_id' ],
+ 'sku_id' => $goods_data[ 'sku_id' ],
+ 'site_id' => $site_id,
+ 'sku_name' => $goods_data[ 'goods_name' ],
+ 'sku_price' => $goods_data[ 'price' ],
+ 'sku_image' => explode(',', $goods_data[ 'goods_image' ])[ 0 ],
+ 'content' => $content_list[ array_rand($content_list) ][ 'content' ],
+ 'images' => '',
+ 'scores' => $dengji[ $i ],
+ 'explain_type' => $evaluate_type[ $i ],
+ 'is_audit' => $order_evaluate_config[ 'evaluate_audit' ] == 1 ? 0 : 1,
+ 'create_time' => mt_rand($data[ 'start_time' ], $data[ 'end_time' ]),
+ ];
+ $data_arr[] = $item;
+
+ $evaluate = 0; //评价
+ $evaluate_shaitu = 0; //晒图
+ $evaluate_shipin = 0; //视频
+ $evaluate_haoping = 0; //好评
+ $evaluate_zhongping = 0; //中评
+ $evaluate_chaping = 0; //差评
+ $wait_evaluate_num = 0; //待审核数
+ $success_evaluate_num = 1;
+
+ if ($order_evaluate_config[ 'evaluate_audit' ] == 1) {
+ $wait_evaluate_num = 1; //待审核数
+ $success_evaluate_num = 0;
+ } else {
+ if ($evaluate_type[ $i ] == 1) {
+ //好评
+ $evaluate = 1; //评价
+ $evaluate_haoping = 1; //好评
+
+ } elseif ($evaluate_type[ $i ] == 2) {
+ //中评
+ $evaluate = 1; //评价
+ $evaluate_zhongping = 1; //中评
+
+ } elseif ($evaluate_type[ $i ] == 3) {
+ //差评
+ $evaluate = 1; //评价
+ $evaluate_chaping = 1; //差评
+ }
+ if (!empty($item[ 'images' ])) {
+ $evaluate_shaitu = 1; //晒图
+ }
+ }
+
+ Db::name('goods')->where([ [ 'goods_id', '=', $goods_data[ 'goods_id' ] ] ])
+ ->update(
+ [
+ "evaluate" => Db::raw('evaluate+' . $evaluate),
+ "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
+ "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
+ "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
+ "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
+ "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
+ "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
+ ]);
+ Db::name('goods_sku')->where([ [ 'sku_id', '=', $goods_data[ 'sku_id' ] ] ])
+ ->update(
+ [
+ "evaluate" => Db::raw('evaluate+' . $evaluate),
+ "evaluate_shaitu" => Db::raw('evaluate_shaitu+' . $evaluate_shaitu),
+ "evaluate_haoping" => Db::raw('evaluate_haoping+' . $evaluate_haoping),
+ "evaluate_zhongping" => Db::raw('evaluate_zhongping+' . $evaluate_zhongping),
+ "evaluate_chaping" => Db::raw('evaluate_chaping+' . $evaluate_chaping),
+ "wait_evaluate_num" => Db::raw('wait_evaluate_num+' . $wait_evaluate_num),
+ "success_evaluate_num" => Db::raw('success_evaluate_num+' . $success_evaluate_num),
+ ]);
+ }
+ $evaluate_id = model('goods_evaluate')->addList($data_arr);
+ Cache::tag('goods_evaluate')->clear();
+ return $this->success($evaluate_id);
+ } else {
+ return $this->error();
+ }
+
+ }
+
+ private function randNickName()
+ {
+ $nicheng_tou = array ( '快乐的', '冷静的', '醉熏的', '潇洒的', '糊涂的', '积极的', '冷酷的', '深情的', '粗暴的',
+ '温柔的', '可爱的', '愉快的', '义气的', '认真的', '威武的', '帅气的', '传统的', '潇洒的', '漂亮的', '自然的',
+ '专一的', '听话的', '昏睡的', '狂野的', '等待的', '搞怪的', '幽默的', '魁梧的', '活泼的', '开心的', '高兴的',
+ '超帅的', '留胡子的', '坦率的', '直率的', '轻松的', '痴情的', '完美的', '精明的',
+ '无聊的', '有魅力的', '丰富的', '繁荣的', '饱满的', '炙热的', '暴躁的', '碧蓝的', '俊逸的',
+ '英勇的', '健忘的', '故意的', '无心的', '土豪的', '朴实的', '兴奋的', '幸福的', '淡定的', '不安的',
+ '阔达的', '孤独的', '独特的', '疯狂的', '时尚的', '落后的', '风趣的', '忧伤的', '大胆的', '爱笑的', '矮小的',
+ '健康的', '合适的', '玩命的', '沉默的', '斯文的', '香蕉', '苹果', '鲤鱼', '鳗鱼', '任性的', '细心的', '粗心的',
+ '大意的', '甜甜的', '酷酷的', '健壮的', '英俊的', '霸气的', '阳光的', '默默的', '大力的', '孝顺的', '忧虑的', '着急的',
+ '紧张的', '善良的', '凶狠的', '害怕的', '重要的', '危机的', '欢喜的', '欣慰的', '满意的', '跳跃的', '诚心的', '称心的',
+ '如意的', '怡然的', '娇气的', '无奈的', '无语的', '激动的', '愤怒的', '美好的', '感动的', '激情的', '激昂的', '震动的',
+ '虚拟的', '超级的', '寒冷的', '精明的', '明理的', '犹豫的', '忧郁的', '寂寞的', '奋斗的', '勤奋的', '现代的', '过时的',
+ '稳重的', '热情的', '含蓄的', '开放的', '无辜的', '多情的', '纯真的', '拉长的', '热心的', '从容的', '体贴的', '风中的',
+ '曾经的', '追寻的', '儒雅的', '优雅的', '开朗的', '外向的', '内向的', '清爽的', '文艺的', '长情的', '平常的', '单身的',
+ '伶俐的', '高大的', '懦弱的', '柔弱的', '爱笑的', '乐观的', '耍酷的', '酷炫的', '神勇的', '年轻的', '唠叨的', '瘦瘦的',
+ '无情的', '包容的', '顺心的', '畅快的', '舒适的', '靓丽的', '负责的', '背后的', '简单的', '谦让的', '彩色的', '缥缈的',
+ '欢呼的', '生动的', '复杂的', '慈祥的', '仁爱的', '魔幻的', '虚幻的', '淡然的', '受伤的', '雪白的', '高高的', '糟糕的',
+ '顺利的', '闪闪的', '羞涩的', '缓慢的', '迅速的', '优秀的', '聪明的', '含糊的', '俏皮的', '淡淡的', '坚强的', '平淡的',
+ '欣喜的', '能干的', '灵巧的', '友好的', '机智的', '机灵的', '正直的', '谨慎的', '俭朴的', '殷勤的', '虚心的', '辛勤的',
+ '自觉的', '无私的', '无限的', '踏实的', '老实的', '现实的', '可靠的', '务实的', '拼搏的', '个性的', '粗犷的', '活力的',
+ '成就的', '勤劳的', '单纯的', '落寞的', '朴素的', '悲凉的', '忧心的', '洁净的', '清秀的', '自由的', '小巧的', '单薄的',
+ '贪玩的', '刻苦的', '干净的', '壮观的', '和谐的', '文静的', '调皮的', '害羞的', '安详的', '自信的', '端庄的', '坚定的',
+ '美满的', '舒心的', '温暖的', '专注的', '勤恳的', '美丽的', '腼腆的', '优美的', '甜美的', '甜蜜的', '整齐的', '动人的',
+ '典雅的', '尊敬的', '舒服的', '妩媚的', '秀丽的', '喜悦的', '甜美的', '彪壮的', '强健的', '大方的', '俊秀的', '聪慧的',
+ '迷人的', '陶醉的', '悦耳的', '动听的', '明亮的', '结实的', '魁梧的', '标致的', '清脆的', '敏感的', '光亮的', '大气的',
+ '老迟到的', '知性的', '冷傲的', '呆萌的', '野性的', '隐形的', '笑点低的', '微笑的', '笨笨的', '难过的', '沉静的', '火星上的',
+ '失眠的', '安静的', '纯情的', '要减肥的', '迷路的', '烂漫的', '哭泣的', '贤惠的', '苗条的', '温婉的', '发嗲的', '会撒娇的',
+ '贪玩的', '执着的', '眯眯眼的', '花痴的', '想人陪的', '眼睛大的', '高贵的', '傲娇的', '心灵美的', '爱撒娇的', '细腻的', '天真的',
+ '怕黑的', '感性的', '飘逸的', '怕孤独的', '忐忑的', '高挑的', '傻傻的', '冷艳的', '爱听歌的', '还单身的', '怕孤单的', '懵懂的' );
+
+ $nicheng_wei = array ( '嚓茶', '凉面', '便当', '毛豆', '花生', '可乐', '灯泡', '哈密瓜', '野狼', '背包', '眼神', '缘分', '雪碧',
+ '人生', '牛排', '蚂蚁', '飞鸟', '灰狼', '斑马', '汉堡', '悟空', '巨人', '绿茶', '自行车', '保温杯', '大碗', '墨镜', '魔镜',
+ '煎饼', '月饼', '月亮', '星星', '芝麻', '啤酒', '玫瑰', '大叔', '小伙', '哈密瓜,数据线', '太阳', '树叶', '芹菜', '黄蜂', '蜜粉',
+ '蜜蜂', '信封', '西装', '外套', '裙子', '大象', '猫咪', '母鸡', '路灯', '蓝天', '白云', '星月', '彩虹', '微笑', '摩托', '板栗', '高山',
+ '大地', '大树', '电灯胆', '砖头', '楼房', '水池', '鸡翅', '蜻蜓', '红牛', '咖啡', '机器猫', '枕头', '大船', '诺言', '钢笔', '刺猬', '天空',
+ '飞机', '大炮', '冬天', '洋葱', '春天', '夏天', '秋天', '冬日', '航空', '毛衣', '豌豆', '黑米', '玉米', '眼睛', '老鼠', '白羊', '帅哥', '美女',
+ '季节', '鲜花', '服饰', '裙子', '白开水', '秀发', '大山', '火车', '汽车', '歌曲', '舞蹈', '老师', '导师', '方盒', '大米', '麦片', '水杯', '水壶',
+ '手套', '鞋子', '自行车', '鼠标', '手机', '电脑', '书本', '奇迹', '身影', '香烟', '夕阳', '台灯', '宝贝', '未来', '皮带', '钥匙', '心锁', '故事',
+ '花瓣', '滑板', '画笔', '画板', '学姐', '店员', '电源', '饼干', '宝马', '过客', '大白', '时光', '石头', '钻石', '河马', '犀牛', '西牛', '绿草',
+ '抽屉', '柜子', '往事', '寒风', '路人', '橘子', '耳机', '鸵鸟', '朋友', '苗条', '铅笔', '钢笔', '硬币', '热狗', '大侠', '御姐', '萝莉', '毛巾',
+ '期待', '盼望', '白昼', '黑夜', '大门', '黑裤', '钢铁侠', '哑铃', '板凳', '枫叶', '荷花', '乌龟', '仙人掌', '衬衫', '大神', '草丛', '早晨', '心情',
+ '茉莉', '流沙', '蜗牛', '战斗机', '冥王星', '猎豹', '棒球', '篮球', '乐曲', '电话', '网络', '世界', '中心', '鱼', '鸡', '狗', '老虎', '鸭子', '雨',
+ '羽毛', '翅膀', '外套', '火', '丝袜', '书包', '钢笔', '冷风', '八宝粥', '烤鸡', '大雁', '音响', '招牌', '胡萝卜', '冰棍', '帽子', '菠萝', '蛋挞', '香水',
+ '泥猴桃', '吐司', '溪流', '黄豆', '樱桃', '小鸽子', '小蝴蝶', '爆米花', '花卷', '小鸭子', '小海豚', '日记本', '小熊猫', '小懒猪', '小懒虫', '荔枝', '镜子',
+ '曲奇', '金针菇', '小松鼠', '小虾米', '酒窝', '紫菜', '金鱼', '柚子', '果汁', '百褶裙', '项链', '帆布鞋', '火龙果', '奇异果', '煎蛋', '唇彩', '小土豆', '高跟鞋',
+ '戒指', '雪糕', '睫毛', '铃铛', '手链', '香氛', '红酒', '月光', '酸奶', '银耳汤', '咖啡豆', '小蜜蜂', '小蚂蚁', '蜡烛', '棉花糖', '向日葵', '水蜜桃', '小蝴蝶',
+ '小刺猬', '小丸子', '指甲油', '康乃馨', '糖豆', '薯片', '口红', '超短裙', '乌冬面', '冰淇淋', '棒棒糖', '长颈鹿', '豆芽', '发箍', '发卡', '发夹', '发带', '铃铛',
+ '小馒头', '小笼包', '小甜瓜', '冬瓜', '香菇', '小兔子', '含羞草', '短靴', '睫毛膏', '小蘑菇', '跳跳糖', '小白菜', '草莓', '柠檬', '月饼', '百合', '纸鹤', '小天鹅',
+ '云朵', '芒果', '面包', '海燕', '小猫咪', '龙猫', '唇膏', '鞋垫', '羊', '黑猫', '白猫', '万宝路', '金毛', '山水', '音响' );
+
+ $tou_num = rand(0, 331);
+
+ $wei_num = rand(0, 325);
+
+ $nicheng = $nicheng_tou[ $tou_num ] . $nicheng_wei[ $wei_num ];
+
+ return $nicheng; //输出生成的昵称
+ }
}
\ No newline at end of file
diff --git a/src/addon/virtualevaluation/model/VirtualStock.php b/src/addon/virtualevaluation/model/VirtualStock.php
index 399bf9fec..334f91cbd 100644
--- a/src/addon/virtualevaluation/model/VirtualStock.php
+++ b/src/addon/virtualevaluation/model/VirtualStock.php
@@ -1,186 +1,178 @@
-pageList($condition, $field, $order, $page, $page_size);
- return $this->success($list);
- }
-
- /**
- * 添加虚拟评价库分页列表
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function addStock($data)
- {
- $stock_id = model('virtual_stock')->add($data);
- return $this->success($stock_id);
- }
-
- /**
- * 删除虚拟评价库
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function deleteStock($stock_id, $site_id)
- {
- $stock_id = model('virtual_stock')->delete([ [ 'stock_id', '=', $stock_id ], [ 'site_id', '=', $site_id ] ]);
-
- return $this->success($stock_id);
- }
-
- /**
- * 更新虚拟评价库
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function updateStock($data, $site_id)
- {
- $stock_id = model('virtual_stock')->update($data, [ [ 'stock_id', '=', $data[ 'stock_id' ] ], [ 'site_id', '=', $site_id ] ]);
-
- return $this->success($stock_id);
- }
-
- /**
- * 获取虚拟评价库信息
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function getStockInfo($stock_id, $site_id)
- {
- $stock_info = model('virtual_stock')->getInfo([ [ 'stock_id', '=', $stock_id ], [ 'site_id', '=', $site_id ] ], '*');
-
- return $this->success($stock_info);
- }
-
- /**
- * 获取虚拟评价库信息
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function getContentsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*')
- {
- $list = model('stock_content')->pageList($condition, $field, $order, $page, $page_size);
- return $this->success($list);
- }
-
- /**
- * 添加虚拟评价库评论
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function addContent($data)
- {
- $stock_id = model('stock_content')->add($data);
- if ($stock_id) {
- model("virtual_stock")->setInc([ [ 'stock_id', '=', $data[ 'stock_id' ] ] ], "num", 1);
- }
- return $this->success($stock_id);
- }
-
- /**
- * 删除虚拟评价库评论
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function deleteContent($id, $site_id)
- {
- $stock_data = model('stock_content')->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'stock_id');
- model("virtual_stock")->setDec([ [ 'stock_id', '=', $stock_data[ 'stock_id' ] ] ], "num", 1);
-
- $stock_id = model('stock_content')->delete([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ]);
-
- return $this->success($stock_id);
- }
-
- /**
- * 获取虚拟评价库信息
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function getContentInfo($id, $site_id)
- {
- $stock_info = model('stock_content')->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], '*');
-
- return $this->success($stock_info);
- }
-
- /**
- * 修改虚拟评价库信息
- * @param array $condition
- * @param number $page
- * @param string $page_size
- * @param string $order
- * @param string $field
- */
- public function editContentInfo($data, $site_id)
- {
- $content_info = model('stock_content')->update($data, [ [ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $site_id ] ]);
-
- return $this->success($content_info);
- }
-
- /**
- * 获取评论库列表
- * @param array $condition
- * @param string $field
- * @param string $order
- * @param null $limit
- * @return array
- */
- public function getStockList($condition = [], $field = '*', $order = 'stock_id asc', $limit = null)
- {
- $list = model('virtual_stock')->getList($condition, $field, $order, '', '', '', $limit);
- return $this->success($list);
- }
-
+pageList($condition, $field, $order, $page, $page_size);
+ return $this->success($list);
+ }
+
+ /**
+ * 添加虚拟评价库分页列表
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function addStock($data)
+ {
+ $stock_id = model('virtual_stock')->add($data);
+ return $this->success($stock_id);
+ }
+
+ /**
+ * 删除虚拟评价库
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function deleteStock($stock_id, $site_id)
+ {
+ $stock_id = model('virtual_stock')->delete([ [ 'stock_id', '=', $stock_id ], [ 'site_id', '=', $site_id ] ]);
+
+ return $this->success($stock_id);
+ }
+
+ /**
+ * 更新虚拟评价库
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function updateStock($data, $site_id)
+ {
+ $stock_id = model('virtual_stock')->update($data, [ [ 'stock_id', '=', $data[ 'stock_id' ] ], [ 'site_id', '=', $site_id ] ]);
+
+ return $this->success($stock_id);
+ }
+
+ /**
+ * 获取虚拟评价库信息
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function getStockInfo($stock_id, $site_id)
+ {
+ $stock_info = model('virtual_stock')->getInfo([ [ 'stock_id', '=', $stock_id ], [ 'site_id', '=', $site_id ] ], '*');
+
+ return $this->success($stock_info);
+ }
+
+ /**
+ * 获取虚拟评价库信息
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function getContentsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'create_time desc', $field = '*')
+ {
+ $list = model('stock_content')->pageList($condition, $field, $order, $page, $page_size);
+ return $this->success($list);
+ }
+
+ /**
+ * 添加虚拟评价库评论
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function addContent($data)
+ {
+ $stock_id = model('stock_content')->add($data);
+ if ($stock_id) {
+ model("virtual_stock")->setInc([ [ 'stock_id', '=', $data[ 'stock_id' ] ] ], "num", 1);
+ }
+ return $this->success($stock_id);
+ }
+
+ /**
+ * 删除虚拟评价库评论
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function deleteContent($id, $site_id)
+ {
+ $stock_data = model('stock_content')->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], 'stock_id');
+ model("virtual_stock")->setDec([ [ 'stock_id', '=', $stock_data[ 'stock_id' ] ] ], "num", 1);
+
+ $stock_id = model('stock_content')->delete([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ]);
+
+ return $this->success($stock_id);
+ }
+
+ /**
+ * 获取虚拟评价库信息
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function getContentInfo($id, $site_id)
+ {
+ $stock_info = model('stock_content')->getInfo([ [ 'id', '=', $id ], [ 'site_id', '=', $site_id ] ], '*');
+
+ return $this->success($stock_info);
+ }
+
+ /**
+ * 修改虚拟评价库信息
+ * @param array $condition
+ * @param number $page
+ * @param string $page_size
+ * @param string $order
+ * @param string $field
+ */
+ public function editContentInfo($data, $site_id)
+ {
+ $content_info = model('stock_content')->update($data, [ [ 'id', '=', $data[ 'id' ] ], [ 'site_id', '=', $site_id ] ]);
+
+ return $this->success($content_info);
+ }
+
+ /**
+ * 获取评论库列表
+ * @param array $condition
+ * @param string $field
+ * @param string $order
+ * @param null $limit
+ * @return array
+ */
+ public function getStockList($condition = [], $field = '*', $order = 'stock_id asc', $limit = null)
+ {
+ $list = model('virtual_stock')->getList($condition, $field, $order, '', '', '', $limit);
+ return $this->success($list);
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/virtualevaluation/shop/controller/Comment.php b/src/addon/virtualevaluation/shop/controller/Comment.php
index eae60a885..2559cc128 100644
--- a/src/addon/virtualevaluation/shop/controller/Comment.php
+++ b/src/addon/virtualevaluation/shop/controller/Comment.php
@@ -1,415 +1,407 @@
-isJson()) {
- $page_index = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $search_text = input('search_text', "");
- $goods_state = input('goods_state', "");
- $start_sale = input('start_sale', 0);
- $end_sale = input('end_sale', 0);
- $start_price = input('start_price', 0);
- $end_price = input('end_price', 0);
- $goods_class = input('goods_class', "");
- $label_id = input('label_id', "");
- $order = input('order', '');
- $sort = input('sort', 'asc');
-
- $order_by = 'create_time desc';
- if ($order != '') {
- if ($order == 'sort') {
- $order_by = $order . ' ' . $sort . ',create_time desc';
- } else {
- $order_by = $order . ' ' . $sort;
- }
- }
- $promotion_type = input('promotion_type', "");
-
- $condition = [ [ 'is_delete', '=', 0 ], [ 'site_id', '=', $this->site_id ] ];
-
- if (!empty($search_text)) {
- $condition[] = [ 'goods_name', 'like', '%' . $search_text . '%' ];
- }
- $category_id = input('category_id', "");
- if (!empty($category_id)) {
- $condition[] = [ 'category_id', 'like', '%,' . $category_id . ',%' ];
- }
-
- if ($goods_class !== "") {
- $condition[] = [ 'goods_class', '=', $goods_class ];
- }
-
- if (!empty($label_id)) {
- $condition[] = [ 'label_id', '=', $label_id ];
- }
-
- if (!empty($promotion_type)) {
- $condition[] = [ 'promotion_addon', 'like', "%{$promotion_type}%" ];
- }
-
- // 上架状态
- if ($goods_state !== '') {
- $condition[] = [ 'goods_state', '=', $goods_state ];
- }
- if (!empty($start_sale)) $condition[] = [ 'sale_num', '>=', $start_sale ];
- if (!empty($end_sale)) $condition[] = [ 'sale_num', '<=', $end_sale ];
- if (!empty($start_price)) $condition[] = [ 'price', '>=', $start_price ];
- if (!empty($end_price)) $condition[] = [ 'price', '<=', $end_price ];
-
- // 查询库存预警的商品
- if ($stockalarm) {
- $stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
- if (!empty($stock_alarm[ 'data' ])) {
- $condition[] = [ 'goods_id', 'in', $stock_alarm[ 'data' ] ];
- } else {
- return success(0, '', [ 'page_count' => 1, 'count' => 0, 'list' => [] ]);
- }
- }
- $field = 'goods_id,goods_name,site_id,site_name,goods_image,goods_state,price,goods_stock,goods_stock_alarm,create_time,sale_num,is_virtual,goods_class,is_fenxiao,fenxiao_type,promotion_addon,sku_id,is_consume_discount,discount_config,discount_method,sort,evaluate,evaluate_shaitu,success_evaluate_num,fail_evaluate_num,wait_evaluate_num';
- $res = $goods_model->getGoodsPageList($condition, $page_index, $page_size, $order_by, $field);
- $goods_promotion_type = event('GoodsPromotionType');
- if (!empty($res[ 'data' ][ 'list' ])) {
- foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
-
- $res[ 'data' ][ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($res[ 'data' ][ 'list' ][ $k ][ 'goods_stock' ]);
- $res[ 'data' ][ 'list' ][ $k ][ 'sale_num' ] = numberFormat($res[ 'data' ][ 'list' ][ $k ][ 'sale_num' ]);
-
- if (!empty($v[ 'promotion_addon' ])) {
- $v[ 'promotion_addon' ] = json_decode($v[ 'promotion_addon' ], true);
- foreach ($v[ 'promotion_addon' ] as $ck => $cv) {
- foreach ($goods_promotion_type as $gk => $gv) {
- if ($gv[ 'type' ] == $ck) {
- $res[ 'data' ][ 'list' ][ $k ][ 'promotion_addon_list' ][] = $gv;
- break;
- }
- }
- }
- }
- }
- }
- return $res;
- } else {
-
- $goods_state = input('state', '');
- $this->assign('goods_state', $goods_state);
- //获取一级商品分类
- $goods_category_model = new GoodsCategoryModel();
- $condition = [
- [ 'pid', '=', 0 ],
- [ 'site_id', '=', $this->site_id ]
- ];
-
- $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate');
- $goods_category_list = $goods_category_list[ 'data' ];
- $this->assign("goods_category_list", $goods_category_list);
-
- // 商品分组
- $goods_label_model = new GoodsLabelModel();
- $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'create_time desc')[ 'data' ];
- $this->assign("label_list", $label_list);
-
- // 商品服务
- $goods_service_model = new GoodsServiceModel();
- $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
- $this->assign("service_list", $service_list);
-
- //获取运费模板
- $express_template_model = new ExpressTemplateModel();
- $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
- $express_template_list = $express_template_list[ 'data' ];
- $this->assign("express_template_list", $express_template_list);
-
- //判断会员价插件
- $memberprice_is_exit = addon_is_exit('memberprice', $this->site_id);
- $this->assign('memberprice_is_exit', $memberprice_is_exit);
-
- // 判断采集插件
- $goodsgrab_is_exit = addon_is_exit('goodsgrab', $this->site_id);
- $this->assign('goodsgrab_is_exit', $goodsgrab_is_exit);
-
- // 营销活动
- $goods_promotion_type = event('GoodsPromotionType');
- $this->assign('promotion_type', $goods_promotion_type);
-
- $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
-
- $this->assign('stockalarm', $stockalarm);
-
- return $this->fetch("comment/goods_lists");
- }
- }
-
- /**
- * 创建虚拟评价
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function setting()
- {
- $goods_ids = input('goods_ids', 0);
- $goods_model = new Goods();
- $goods_data = $goods_model->getGoodsList([ [ 'goods_id', 'in', $goods_ids ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,goods_id,goods_name,price,goods_image');
-
- $data = json_decode(input('field'), true);
-
- if (!empty($data[ 'member_headimg' ])) {
- $data[ 'member_headimg' ] = $data[ 'member_headimg' ][ 0 ];
- }
- $pingjia_img = '';
- if (!empty($data[ 'pingjia_img' ])) {
- foreach ($data[ 'pingjia_img' ] as $k => $val) {
- $pingjia_img = $pingjia_img . ',' . $val;
- }
- $pingjia_img = trim($pingjia_img, ',');
- }
-
- $data[ 'pingjia_img' ] = $pingjia_img;
- $data[ 'goods_data' ] = '';
- if (!empty($goods_data[ 'data' ])) {
- $data[ 'goods_data' ] = $goods_data[ 'data' ];
- }
- $VirtualEvaluation_model = new VirtualEvaluation();
- $res = $VirtualEvaluation_model->addGoodsComment($data, $this->site_id);
- return $res;
- }
-
- /**
- * 虚拟评价库
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function stock()
- {
- if (request()->isJson()) {
- $stock_model = new VirtualStock();
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $condition = [
- 'site_id' => $this->site_id
- ];
- $stock_data = $stock_model->getStockPageList($condition, $page, $page_size, '', '');
- return $stock_data;
- } else {
-
- return $this->fetch("comment/stock");
- }
- }
-
- /**
- * 添加虚拟评价库
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function addStock()
- {
- $stock_model = new VirtualStock();
- $stock_name = input('stock_name', '');
- $data = [
- 'stock_name' => $stock_name,
- 'site_id' => $this->site_id,
- 'create_time' => time(),
- ];
- return $stock_model->addStock($data);
- }
-
- /**
- * 删除虚拟评价库
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function deleteStock()
- {
- $stock_model = new VirtualStock();
- $stock_id = input('stock_id', '');
-
- return $stock_model->deleteStock($stock_id, $this->site_id);
- }
-
- /**
- * 获取虚拟评价库信息
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function getStockInfo()
- {
- $stock_model = new VirtualStock();
- $stock_id = input('stock_id', '');
- return $stock_model->getStockInfo($stock_id, $this->site_id);
- }
-
- /**
- * 编辑虚拟评价库
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function editStock()
- {
- $stock_model = new VirtualStock();
- $stock_id = input('stock_id', 0);
- $stock_name = input('stock_name', '');
- $data = [
- 'stock_name' => $stock_name,
- 'modify_time' => time(),
- 'stock_id' => $stock_id
- ];
-
- return $stock_model->updateStock($data, $this->site_id);
- }
-
- /**
- * 获取虚拟评价库里的评论信息
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function getContents()
- {
- $stock_id = input('stock_id', 0);
- if (request()->isJson()) {
- $stock_model = new VirtualStock();
- $page = input('page', 1);
- $page_size = input('page_size', PAGE_LIST_ROWS);
- $condition = [
- 'site_id' => $this->site_id,
- 'stock_id' => $stock_id,
- ];
- $stock_data = $stock_model->getContentsPageList($condition, $page, $page_size, '', '');
- return $stock_data;
- } else {
- $this->assign('stock_id', $stock_id);
- return $this->fetch("comment/contents");
- }
- }
-
- /**
- * 添加虚拟评价库评论
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function addContent()
- {
- $stock_model = new VirtualStock();
- $stock_id = input('stock_id', 0);
- $content = input('content', '');
- $data = [
- 'stock_id' => $stock_id,
- 'site_id' => $this->site_id,
- 'content' => $content,
- 'create_time' => time(),
- ];
- return $stock_model->addContent($data);
- }
-
- /**
- * 删除虚拟评价库评论
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function deleteContent()
- {
- $stock_model = new VirtualStock();
- $id = input('id', 0);
-
- return $stock_model->deleteContent($id, $this->site_id);
- }
-
- /**
- * 获取虚拟评价库评论信息
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function getContentInfo()
- {
- $stock_model = new VirtualStock();
- $id = input('id', 0);
-
- return $stock_model->getContentInfo($id, $this->site_id);
- }
-
- /**
- * 修改虚拟评价库评论信息
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function editContent()
- {
- $stock_model = new VirtualStock();
- $id = input('id', 0);
- $content = input('content', '');
- $data = [
- 'content' => $content,
- 'id' => $id
- ];
- return $stock_model->editContentInfo($data, $this->site_id);
- }
-
- /**
- * 批量添加单个商品的评论
- * Class Virtualgoods
- * @package app\shop\controller
- */
- public function batchAdd()
- {
- $album_model = new Album();
- $stock_model = new VirtualStock();
- $goods_id = input('goods_id', 0);
- if (request()->isJson()) {
- $start_time = date_to_time(input('start_time'));
- $end_time = date_to_time(input('end_time'));
- if ($start_time == '' || $end_time == '' || $end_time < $start_time) return error('-1', '时间格式不正确');
- $virtual_evaluation_model = new VirtualEvaluation();
- $data = [
- 'goods_id' => input('goods_id', 0),
- 'number' => input('number', 0),
- 'pingfen' => input('pingfen', ''),
- 'start_time' => $start_time,
- 'end_time' => $end_time,
- 'album_id' => input('album_id', 0),
- 'stock_id' => input('stock_id', 0)
- ];
- $res = $virtual_evaluation_model->batghAdd($data, $this->site_id);
- return $res;
- } else {
- //获取相册
- $album_list = $album_model->getAlbumList([ [ 'site_id', '=', $this->site_id ], [ 'num', '>', 0 ] ]);
- $this->assign('album_list', $album_list[ 'data' ]);
- //获取评论库
- $stock_list = $stock_model->getStockList([ [ 'site_id', '=', $this->site_id ], [ 'num', '>', 0 ] ]);
- $this->assign('stock_list', $stock_list[ 'data' ]);
- $this->assign('goods_id', $goods_id);
- return $this->fetch("comment/batchadd");
- }
- }
-
+isJson()) {
+ $page_index = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $search_text = input('search_text', "");
+ $goods_state = input('goods_state', "");
+ $start_sale = input('start_sale', 0);
+ $end_sale = input('end_sale', 0);
+ $start_price = input('start_price', 0);
+ $end_price = input('end_price', 0);
+ $goods_class = input('goods_class', "");
+ $label_id = input('label_id', "");
+ $order = input('order', '');
+ $sort = input('sort', 'asc');
+
+ $order_by = 'create_time desc';
+ if ($order != '') {
+ if ($order == 'sort') {
+ $order_by = $order . ' ' . $sort . ',create_time desc';
+ } else {
+ $order_by = $order . ' ' . $sort;
+ }
+ }
+ $promotion_type = input('promotion_type', "");
+
+ $condition = [ [ 'is_delete', '=', 0 ], [ 'site_id', '=', $this->site_id ] ];
+
+ if (!empty($search_text)) {
+ $condition[] = [ 'goods_name', 'like', '%' . $search_text . '%' ];
+ }
+ $category_id = input('category_id', "");
+ if (!empty($category_id)) {
+ $condition[] = [ 'category_id', 'like', '%,' . $category_id . ',%' ];
+ }
+
+ if ($goods_class !== "") {
+ $condition[] = [ 'goods_class', '=', $goods_class ];
+ }
+
+ if (!empty($label_id)) {
+ $condition[] = [ 'label_id', '=', $label_id ];
+ }
+
+ if (!empty($promotion_type)) {
+ $condition[] = [ 'promotion_addon', 'like', "%{$promotion_type}%" ];
+ }
+
+ // 上架状态
+ if ($goods_state !== '') {
+ $condition[] = [ 'goods_state', '=', $goods_state ];
+ }
+ if (!empty($start_sale)) $condition[] = [ 'sale_num', '>=', $start_sale ];
+ if (!empty($end_sale)) $condition[] = [ 'sale_num', '<=', $end_sale ];
+ if (!empty($start_price)) $condition[] = [ 'price', '>=', $start_price ];
+ if (!empty($end_price)) $condition[] = [ 'price', '<=', $end_price ];
+
+ // 查询库存预警的商品
+ if ($stockalarm) {
+ $stock_alarm = $goods_model->getGoodsStockAlarm($this->site_id);
+ if (!empty($stock_alarm[ 'data' ])) {
+ $condition[] = [ 'goods_id', 'in', $stock_alarm[ 'data' ] ];
+ } else {
+ return success(0, '', [ 'page_count' => 1, 'count' => 0, 'list' => [] ]);
+ }
+ }
+ $field = 'goods_id,goods_name,site_id,site_name,goods_image,goods_state,price,goods_stock,goods_stock_alarm,create_time,sale_num,is_virtual,goods_class,is_fenxiao,fenxiao_type,promotion_addon,sku_id,is_consume_discount,discount_config,discount_method,sort,evaluate,evaluate_shaitu,success_evaluate_num,fail_evaluate_num,wait_evaluate_num';
+ $res = $goods_model->getGoodsPageList($condition, $page_index, $page_size, $order_by, $field);
+ $goods_promotion_type = event('GoodsPromotionType');
+ if (!empty($res[ 'data' ][ 'list' ])) {
+ foreach ($res[ 'data' ][ 'list' ] as $k => $v) {
+
+ $res[ 'data' ][ 'list' ][ $k ][ 'goods_stock' ] = numberFormat($res[ 'data' ][ 'list' ][ $k ][ 'goods_stock' ]);
+ $res[ 'data' ][ 'list' ][ $k ][ 'sale_num' ] = numberFormat($res[ 'data' ][ 'list' ][ $k ][ 'sale_num' ]);
+
+ if (!empty($v[ 'promotion_addon' ])) {
+ $v[ 'promotion_addon' ] = json_decode($v[ 'promotion_addon' ], true);
+ foreach ($v[ 'promotion_addon' ] as $ck => $cv) {
+ foreach ($goods_promotion_type as $gk => $gv) {
+ if ($gv[ 'type' ] == $ck) {
+ $res[ 'data' ][ 'list' ][ $k ][ 'promotion_addon_list' ][] = $gv;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $res;
+ } else {
+
+ $goods_state = input('state', '');
+ $this->assign('goods_state', $goods_state);
+ //获取一级商品分类
+ $goods_category_model = new GoodsCategoryModel();
+ $condition = [
+ [ 'pid', '=', 0 ],
+ [ 'site_id', '=', $this->site_id ]
+ ];
+
+ $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate');
+ $goods_category_list = $goods_category_list[ 'data' ];
+ $this->assign("goods_category_list", $goods_category_list);
+
+ // 商品分组
+ $goods_label_model = new GoodsLabelModel();
+ $label_list = $goods_label_model->getLabelList([ [ 'site_id', '=', $this->site_id ] ], 'id,label_name', 'create_time desc')[ 'data' ];
+ $this->assign("label_list", $label_list);
+
+ // 商品服务
+ $goods_service_model = new GoodsServiceModel();
+ $service_list = $goods_service_model->getServiceList([ [ 'site_id', '=', $this->site_id ] ], 'id,service_name,icon')[ 'data' ];
+ $this->assign("service_list", $service_list);
+
+ //获取运费模板
+ $express_template_model = new ExpressTemplateModel();
+ $express_template_list = $express_template_model->getExpressTemplateList([ [ 'site_id', "=", $this->site_id ] ], 'template_id,template_name', 'is_default desc');
+ $express_template_list = $express_template_list[ 'data' ];
+ $this->assign("express_template_list", $express_template_list);
+
+ //判断会员价插件
+ $memberprice_is_exit = addon_is_exit('memberprice', $this->site_id);
+ $this->assign('memberprice_is_exit', $memberprice_is_exit);
+
+ // 判断采集插件
+ $goodsgrab_is_exit = addon_is_exit('goodsgrab', $this->site_id);
+ $this->assign('goodsgrab_is_exit', $goodsgrab_is_exit);
+
+ // 营销活动
+ $goods_promotion_type = event('GoodsPromotionType');
+ $this->assign('promotion_type', $goods_promotion_type);
+
+ $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id));
+
+ $this->assign('stockalarm', $stockalarm);
+
+ return $this->fetch("comment/goods_lists");
+ }
+ }
+
+ /**
+ * 创建虚拟评价
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function setting()
+ {
+ $goods_ids = input('goods_ids', 0);
+ $goods_model = new Goods();
+ $goods_data = $goods_model->getGoodsList([ [ 'goods_id', 'in', $goods_ids ], [ 'site_id', '=', $this->site_id ] ], 'sku_id,goods_id,goods_name,price,goods_image');
+
+ $data = json_decode(input('field'), true);
+
+ if (!empty($data[ 'member_headimg' ])) {
+ $data[ 'member_headimg' ] = $data[ 'member_headimg' ][ 0 ];
+ }
+ $pingjia_img = '';
+ if (!empty($data[ 'pingjia_img' ])) {
+ foreach ($data[ 'pingjia_img' ] as $k => $val) {
+ $pingjia_img = $pingjia_img . ',' . $val;
+ }
+ $pingjia_img = trim($pingjia_img, ',');
+ }
+
+ $data[ 'pingjia_img' ] = $pingjia_img;
+ $data[ 'goods_data' ] = '';
+ if (!empty($goods_data[ 'data' ])) {
+ $data[ 'goods_data' ] = $goods_data[ 'data' ];
+ }
+ $VirtualEvaluation_model = new VirtualEvaluation();
+ $res = $VirtualEvaluation_model->addGoodsComment($data, $this->site_id);
+ return $res;
+ }
+
+ /**
+ * 虚拟评价库
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function stock()
+ {
+ if (request()->isJson()) {
+ $stock_model = new VirtualStock();
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $condition = [
+ 'site_id' => $this->site_id
+ ];
+ $stock_data = $stock_model->getStockPageList($condition, $page, $page_size, '', '');
+ return $stock_data;
+ } else {
+
+ return $this->fetch("comment/stock");
+ }
+ }
+
+ /**
+ * 添加虚拟评价库
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function addStock()
+ {
+ $stock_model = new VirtualStock();
+ $stock_name = input('stock_name', '');
+ $data = [
+ 'stock_name' => $stock_name,
+ 'site_id' => $this->site_id,
+ 'create_time' => time(),
+ ];
+ return $stock_model->addStock($data);
+ }
+
+ /**
+ * 删除虚拟评价库
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function deleteStock()
+ {
+ $stock_model = new VirtualStock();
+ $stock_id = input('stock_id', '');
+
+ return $stock_model->deleteStock($stock_id, $this->site_id);
+ }
+
+ /**
+ * 获取虚拟评价库信息
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function getStockInfo()
+ {
+ $stock_model = new VirtualStock();
+ $stock_id = input('stock_id', '');
+ return $stock_model->getStockInfo($stock_id, $this->site_id);
+ }
+
+ /**
+ * 编辑虚拟评价库
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function editStock()
+ {
+ $stock_model = new VirtualStock();
+ $stock_id = input('stock_id', 0);
+ $stock_name = input('stock_name', '');
+ $data = [
+ 'stock_name' => $stock_name,
+ 'modify_time' => time(),
+ 'stock_id' => $stock_id
+ ];
+
+ return $stock_model->updateStock($data, $this->site_id);
+ }
+
+ /**
+ * 获取虚拟评价库里的评论信息
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function getContents()
+ {
+ $stock_id = input('stock_id', 0);
+ if (request()->isJson()) {
+ $stock_model = new VirtualStock();
+ $page = input('page', 1);
+ $page_size = input('page_size', PAGE_LIST_ROWS);
+ $condition = [
+ 'site_id' => $this->site_id,
+ 'stock_id' => $stock_id,
+ ];
+ $stock_data = $stock_model->getContentsPageList($condition, $page, $page_size, '', '');
+ return $stock_data;
+ } else {
+ $this->assign('stock_id', $stock_id);
+ return $this->fetch("comment/contents");
+ }
+ }
+
+ /**
+ * 添加虚拟评价库评论
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function addContent()
+ {
+ $stock_model = new VirtualStock();
+ $stock_id = input('stock_id', 0);
+ $content = input('content', '');
+ $data = [
+ 'stock_id' => $stock_id,
+ 'site_id' => $this->site_id,
+ 'content' => $content,
+ 'create_time' => time(),
+ ];
+ return $stock_model->addContent($data);
+ }
+
+ /**
+ * 删除虚拟评价库评论
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function deleteContent()
+ {
+ $stock_model = new VirtualStock();
+ $id = input('id', 0);
+
+ return $stock_model->deleteContent($id, $this->site_id);
+ }
+
+ /**
+ * 获取虚拟评价库评论信息
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function getContentInfo()
+ {
+ $stock_model = new VirtualStock();
+ $id = input('id', 0);
+
+ return $stock_model->getContentInfo($id, $this->site_id);
+ }
+
+ /**
+ * 修改虚拟评价库评论信息
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function editContent()
+ {
+ $stock_model = new VirtualStock();
+ $id = input('id', 0);
+ $content = input('content', '');
+ $data = [
+ 'content' => $content,
+ 'id' => $id
+ ];
+ return $stock_model->editContentInfo($data, $this->site_id);
+ }
+
+ /**
+ * 批量添加单个商品的评论
+ * Class Virtualgoods
+ * @package app\shop\controller
+ */
+ public function batchAdd()
+ {
+ $album_model = new Album();
+ $stock_model = new VirtualStock();
+ $goods_id = input('goods_id', 0);
+ if (request()->isJson()) {
+ $start_time = date_to_time(input('start_time'));
+ $end_time = date_to_time(input('end_time'));
+ if ($start_time == '' || $end_time == '' || $end_time < $start_time) return error('-1', '时间格式不正确');
+ $virtual_evaluation_model = new VirtualEvaluation();
+ $data = [
+ 'goods_id' => input('goods_id', 0),
+ 'number' => input('number', 0),
+ 'pingfen' => input('pingfen', ''),
+ 'start_time' => $start_time,
+ 'end_time' => $end_time,
+ 'album_id' => input('album_id', 0),
+ 'stock_id' => input('stock_id', 0)
+ ];
+ $res = $virtual_evaluation_model->batghAdd($data, $this->site_id);
+ return $res;
+ } else {
+ //获取相册
+ $album_list = $album_model->getAlbumList([ [ 'site_id', '=', $this->site_id ], [ 'num', '>', 0 ] ]);
+ $this->assign('album_list', $album_list[ 'data' ]);
+ //获取评论库
+ $stock_list = $stock_model->getStockList([ [ 'site_id', '=', $this->site_id ], [ 'num', '>', 0 ] ]);
+ $this->assign('stock_list', $stock_list[ 'data' ]);
+ $this->assign('goods_id', $goods_id);
+ return $this->fetch("comment/batchadd");
+ }
+ }
+
}
\ No newline at end of file
diff --git a/src/addon/weapp/api/controller/Auth.php b/src/addon/weapp/api/controller/Auth.php
index 9536e3693..efc86dfbb 100644
--- a/src/addon/weapp/api/controller/Auth.php
+++ b/src/addon/weapp/api/controller/Auth.php
@@ -1,40 +1,31 @@
-siteid();
- $this->wechat = new Weapp($site_id);
- }
-
- /**
- * 小程序消息推送
- */
- public function relateWeixin()
- {
- Log::write('微信小程序消息推送');
- $this->wechat->relateWeixin();
- }
-
-
+siteid();
+ $this->wechat = new Weapp($site_id);
+ }
+
+ /**
+ * 小程序消息推送
+ */
+ public function relateWeixin()
+ {
+ Log::write('微信小程序消息推送');
+ $this->wechat->relateWeixin();
+ }
+
+
}
\ No newline at end of file
diff --git a/src/addon/weapp/api/controller/Weapp.php b/src/addon/weapp/api/controller/Weapp.php
index 70b7b7a21..5021b3447 100644
--- a/src/addon/weapp/api/controller/Weapp.php
+++ b/src/addon/weapp/api/controller/Weapp.php
@@ -1,88 +1,80 @@
-site_id);
- $res = $weapp_model->authCodeToOpenid($this->params);
- return $this->response($res);
- }
-
- /**
- * 获取消息模板id(最多三条)
- */
- public function messageTmplIds()
- {
- $keywords = $this->params[ 'keywords' ] ?? '';
- $message = new Message();
- $res = $message->getMessageTmplIds($this->site_id, $keywords);
- return $this->response($res);
- }
-
- /*
- * 获取小程序码
- */
- public function qrcode()
- {
- $config_model = new Config();
- $config = $config_model->getWeappConfig($this->site_id);
- $qrcode = $config[ 'data' ][ 'value' ][ 'qrcode' ] ?? '';
- return $this->response($this->success($qrcode));
- }
-
- /**
- * 分享
- * @return false|string
- */
- public function share()
- {
- /*$config_model = new Config();
- $config = $config_model->getShareConfig($this->site_id, 'shop');
- $share_config = $config['data']['value'];*/
-
- $this->checkToken();
-
- //页面路径
- $path = $this->params[ 'path' ] ?? '';
-
- //分享配置
- $share_config = [];
- $share_data = event('WeappShareData', [
- 'path' => $path,
- 'site_id' => $this->site_id,
- 'member_id' => $this->member_id,
- ], true);
- if (!empty($share_data)) {
- $share_config[ 'permission' ] = $share_data[ 'permission' ];
- $share_config[ 'data' ] = $share_data[ 'data' ];
- } else {
- $share_config[ 'permission' ] = [
- 'onShareAppMessage' => false,
- 'onShareTimeline' => false,
- ];
- $share_config[ 'data' ] = null;
- }
-
- return $this->response($this->success($share_config));
- }
+site_id);
+ $res = $weapp_model->authCodeToOpenid($this->params);
+ return $this->response($res);
+ }
+
+ /**
+ * 获取消息模板id(最多三条)
+ */
+ public function messageTmplIds()
+ {
+ $keywords = $this->params[ 'keywords' ] ?? '';
+ $message = new Message();
+ $res = $message->getMessageTmplIds($this->site_id, $keywords);
+ return $this->response($res);
+ }
+
+ /*
+ * 获取小程序码
+ */
+ public function qrcode()
+ {
+ $config_model = new Config();
+ $config = $config_model->getWeappConfig($this->site_id);
+ $qrcode = $config[ 'data' ][ 'value' ][ 'qrcode' ] ?? '';
+ return $this->response($this->success($qrcode));
+ }
+
+ /**
+ * 分享
+ * @return false|string
+ */
+ public function share()
+ {
+ /*$config_model = new Config();
+ $config = $config_model->getShareConfig($this->site_id, 'shop');
+ $share_config = $config['data']['value'];*/
+
+ $this->checkToken();
+
+ //页面路径
+ $path = $this->params[ 'path' ] ?? '';
+
+ //分享配置
+ $share_config = [];
+ $share_data = event('WeappShareData', [
+ 'path' => $path,
+ 'site_id' => $this->site_id,
+ 'member_id' => $this->member_id,
+ ], true);
+ if (!empty($share_data)) {
+ $share_config[ 'permission' ] = $share_data[ 'permission' ];
+ $share_config[ 'data' ] = $share_data[ 'data' ];
+ } else {
+ $share_config[ 'permission' ] = [
+ 'onShareAppMessage' => false,
+ 'onShareTimeline' => false,
+ ];
+ $share_config[ 'data' ] = null;
+ }
+
+ return $this->response($this->success($share_config));
+ }
}
\ No newline at end of file
diff --git a/src/addon/weapp/config/diy_view.php b/src/addon/weapp/config/diy_view.php
index c3c657905..e36ca9b7d 100644
--- a/src/addon/weapp/config/diy_view.php
+++ b/src/addon/weapp/config/diy_view.php
@@ -1,38 +1,30 @@
- '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
- 'template' => [],
-
- // 后台自定义组件——装修
- 'util' => [],
-
- // 自定义页面路径
- 'link' => [],
-
- // 自定义图标库
- 'icon_library' => [],
-
- // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
- 'component' => [],
-
- // uni-app 页面,多个逗号隔开
- 'pages' => [],
-
- // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
- 'info' => [],
-
- // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
- 'theme' => [],
-
- // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
- 'data' => []
+ '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
+ 'template' => [],
+
+ // 后台自定义组件——装修
+ 'util' => [],
+
+ // 自定义页面路径
+ 'link' => [],
+
+ // 自定义图标库
+ 'icon_library' => [],
+
+ // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
+ 'component' => [],
+
+ // uni-app 页面,多个逗号隔开
+ 'pages' => [],
+
+ // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
+ 'info' => [],
+
+ // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
+ 'theme' => [],
+
+ // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
+ 'data' => []
];
\ No newline at end of file
diff --git a/src/addon/weapp/config/info.php b/src/addon/weapp/config/info.php
index eb23187b1..53d711bf4 100644
--- a/src/addon/weapp/config/info.php
+++ b/src/addon/weapp/config/info.php
@@ -1,12 +1,5 @@
'weapp',
'title' => '微信小程序',
diff --git a/src/addon/weapp/event/DecryptData.php b/src/addon/weapp/event/DecryptData.php
index 4de198569..ef69e0fd4 100644
--- a/src/addon/weapp/event/DecryptData.php
+++ b/src/addon/weapp/event/DecryptData.php
@@ -1,12 +1,4 @@
error("不存在的模板信息!");
-
-
$this->assign("keywords", $keywords);
$this->assign("info", $weapp_json_array);
$this->assign('weapp_is_open', $info[ 'weapp_is_open' ]);
+ $this->assign('message_title', $info[ 'title' ] ?? '');
return $this->fetch('message/edit');
}
}
diff --git a/src/addon/weapp/shop/controller/Stat.php b/src/addon/weapp/shop/controller/Stat.php
index cb4b3f650..224e8f9bb 100644
--- a/src/addon/weapp/shop/controller/Stat.php
+++ b/src/addon/weapp/shop/controller/Stat.php
@@ -1,12 +1,4 @@
.layui-elem-quote{color: #999;}
.table-btn{justify-content: center;}
@@ -8,7 +6,6 @@
.template-content{white-space:pre;line-height: 1.5;text-align: left}
-
操作提示
@@ -37,7 +34,7 @@
{{# if(d.weapp_is_open == 0){ }}
开启
- {{# }else{ }}
+ {{# }else{ }}
关闭
{{# } }}
@@ -60,8 +57,6 @@
{{ d.weapp_is_open == 1 ? '已启用' : '已关闭' }}
-
-
-
+
-
-
-
-
diff --git a/src/app/shop/view/message/lists.html b/src/app/shop/view/message/lists.html
index f6b539a0e..11178a56e 100644
--- a/src/app/shop/view/message/lists.html
+++ b/src/app/shop/view/message/lists.html
@@ -1,5 +1,3 @@
-
-
-
+ {if isset($sms_num) && $sms_num < 500}
+
+
+ 当前短信条数就剩{$sms_num}条了,赶快去充值吧!
+
立即充值
+
+ {/if}
+
{empty name="wechat_config"}
@@ -61,7 +66,7 @@
-
+
@@ -113,7 +118,7 @@
-
-
-
diff --git a/src/app/shop/view/public/js/route.js b/src/app/shop/view/public/js/route.js
index e0cf9d5f1..670123b0b 100644
--- a/src/app/shop/view/public/js/route.js
+++ b/src/app/shop/view/public/js/route.js
@@ -65,7 +65,7 @@ function loadMenu(url) {
if (window.currentMenu) {
// 菜单树结构,面包屑
- getMenuTree(window.currentMenu.name)
+ getMenuTree(window.currentMenu.name);
window.crumbs.sort((a, b) => {
return a.level - b.level;
});
@@ -96,7 +96,7 @@ function renderMenu() {
window.secondMenu = item.child_list;
window.firstMenu = item;
}
- })
+ });
// 加载一级菜单
$('.menu-first-wrap').html(html);
@@ -160,10 +160,10 @@ function renderMenu() {
forthMenuHtml += `