ソースを参照

订单提交可选择期数

kevin 1 年間 前
コミット
346702d882

+ 22 - 9
common/helpers/bonus/Calc/CalcConsole.php

@@ -151,9 +151,9 @@ class CalcConsole extends BaseBusiness
         $periodNum = $currentPeriod['PERIOD_NUM'];
         $prevPeriodNum = $periodNum - 1;    // 121
         $prevPeriod = Period::find()->where('PERIOD_NUM = :PERIOD_NUM',[':PERIOD_NUM'=>$prevPeriodNum])->asArray()->one();
-        if($prevPeriod['IS_SENT']==0){
-            return;
-        }
+//        if($prevPeriod['IS_SENT']==0) {
+//            return;
+//        }
         if (
             Period::isPreparing($periodNum)
 //            || $currentPeriod['IS_MONTH'] == 0
@@ -174,17 +174,30 @@ class CalcConsole extends BaseBusiness
             return;
         }
 
-        if( 1 < $nowDate && 10 >= $nowDate ){ // 10号及以前,不是0点,则跳过
-            if( $nowHour != 0) {
+        // 如果上一期没有挂网,则1-5号以及26~月底,每小时执行一次
+        if ($prevPeriod['IS_SENT'] == 0) {
+            // 每小时整点执行一次
+            if ($nowMin != 0) {
                 return;
             }
-        }
-
-        if( 15 < $nowDate && 25 >= $nowDate ){ // 下半月前10天,不是0点,则跳过
-            if( $nowHour != 0) {
+            // 10~25不执行
+            if ($nowDate >= 10 && $nowDate <= 25) {
                 return;
             }
+        } else {
+            if( 1 < $nowDate && 10 >= $nowDate ){ // 10号及以前,不是0点,则跳过
+                if( $nowHour != 0) {
+                    return;
+                }
+            }
+
+            if( 15 < $nowDate && 25 >= $nowDate ){ // 下半月前10天,不是0点,则跳过
+                if( $nowHour != 0) {
+                    return;
+                }
+            }
         }
+
 //        if($nowDate >1 && $nowDate <= 15 || (($nowMin!=0 || $nowSec >= 5 ) || Period::isPreparing($periodNum)) ){ // 当不是整点小时,当计算中,不计算
 //            return;
 //        }

+ 5 - 3
common/models/forms/ApproachDeclarationForm.php

@@ -80,6 +80,7 @@ class ApproachDeclarationForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
+    private $period;
 
     // 批量报单时添加会员的REDIS里面缓存的添加的会员资料
     const REDIS_WAIT_ADD_USER = 'user:dec:waitAdd';
@@ -740,7 +741,8 @@ class ApproachDeclarationForm extends Model
      * @throws \yii\db\Exception
      */
     public function addUser($allData){
-        $period = Period::instance();
+        $periodObj = Period::instance();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
         // 增加会员
         $user = new User();
         $user->USER_NAME = $this->insertUserName;
@@ -772,7 +774,7 @@ class ApproachDeclarationForm extends Model
         $user->IS_DEC = 0;
         $user->DEC_ID = $this->_decId ?? null;
         $user->DEC_ROLE_ID = $this->decRoleId ?? null;
-        $user->PERIOD_AT = $period->getNowPeriodNum();
+        $user->PERIOD_AT = $nowPeriodNum;
         $user->IS_DIRECT_SELLER = 0;
         $user->VERIFIED = 1;
         $user->VERIFIED_AT = Date::nowTime();
@@ -810,7 +812,7 @@ class ApproachDeclarationForm extends Model
      */
     public function addDecOrder(){
         $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
         $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
 
         $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);

+ 7 - 3
common/models/forms/ApproachDeclarationUpgradeForm.php

@@ -63,6 +63,7 @@ class ApproachDeclarationUpgradeForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
+    private $period;
     
     const TYPE_ZC = 'ZC';
     private $_userForm = null;
@@ -268,15 +269,18 @@ class ApproachDeclarationUpgradeForm extends Model
      */
     public function addDecOrder($insertConId, $insertRecId, $oriDecLv, $isObserve, $remark = ''): ApproachOrder
     {
+        $periodObj = Period::instance();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
         $warehouse = Region::getWarehouseByCode($this->province);//仓库
         if(!$warehouse){
             throw new Exception(Yii::t('app', 'deliveryTemporarilyNotSupported'), 400);
         }
 
         $upgradeType = $isObserve ? 1 : 2; // 1补差  2全额
-        $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
-        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+//        $periodObj = Period::instance();
+//        $nowPeriodNum = $periodObj->getNowPeriodNum();
+//        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
         $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
 
         // 加入报单信息

+ 3 - 1
common/models/forms/ApproachOrderForm.php

@@ -71,6 +71,7 @@ class ApproachOrderForm extends Model
     private $_standardAmount;
     private $_decAmountStandard;
     private $_userName;
+    private $period;
 
     /**
      * @var ApproachOrder
@@ -538,7 +539,8 @@ class ApproachOrderForm extends Model
     public function addOrder()
     {
         $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
+//        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
         $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
 
         $userId = \Yii::$app->user->id;

+ 5 - 3
common/models/forms/DeclarationForm.php

@@ -76,6 +76,7 @@ class DeclarationForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
+    private $period;
 
     // 批量报单时添加会员的REDIS里面缓存的添加的会员资料
     const REDIS_WAIT_ADD_USER = 'user:dec:waitAdd';
@@ -771,7 +772,8 @@ class DeclarationForm extends Model
      * @throws \yii\db\Exception
      */
     public function addUser($allData){
-        $period = Period::instance();
+        $periodObj = Period::instance();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
         // 增加会员
         $user = new User();
         $user->USER_NAME = $this->insertUserName;
@@ -803,7 +805,7 @@ class DeclarationForm extends Model
         $user->IS_DEC = 0;
         $user->DEC_ID = $this->_decId ?? null;
         $user->DEC_ROLE_ID = $this->decRoleId ?? null;
-        $user->PERIOD_AT = $period->getNowPeriodNum();
+        $user->PERIOD_AT = $nowPeriodNum;
         $user->IS_DIRECT_SELLER = 0;
         $user->VERIFIED = 1;
         $user->VERIFIED_AT = Date::nowTime();
@@ -844,7 +846,7 @@ class DeclarationForm extends Model
      */
     public function addDecOrder(){
         $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
         $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
 
         $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);

+ 8 - 3
common/models/forms/DeclarationUpgradeForm.php

@@ -60,6 +60,7 @@ class DeclarationUpgradeForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
+    private $period;
 
     const TYPE_ZC = 'ZC';
     private $_userForm = null;
@@ -269,14 +270,18 @@ class DeclarationUpgradeForm extends Model
      * @throws \yii\db\Exception
      */
     public function addDecOrder($insertConId,$insertRecId,$oriDecLv,$isObserve,$remark=''){
+        $periodObj = Period::instance();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+
         $warehouse = Region::getWarehouseByCode($this->province);//仓库
         if(!$warehouse){
             throw new Exception(Yii::t('app', 'deliveryTemporarilyNotSupported'), 400);
         }
         $upgradeType = $isObserve ? 1 : 2; // 1补差  2全额
-        $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
-        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+//        $periodObj = Period::instance();
+//        $nowPeriodNum = $periodObj->getNowPeriodNum();
+//        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
         $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
         // 加入报单信息
         $db = \Yii::$app->db;

+ 3 - 1
common/models/forms/OrderForm.php

@@ -67,6 +67,7 @@ class OrderForm extends Model
     private $_exchangeRate;
     private $_remainPv;
     private $_realPv;
+    private $period;
 
     /**
      * @var Order
@@ -695,7 +696,8 @@ class OrderForm extends Model
      */
     public function addOrder(){
         $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
+//        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowPeriodNum = $this->period ?: $periodObj->getNowPeriodNum();
         $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
 
         $userId = \Yii::$app->user->id;

+ 1 - 0
frontendApi/config/params.php

@@ -18,6 +18,7 @@ return [
         'v1/site/config',
         'v1/shop/verify-approach-order',
         'v1/finance/prove-add',
+        'v1/bonus/period',
         ],
     'noCheckPermissionActions' => [],
 ];

+ 1 - 0
frontendApi/config/urlManagerRules.php

@@ -153,6 +153,7 @@ return [
             'GET dec-period' => 'dec-period',
             'GET fc-point' => 'fc-point',
             'GET historical-cumulative-bonus' => 'historical-cumulative-bonus',
+            'GET period' => 'period',
         ],
     ],
     [

+ 21 - 0
frontendApi/modules/v1/controllers/BonusController.php

@@ -52,6 +52,7 @@ use common\models\UserRelation;
 use common\models\Withdraw;
 use frontendApi\modules\v1\models\User;
 use Yii;
+use yii\web\HttpException;
 use yii\web\UploadedFile;
 
 class BonusController extends BaseController {
@@ -1090,4 +1091,24 @@ class BonusController extends BaseController {
         ]);
         return static::notice($data);
     }
+
+    /**
+     * 查询可用期数
+     * @return mixed
+     * @throws HttpException
+     */
+    public function actionPeriod() {
+        $nowTs = time();
+        // 当前期
+        $currentPeriod = Period::find()->where('START_TIME<:NOW_TIME', ['NOW_TIME' => $nowTs])->where('END_TIME>=:NOW_TIME', ['NOW_TIME' => $nowTs - 6])->asArray()->one();
+        $data[] = $currentPeriod['PERIOD_NUM'];
+        // 上一期是否封期
+        $prevPeriodNum = $currentPeriod['PERIOD_NUM'] - 1;
+        $prevPeriod = Period::find()->where('PERIOD_NUM=:PERIOD_NUM AND IS_SENT=0', [':PERIOD_NUM' => $prevPeriodNum])->asArray()->one();
+        if ($prevPeriod) {
+            $data[] = $prevPeriod['PERIOD_NUM'];
+        }
+
+        return static::notice(['data' => $data]);
+    }
 }