Ejemplo n.º 1
0
Archivo: U.php Proyecto: noikiy/wowewe
 public static function getLastDayOfLastMonth()
 {
     $year = date('Y');
     $month = date('m');
     if ($month == 1) {
         $year = $year - 1;
         $last_month = 12;
     } else {
         $last_month = $month - 1;
     }
     $theFirstDayOfLastMonth = U::getFirstDate($year, $last_month);
     $theLastDayOfLastMonth = U::getLastDate($year, $last_month);
     return $theLastDayOfLastMonth;
 }
Ejemplo n.º 2
0
 public function actionOrder($filename = 'order.csv', $date = null)
 {
     $filepathname = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'exported_data' . DIRECTORY_SEPARATOR . $filename;
     $fh = fopen($filepathname, 'w');
     if (null === $date) {
         $date = \app\models\U::getFirstDate(date('Y'), date('m'));
     }
     $total_count = \app\models\MOrder::find()->where(['>', 'create_time', $date])->count();
     //$total_count = \app\models\MUser::find()->count();
     $step = 300;
     $start = 0;
     while ($start < $total_count) {
         $orders = \app\models\MOrder::find()->offset($start)->limit($step)->where(['>', 'create_time', $date])->orderBy(['create_time' => SORT_ASC])->all();
         fprintf($fh, "营业厅, 订单号, 商品, 价格, 订单时间, 身份证, 用户姓名, 联系电话, 支付方式, 订单状态, 开通, 备注, 用户类型\n");
         foreach ($orders as $order) {
             $office = \app\models\MOffice::findOne(['office_id' => $order->office_id]);
             if (!empty($office)) {
                 $office_title = $office->title;
             } else {
                 $office_title = "";
             }
             $user = \app\models\MUser::findOne(['openid' => $order->openid]);
             $customerFlag = '--';
             /*
             if ($user->bindMobileIsInside('wx_t1')) {
                 $customerFlag = '老';
             } elseif ($user->bindMobileIsInside('wx_t2')) {
                 $customerFlag = '老';
             }elseif ($user->bindMobileIsInside('wx_t3')) {
                 $customerFlag = '老';
             } else {
                 $customerFlag = '新';
             }
             */
             if ($user->bindMobileIsInside('wx_oldcustomer')) {
                 $customerFlag = '老';
             } else {
                 $customerFlag = '新';
             }
             $pay_kind = \app\models\MOrder::getOrderPayKindOption($order->pay_kind);
             $price = $order->feesum / 100;
             $paystatus = \app\models\MOrder::getOrderStatusName($order->status);
             //echo $office_title."\t".$order->oid."\t".$order->title."\t".$price."\t".$order->create_time."\t".$order->userid."\t".$order->username."\t".$order->usermobile."\t".$pay_kind."\t".$order->memo."\t".$order->customerFlag."\t\n";
             fprintf($fh, "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s\n", $office_title, $order->oid, $order->title, $price, $order->create_time, $order->userid, $order->username, $order->usermobile, $pay_kind, $paystatus, $order->kaitong, $order->memo, $order->customerFlag);
         }
         $start += $step;
     }
     fclose($fh);
 }