| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\utils;
- use app\models\AlipayActivityDelivery;
- use app\models\AlipayVoucherCode;
- use app\models\Cash;
- use app\models\LevelOrder;
- use app\models\Mch;
- use app\models\MchCash;
- use app\models\Order;
- use app\models\OrderUnion;
- use app\models\ReOrder;
- use app\models\SaasProfitCash;
- use app\models\StoreReOrder;
- use app\models\BusinessMemberOrder;
- use app\models\LocalDeliveryCash;
- use app\plugins\adopt\models\AdoptCostOrder;
- use app\plugins\food\models\FoodOrder;
- use app\plugins\integral\models\SaasIntegralOrder;
- use app\models\PurchaseOrder;
- class OrderNo
- {
- /**
- * 定义订单类型,统一订单号,以便回调后续统一处理
- */
- const ORDER_MALL = 'ML'; // 商城订单
- const ORDER_MS = 'MS'; // 秒杀订单
- const ORDER_PT = 'PT'; // 拼团订单
- const ORDER_BOOK = 'YY'; // 预约订单
- const ORDER_BARGAIN = 'BG'; // 砍价订单
- const ORDER_INTEGRAL = 'IG'; // 积分订单
- const ORDER_LOTTERY = 'LT'; // 抽奖订单
- const ORDER_SUPPLIER = 'SP'; // 供货商订单
- const ORDER_RECHARGE = 'RG'; // 充值订单
- const INTEGRAL_RECHARGE = 'IR'; // 积分充值订单
- const ORDER_UNION = 'UN'; // 联合订单
- const ORDER_CASH = 'CS'; // 提现订单
- const ORDER_LOCAL_CASH = 'LCS'; // 同城配送提现订单
- const ORDER_MCH_CASH = 'MC'; // 商户提现订单
- const ORDER_LEVEL = 'LV'; // 会员订单
- const ORDER_INTEGRAL_COUPON = 'IC'; // 积分卡券
- const ORDER_SCRATCH = 'ST'; // 红包
- const ORDER_STEP = 'TP'; // 步数宝
- const ORDER_POND = 'PD'; // 大转盘
- const ORDER_BARGAIN_REFUND = 'BF'; // 砍价退款订单
- const ORDER_SCAN_CODE_PAY = 'SC'; // 当面付订单
- const ORDER_SAAS_INTEGRAL = 'SI'; // saas积分订单
- const ORDER_SAAS_PROFIT_CASH = 'PC'; // 联盟佣金订单
- const ORDER_ALIPAY_FOOD = 'FO'; // 点餐订单
- const ORDER_ALIPAY_SCAN = 'AC'; // 支付宝当面付订单
- const ORDER_ALLIANCE = 'AL'; // 商盟订单
- const ORDER_ALLIANCE_PURCHASE = 'AP'; // 商盟采购订单
- const ORDER_PURCHASE_RE = 'PR'; // 商盟采购员充值
- const ORDER_ALLIANCE_MEMBER = 'AM'; // 商盟会员卡
- const STORE_ORDER_RECHARGE = 'SG'; // 充值订单
- const ADOPT_COST_ORDER = 'AD'; // 认养费用订单
- const ALIPAY_ACTIVITY_DELIVERY = 'AAD'; // 推广活动外部订单
- const ALIPAY_VOUCHAR_CODE = 'VC';//支付宝券码外部单号
- const LEAGUE_PRICE = 'LP';//商城联盟券充值
- const ERP_PURCHASE = 'EP';//ERP采购单
- const ERP_PURCHASE_IN = 'EQ';//ERP入库单
- const ERP_PURCHASE_OUT = 'EO';//ERP出库单
-
- const REPORT_INFO = 'RE';//全域产品
- public static $validOrderType = [
- self::ORDER_MALL,
- self::ORDER_MS,
- self::ORDER_PT,
- self::ORDER_BOOK,
- self::ORDER_BARGAIN,
- self::ORDER_INTEGRAL,
- self::ORDER_LOTTERY,
- self::ORDER_SUPPLIER,
- self::ORDER_RECHARGE,
- self::ORDER_UNION,
- self::ORDER_CASH,
- self::ORDER_LOCAL_CASH,
- self::ORDER_LEVEL,
- self::ORDER_INTEGRAL_COUPON,
- self::ORDER_SCRATCH,
- self::ORDER_STEP,
- self::ORDER_POND,
- self::ORDER_BARGAIN_REFUND,
- self::ORDER_MCH_CASH,
- self::ORDER_SCAN_CODE_PAY,
- self::ORDER_SAAS_INTEGRAL,
- self::ORDER_SAAS_PROFIT_CASH,
- self::ORDER_ALIPAY_FOOD,
- self::STORE_ORDER_RECHARGE,
- self::ORDER_ALLIANCE,
- self::ORDER_ALLIANCE_PURCHASE,
- self::LEAGUE_PRICE,
- self::ORDER_PURCHASE_RE,
- self::ORDER_ALLIANCE_MEMBER,
- self::ADOPT_COST_ORDER,
- self::ALIPAY_ACTIVITY_DELIVERY,
- self::ALIPAY_VOUCHAR_CODE,
- self::REPORT_INFO,
-
- self::ERP_PURCHASE,
- self::ERP_PURCHASE_IN,
- ];
- public static function checkOrderNo($order_no, $type)
- {
- if(!empty($type) && (strpos($order_no, $type) !== false)){
- return true;
- }
- return false;
- }
- /**
- * 根据订单类型生成订单号
- * @param $type
- * @return null | string
- */
- public static function getOrderNo($type)
- {
- $order_no = null;
- while (true) {
- $order_no = $type.date('YmdHis') . mt_rand(100000, 999999);
- switch ($type) {
- case self::ORDER_MALL:
- $exist_order_no = Order::find()->where(['order_no' => $order_no])->exists();
- break;
- // case self::ORDER_MS:
- // $exist_order_no = MsOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_PT:
- // $exist_order_no = PtOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_BOOK:
- // $exist_order_no = YyOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_BARGAIN:
- // $exist_order_no = BargainOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_INTEGRAL:
- // $exist_order_no = IntegralOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_SUPPLIER:
- // $exist_order_no = SupplierOrderNew::find()->where(['order_no' => $order_no])->exists();
- // break;
- case self::ORDER_RECHARGE:
- $exist_order_no = ReOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_UNION:
- $exist_order_no = OrderUnion::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_CASH:
- $exist_order_no = Cash::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_LOCAL_CASH:
- $exist_order_no = LocalDeliveryCash::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_MCH_CASH:
- $exist_order_no = MchCash::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_LEVEL:
- $exist_order_no = LevelOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_SCAN_CODE_PAY:
- $exist_order_no = \app\plugins\scanCodePay\models\Order::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_SAAS_INTEGRAL:
- $exist_order_no = SaasIntegralOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_SAAS_PROFIT_CASH:
- $exist_order_no = SaasProfitCash::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_ALIPAY_FOOD:
- $exist_order_no = FoodOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::STORE_ORDER_RECHARGE:
- $exist_order_no = StoreReOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_ALLIANCE_MEMBER:
- $exist_order_no = BusinessMemberOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ORDER_ALLIANCE:
- $exist_order_no = Order::find()->where(['order_no' => $order_no])->exists();
- case self::ORDER_ALLIANCE_PURCHASE:
- $exist_order_no = PurchaseOrder::find()->where(['order_no' => $order_no])->exists();
- case self::ORDER_PURCHASE_RE:
- $exist_order_no = \app\models\PurchaseReOrder::find()->where(['order_no' => $order_no])->exists();
- case self::LEAGUE_PRICE:
- $exist_order_no = \app\models\RechargeReOrder::find()->where(['order_no' => $order_no])->exists();
- case self::ADOPT_COST_ORDER:
- $exist_order_no = AdoptCostOrder::find()->where(['order_no' => $order_no])->exists();
- break;
- // case self::ORDER_INTEGRAL_COUPON:
- // $exist_order_no = IntegralCouponOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_SCRATCH:
- // $exist_order_no = ScratchOrder::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_STEP:
- // $exist_order_no = \app\plugins\step\models\Order::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_POND:
- // $exist_order_no = \app\plugins\pond\models\models\Order::find()->where(['order_no' => $order_no])->exists();
- // break;
- // case self::ORDER_BARGAIN_REFUND:
- // $exist_order_no = BargainOrderRefund::find()->where(['order_refund_no' => $order_no])->exists();
- // break;
- case self::ALIPAY_ACTIVITY_DELIVERY:
- $exist_order_no = AlipayActivityDelivery::find()->where(['order_no' => $order_no])->exists();
- break;
- case self::ALIPAY_VOUCHAR_CODE:
- $exist_order_no = AlipayVoucherCode::find()->where(['order_no' => $order_no])->exists();
- default:;
- }
- if (!$exist_order_no) {
- break;
- }
- }
- return $order_no;
- }
- }
|