|
@@ -12,13 +12,31 @@ class Hexiao extends Api
|
|
|
protected $noNeedLogin = [];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
+ public function __construct(){
|
|
|
+ parent::__construct();
|
|
|
+
|
|
|
+ if($this->auth->is_hexiao != 1){$this->error('没有核销权限');}
|
|
|
+ }
|
|
|
+
|
|
|
+ //首页
|
|
|
+ public function index(){
|
|
|
+
|
|
|
+ $wallet = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->find();
|
|
|
+
|
|
|
+ $rs = [
|
|
|
+ 'hexiaomoney' => $wallet['hexiaomoney'],
|
|
|
+ 'takecash' => $wallet['hexiaomoney'],
|
|
|
+ 'wait' => 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
|
|
|
//订单详情
|
|
|
//code:order_hexiao_no|2024090466d7c9d5abb1c1
|
|
|
//order_no:2024090466d7c9d5abb1c1
|
|
|
public function order_info()
|
|
|
{
|
|
|
- if($this->auth->is_hexiao != 1){$this->error('没有核销权限');}
|
|
|
|
|
|
$code = input('code','');
|
|
|
if(strpos($code,'order_hexiao_no|') !== 0){
|
|
@@ -72,7 +90,6 @@ class Hexiao extends Api
|
|
|
|
|
|
//完成核销动作
|
|
|
public function hexiao(){
|
|
|
- if($this->auth->is_hexiao != 1){$this->error('没有核销权限');}
|
|
|
|
|
|
$code = input('code','');
|
|
|
if(strpos($code,'order_hexiao_no|') !== 0){
|
|
@@ -132,9 +149,38 @@ class Hexiao extends Api
|
|
|
$this->success('核销成功');
|
|
|
}
|
|
|
|
|
|
+ //核销统计
|
|
|
+ public function order_sum(){
|
|
|
+ $startdate = input('startdate',date('Y-m-d'));
|
|
|
+ $enddate = input('enddate' ,date('Y-m-d'));
|
|
|
+
|
|
|
+ $starttime = strtotime($startdate);
|
|
|
+ $endtime = strtotime($enddate) + 86399;
|
|
|
+
|
|
|
+ $condition = [
|
|
|
+ 'hexiao_uid' => $this->auth->id,
|
|
|
+ 'status' => 1,
|
|
|
+ 'have_paid' => ['gt',0],
|
|
|
+ 'have_delivered' => ['gt',0],
|
|
|
+ 'have_received' => ['gt',0],
|
|
|
+ ];
|
|
|
+ $count = Db::name('unishop_order')->where($condition)->where('have_received','BETWEEN',[$starttime,$endtime])->count();
|
|
|
+ $total_price = Db::name('unishop_order')->where($condition)->where('have_received','BETWEEN',[$starttime,$endtime])->sum('total_price');
|
|
|
+
|
|
|
+ $rs = [
|
|
|
+ 'count' => $count,
|
|
|
+ 'total_price' => $total_price,
|
|
|
+ ];
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
//核销记录
|
|
|
public function order_list(){
|
|
|
- if($this->auth->group_id != 3){$this->error('你是不是来错地方了?');}
|
|
|
+ $startdate = input('startdate',date('Y-m-d'));
|
|
|
+ $enddate = input('enddate' ,date('Y-m-d'));
|
|
|
+
|
|
|
+ $starttime = strtotime($startdate);
|
|
|
+ $endtime = strtotime($enddate) + 86399;
|
|
|
|
|
|
$orderModel = new \addons\unishop\model\Order();
|
|
|
|
|
@@ -153,21 +199,12 @@ class Hexiao extends Api
|
|
|
|
|
|
])
|
|
|
->where($condition)
|
|
|
+ ->where('have_received','BETWEEN',[$starttime,$endtime])
|
|
|
->order(['have_received' => 'desc'])
|
|
|
->autopage()
|
|
|
->select();
|
|
|
|
|
|
- //预约日期
|
|
|
- $week_data = [
|
|
|
- 0 => '周日',
|
|
|
- 1 => '周一',
|
|
|
- 2 => '周二',
|
|
|
- 3 => '周三',
|
|
|
- 4 => '周四',
|
|
|
- 5 => '周五',
|
|
|
- 6 => '周六',
|
|
|
- 7 => '周日',
|
|
|
- ];
|
|
|
+
|
|
|
|
|
|
foreach ($result as &$item) {
|
|
|
$item->append(['order_id','state']);
|
|
@@ -175,30 +212,12 @@ class Hexiao extends Api
|
|
|
|
|
|
unset($item['pay_out_trade_no']);
|
|
|
|
|
|
- /*$evaluate = array_column($item['evaluate'], 'product_id');
|
|
|
- $refundProducts = array_column($item['refund_products'], 'order_product_id');
|
|
|
- unset($item['evaluate']);
|
|
|
- unset($item['refund_products']);*/
|
|
|
+
|
|
|
|
|
|
foreach ($item['products'] as &$product) {
|
|
|
$product['image'] = cdnurl($product['image']);
|
|
|
- // 是否已评论
|
|
|
- /*if (in_array($product['id'], $evaluate)) {
|
|
|
- $product['evaluate'] = true;
|
|
|
- } else {
|
|
|
- $product['evaluate'] = false;
|
|
|
- }*/
|
|
|
-
|
|
|
- // 是否退货
|
|
|
- /*if ($item['refund_status'] == self::REFUND_STATUS_AGREE && in_array($product['order_product_id'], $refundProducts)) {
|
|
|
- $product['refund'] = true;
|
|
|
- } else {
|
|
|
- $product['refund'] = false;
|
|
|
- }*/
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- $item['bookdate'] = date('Y-m-d H:i',$item['booktime']) .' '. $week_data[date('w',$item['booktime'])];
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|