瀏覽代碼

版本更新

linwu 1 年之前
父節點
當前提交
069feece7d
共有 100 個文件被更改,包括 3024 次插入1026 次删除
  1. 1 0
      admin/static/css/chunk-023b2e94.b1dd7a76.css
  2. 0 0
      admin/static/css/chunk-582e4c70.e13ac41f.css
  3. 1 0
      admin/static/js/chunk-023b2e94.e3c7ef49.js
  4. 1 0
      admin/static/js/chunk-2d230fe7.fa6892be.js
  5. 0 0
      admin/static/js/chunk-582e4c70.31db559f.js
  6. 15 1
      app/admin/controller/AgentController.php
  7. 1 1
      app/admin/controller/ArticleController.php
  8. 8 2
      app/admin/controller/Base.php
  9. 16 2
      app/admin/controller/BottommenuController.php
  10. 4 2
      app/admin/controller/ConfigController.php
  11. 3 2
      app/admin/controller/CouponController.php
  12. 20 4
      app/admin/controller/DiyfieldsController.php
  13. 6 8
      app/admin/controller/GoodsController.php
  14. 179 0
      app/admin/controller/GoodsgiftcardtypeController.php
  15. 2 1
      app/admin/controller/LangController.php
  16. 3 5
      app/admin/controller/LoginController.php
  17. 15 9
      app/admin/controller/MemberController.php
  18. 2 0
      app/admin/controller/MemberauthgroupController.php
  19. 1 13
      app/admin/controller/OperatingcityController.php
  20. 35 8
      app/admin/controller/OrderController.php
  21. 27 12
      app/admin/controller/OrderrefundController.php
  22. 91 0
      app/admin/controller/PlatformController.php
  23. 87 0
      app/admin/controller/ReglikeController.php
  24. 11 11
      app/admin/controller/StoreController.php
  25. 3 1
      app/admin/controller/SysbaseController.php
  26. 74 0
      app/admin/controller/TechnicalcertificateController.php
  27. 29 14
      app/admin/controller/TechnicalincomelogController.php
  28. 3 2
      app/admin/controller/TextreplaceController.php
  29. 29 11
      app/admin/controller/TuanzhangincomelogController.php
  30. 30 9
      app/admin/controller/UpgradeController.php
  31. 2 0
      app/admin/controller/UsersController.php
  32. 51 7
      app/common.php
  33. 41 11
      app/index/controller/AddressController.php
  34. 1 2
      app/index/controller/AdminstoreController.php
  35. 15 1
      app/index/controller/AgentController.php
  36. 1 0
      app/index/controller/ArticleController.php
  37. 3 1
      app/index/controller/Base.php
  38. 2 2
      app/index/controller/CartController.php
  39. 1 1
      app/index/controller/CategoryController.php
  40. 42 3
      app/index/controller/CouponreceiveController.php
  41. 54 9
      app/index/controller/DiypageController.php
  42. 43 10
      app/index/controller/GoodsController.php
  43. 19 17
      app/index/controller/HousingestateController.php
  44. 3 1
      app/index/controller/MemberController.php
  45. 94 0
      app/index/controller/MemberwishlistController.php
  46. 18 20
      app/index/controller/OperatingcityController.php
  47. 82 25
      app/index/controller/OrderController.php
  48. 44 0
      app/index/controller/OrdercardController.php
  49. 37 0
      app/index/controller/OrdertimescardtecordController.php
  50. 12 0
      app/index/controller/QrcodeController.php
  51. 1 13
      app/index/controller/RegisterfieldController.php
  52. 23 0
      app/index/controller/ReglikeController.php
  53. 36 32
      app/index/controller/SigninController.php
  54. 20 3
      app/index/controller/StoreController.php
  55. 12 6
      app/index/controller/TechnicalController.php
  56. 1 1
      app/index/controller/TuanzhangController.php
  57. 21 13
      app/index/controller/WechatmpController.php
  58. 17 9
      app/index/controller/WithdrawController.php
  59. 20 19
      app/index/controller/kefu/ChatlogController.php
  60. 6 0
      app/model/Agent.php
  61. 27 0
      app/model/Category.php
  62. 1 1
      app/model/DiyPageLink.php
  63. 20 10
      app/model/Geocoder.php
  64. 53 19
      app/model/Goods.php
  65. 15 0
      app/model/GoodsGiftcardCommission.php
  66. 75 0
      app/model/GoodsGiftcardType.php
  67. 14 0
      app/model/Member.php
  68. 1 0
      app/model/MessageSms.php
  69. 75 0
      app/model/MiaoshaGoods.php
  70. 19 0
      app/model/Operatingcity.php
  71. 213 125
      app/model/Order.php
  72. 31 0
      app/model/OrderCard.php
  73. 8 8
      app/model/OrderGoods.php
  74. 0 9
      app/model/OrderStaff.php
  75. 15 0
      app/model/OrderTimescard.php
  76. 61 0
      app/model/OrderTimescardRecord.php
  77. 0 9
      app/model/OrderTuanzhang.php
  78. 1 0
      app/model/Partner.php
  79. 0 9
      app/model/Paymethod.php
  80. 39 0
      app/model/Platform.php
  81. 12 2
      app/model/PrinterFeie.php
  82. 78 16
      app/model/RegisterField.php
  83. 15 0
      app/model/Reglike.php
  84. 4 3
      app/model/Signin.php
  85. 61 0
      app/model/Store.php
  86. 29 2
      app/model/Technical.php
  87. 83 0
      app/model/TechnicalCertificate.php
  88. 1 1
      app/model/TextReplace.php
  89. 75 1
      app/model/TuanGoods.php
  90. 2 0
      app/model/Tuanzhang.php
  91. 62 54
      app/samos/wechat/MiniProgram.php
  92. 1 1
      config/database.php
  93. 25 5
      config/my.php
  94. 487 425
      data/installdata.sql
  95. 2 2
      h5/index.html
  96. 0 0
      h5/static/index.2da1efab.css
  97. 0 0
      h5/static/js/chunk-vendors.71cdce8b.js
  98. 0 0
      h5/static/js/chunk-vendors.c1302c01.js
  99. 0 0
      h5/static/js/index.67a04beb.js
  100. 0 0
      h5/static/js/index.803937c5.js

+ 1 - 0
admin/static/css/chunk-023b2e94.b1dd7a76.css

@@ -0,0 +1 @@
+.errPage-container[data-v-35ca77fc]{width:800px;max-width:100%;margin:100px auto}.errPage-container .pan-back-btn[data-v-35ca77fc]{background:#008489;color:#fff;border:none!important}.errPage-container .pan-gif[data-v-35ca77fc]{margin:0 auto;display:block}.errPage-container .pan-img[data-v-35ca77fc]{display:block;margin:0 auto;width:100%}.errPage-container .text-jumbo[data-v-35ca77fc]{font-size:60px;font-weight:700;color:#484848}.errPage-container .list-unstyled[data-v-35ca77fc]{font-size:14px}.errPage-container .list-unstyled li[data-v-35ca77fc]{padding-bottom:5px}.errPage-container .list-unstyled a[data-v-35ca77fc]{color:#008489;text-decoration:none}.errPage-container .list-unstyled a[data-v-35ca77fc]:hover{text-decoration:underline}

文件差異過大導致無法顯示
+ 0 - 0
admin/static/css/chunk-582e4c70.e13ac41f.css


+ 1 - 0
admin/static/js/chunk-023b2e94.e3c7ef49.js

@@ -0,0 +1 @@
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-023b2e94"],{"24e2":function(t,a,i){"use strict";i.r(a);var e=function(){var t=this,a=t.$createElement,i=t._self._c||a;return i("div",{staticClass:"errPage-container"},[i("el-button",{staticClass:"pan-back-btn",attrs:{icon:"el-icon-arrow-left"},on:{click:t.back}},[t._v(" 返回 ")]),i("el-row",[i("el-col",{attrs:{span:12}},[i("h1",{staticClass:"text-jumbo text-ginormous"},[t._v(" Oops! ")]),t._v(" gif来源"),i("a",{attrs:{href:"https://zh.airbnb.com/",target:"_blank"}},[t._v("airbnb")]),t._v(" 页面 "),i("h2",[t._v("你没有权限去该页面")]),i("h6",[t._v("如有不满请联系你领导")]),i("ul",{staticClass:"list-unstyled"},[i("li",[t._v("或者你可以去:")]),i("li",{staticClass:"link-type"},[i("router-link",{attrs:{to:"/dashboard"}},[t._v(" 回首页 ")])],1),i("li",{staticClass:"link-type"},[i("a",{attrs:{href:"https://www.taobao.com/"}},[t._v("随便看看")])]),i("li",[i("a",{attrs:{href:"#"},on:{click:function(a){a.preventDefault(),t.dialogVisible=!0}}},[t._v("点我看图")])])])]),i("el-col",{attrs:{span:12}},[i("img",{attrs:{src:t.errGif,width:"313",height:"428",alt:"Girl has dropped her ice cream."}})])],1),i("el-dialog",{attrs:{visible:t.dialogVisible,title:"随便看"},on:{"update:visible":function(a){t.dialogVisible=a}}},[i("img",{staticClass:"pan-img",attrs:{src:t.ewizardClap}})])],1)},s=[],r=i("cc6c"),l=i.n(r),c={name:"Page401",data(){return{errGif:l.a+"?"+ +new Date,ewizardClap:"https://wpimg.wallstcn.com/007ef517-bafd-4066-aae4-6883632d9646",dialogVisible:!1}},methods:{back(){this.$route.query.noGoBack?this.$router.push({path:"/dashboard"}):this.$router.go(-1)}}},n=c,o=(i("fa66"),i("2877")),u=Object(o["a"])(n,e,s,!1,null,"35ca77fc",null);a["default"]=u.exports},5633:function(t,a,i){},cc6c:function(t,a,i){t.exports=i.p+"static/img/401.089007e7.gif"},fa66:function(t,a,i){"use strict";i("5633")}}]);

+ 1 - 0
admin/static/js/chunk-2d230fe7.fa6892be.js

@@ -0,0 +1 @@
+(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d230fe7"],{ef3c:function(e,r,t){"use strict";t.r(r);var n,u,a={created(){const{params:e,query:r}=this.$route,{path:t}=e;this.$router.replace({path:"/"+t,query:r})},render:function(e){return e()}},c=a,o=t("2877"),p=Object(o["a"])(c,n,u,!1,null,null,null);r["default"]=p.exports}}]);

文件差異過大導致無法顯示
+ 0 - 0
admin/static/js/chunk-582e4c70.31db559f.js


+ 15 - 1
app/admin/controller/AgentController.php

@@ -32,7 +32,7 @@ class AgentController extends Base
 
 		if (!empty($res['data'])) {
 			foreach ($res['data'] as &$vo) {
-				$vo['agent_level'] = AgentLevel::getLevel($vo['agent_level']) ?? '初级';
+				$vo = Agent::conversion($vo);
 			}
 		}
 		$data['data'] = $res;
@@ -46,6 +46,7 @@ class AgentController extends Base
 	{
 		$keyword = trim(input('post.keyword', '', 'serach_in'));
 		$status = input('post.status', '', 'serach_in');
+		$create_time = input('post.create_time', '', 'serach_in');
 		$path = input('post.path', '', 'serach_in');
 		$weid = weid();
 
@@ -55,6 +56,10 @@ class AgentController extends Base
 
 		$query = Agent::where(['weid' => $weid]);
 
+		if (!empty($create_time)) {
+			$query->where('create_time', 'between', [strtotime($create_time[0]), strtotime($create_time[1])]);
+		}
+
 		if (!empty($keyword)) {
 			$query->where('title|tel', 'like', '%' . $keyword . '%');
 		}
@@ -103,6 +108,15 @@ class AgentController extends Base
 
 		return $this->json($data);
 	}
+	//导出
+	function dumpdata()
+	{
+		$page = $this->request->post('page', 1, 'intval');
+		$ptype = 'agent';
+		$query = $this->setSearch();
+		$data = RegisterField::dumpdata($query, $ptype, $page);
+		return $this->json($data);
+	}
 
 	public function agentorder()
 	{

+ 1 - 1
app/admin/controller/ArticleController.php

@@ -69,7 +69,7 @@ class ArticleController extends Base
 		$id =  $this->request->post('id', '', 'serach_in');
 		if (!$id) throw new ValidateException('参数错误');
 		$data = Article::field('*')->find($id)->toArray();
-
+		$data['content'] = \app\model\DomainReplace::setreplace($data['content']);
 		return $this->json(['data' => $data]);
 	}
 

+ 8 - 2
app/admin/controller/Base.php

@@ -21,6 +21,7 @@ class Base extends \app\BaseController
 	protected $ocid = '';
 	protected $tzid = '';
 	protected $console = '';
+	protected $cashregister = '';
 	protected $actionurl = '';
 
 	protected function initialize()
@@ -92,6 +93,8 @@ class Base extends \app\BaseController
 		$this->ocid =  $arr['ocid'];
 		$this->tzid =  $arr['tzid'];
 		$this->console =  $arr['console'];
+		$this->cashregister =  $arr['cashregister'];
+
 		$_W['i'] = $arr['i'];
 
 		return $token;
@@ -201,10 +204,11 @@ class Base extends \app\BaseController
 		$where = [];
 		$where[] = ['type', 'in', [0, 1]];
 		$where[] = ['status', '=', 1];
-
 		$query = \app\model\AdminMenu::where($where);
 		if (!empty($this->sid)) {
 			$query->where('is_store', 1);
+		} elseif (!empty($this->cashregister)) {
+			$query->where('is_cashregister', 1);
 		} elseif (!empty($this->ocid)) {
 			$query->where('is_city', 1);
 		} elseif (!empty($this->tzid)) {
@@ -299,7 +303,9 @@ class Base extends \app\BaseController
 				$result['data']['page_size'] = $result['data']['per_page'];
 			}
 		}
-		$result = TextReplace::setreplace($result);
+		if (empty($result['no_replace'])) {
+			$result = TextReplace::setreplace($result);
+		}
 		return json($result);
 	}
 

+ 16 - 2
app/admin/controller/BottommenuController.php

@@ -80,14 +80,28 @@ class BottommenuController extends Base
 			if ($data['path'] == '/clientmenu/member') {
 				$data['module'] = 'member';
 			}
-	
+
 			if ($data['path'] == '/bottommenu/technical') {
 				$data['module'] = 'technical';
 			}
-	
+
 			if ($data['path'] == '/bottommenu/store') {
 				$data['module'] = 'store';
 			}
+			if (empty($data['icon'])) {
+				$Original = BottomMenuOriginal::where('url', $data['url'])->find();
+				if ($Original) {
+					$data['icon'] = $Original->icon;
+				}
+			}
+
+			if (empty($data['iconactive'])) {
+				$Original = BottomMenuOriginal::where('url', $data['url'])->find();
+				if ($Original) {
+					$data['iconactive'] = $Original->iconactive;
+				}
+			}
+
 			try {
 				$res = BottomMenu::create($data);
 				if ($res->id && empty($data['sort'])) {

+ 4 - 2
app/admin/controller/ConfigController.php

@@ -31,8 +31,10 @@ class ConfigController extends Base
 			}
 		}
 		if ($mo == 'miniprogram') {
-			if ($config['app_id'] == $config['techapp_id']) {
-				throw new ValidateException("用户端小程序AppId和师傅端AppId不能相同!");
+			if (!empty($config['app_id'])) {
+				if ($config['app_id'] == $config['techapp_id']) {
+					throw new ValidateException("用户端小程序AppId和师傅端AppId不能相同!");
+				}
 			}
 		}
 

+ 3 - 2
app/admin/controller/CouponController.php

@@ -77,8 +77,9 @@ class CouponController extends Base
 		$data = input('post.');
 		unset($data['create_time']);
 
-		$data['start_time'] = strtotime($data['start_time']);
-		$data['end_time'] = strtotime($data['end_time']);
+		$data['start_time'] =  xm_strtotime($data['start_time']);
+		
+		$data['end_time'] =  xm_strtotime($data['end_time']);
 
 		if (empty($id)) {
 			$data['weid'] = weid();

+ 20 - 4
app/admin/controller/DiyfieldsController.php

@@ -13,6 +13,7 @@ use app\model\Store;
 use app\model\Operatingcity;
 use app\model\RegisterField;
 use app\model\Category;
+use app\model\TechnicalCertificate;
 use app\model\StoreCate;
 use app\model\Users;
 use app\model\Openid;
@@ -193,6 +194,12 @@ class DiyfieldsController extends Base
 	function getInfo()
 	{
 		$id =  $this->request->post('id', '', 'serach_in');
+		$path = input('post.path', '', 'serach_in');
+		$is_tzstore =  $this->request->post('is_tzstore', '', 'serach_in');
+		if ($is_tzstore == 1) {
+			$id = Store::getidbytzid($id);
+		}
+
 		$ptype = $this->getPath()[1];
 		$data = RegisterField::getinputField($ptype);
 
@@ -234,7 +241,7 @@ class DiyfieldsController extends Base
 		foreach ($data as &$vo) {
 
 			if ($vo['is_sys'] == 1) {
-				if(!empty($infodata[$vo['fieldsmingcheng']])){
+				if (!empty($infodata[$vo['fieldsmingcheng']])) {
 					$vo['fieldsvalue'] = $infodata[$vo['fieldsmingcheng']];
 				}
 				if ($vo['fieldsmingcheng'] == "sex") {
@@ -242,7 +249,7 @@ class DiyfieldsController extends Base
 				}
 
 				if ($vo['fieldsmingcheng'] == 'category_id') {
-					$vo['selectvaluearray'] = \app\model\TechnicalCategory::getpcarray();
+					$vo['selectvaluearray'] = \app\model\TechnicalCertificate::getpcarray();
 				}
 
 				if ($vo['fieldsmingcheng'] == 'sid') {
@@ -290,6 +297,14 @@ class DiyfieldsController extends Base
 					}
 					$vo['selectvaluearray'] = Category::gettoparray($ctopptype);
 				}
+				if ($vo['inputtype'] == 'checkbox' && $vo['fieldsmingcheng'] == 'certificate_ids') {
+					if (empty($vo['fieldsvalue'])) {
+						$vo['fieldsvalue'] = [];
+					} else {
+						$vo['fieldsvalue'] =  explode(',', $vo['fieldsvalue']);
+					}
+					$vo['selectvaluearray'] = TechnicalCertificate::getpcarray($ctopptype);
+				}
 			} else {
 				$vo['fieldsvalue'] = $customtext[$vo['inputtype']][$vo['id']];
 				if (!empty($vo['selectvalue'])) {
@@ -316,13 +331,14 @@ class DiyfieldsController extends Base
 				$vo['fieldsvalue'] =  time_format($vo['fieldsvalue']);
 			}
 		}
-		if(!empty($infodata)){
+		if (!empty($infodata)) {
 			$retdata['id'] = $infodata['id'];
 			$retdata['uuid'] = $infodata['uuid'];
 			$retdata['infodata'] = $infodata;
 		}
-		
+
 		$retdata['fields'] = $data;
+		$retdata['path'] = $path;
 
 		return $this->json(['data' => $retdata]);
 	}

+ 6 - 8
app/admin/controller/GoodsController.php

@@ -28,7 +28,6 @@ class GoodsController extends Base
 		$ptype = input('post.ptype', '', 'serach_in');
 		$is_times = input('post.is_times', '', 'serach_in');
 		$is_all = input('post.is_all', '', 'serach_in');
-		$is_mg = input('post.is_mg', '', 'serach_in');
 		$status = input('post.status', '', 'serach_in');
 
 		$keyword = input('post.keyword', '', 'serach_in');
@@ -47,7 +46,7 @@ class GoodsController extends Base
 			$ptype = 2;
 		}
 
-		$query = Goods::where(['weid' => $weid, 'is_mg' => (int)$is_mg]);
+		$query = Goods::where(['weid' => $weid]);
 
 		if (!empty($ptype)) {
 			$query->where('ptype', $ptype);
@@ -187,9 +186,9 @@ class GoodsController extends Base
 			if (empty($data['cat_id'])) {
 				throw new ValidateException('请选择分类');
 			}
-			if ($data['is_mg'] == 1) {
-				if (empty($data['mgid'])) {
-					throw new ValidateException('请选择会员等级');
+			if ($data['is_times'] == 3) {
+				if (empty($data['card_tid'])) {
+					throw new ValidateException('请选择卡类型');
 				}
 			}
 			$data['weid'] = weid();
@@ -226,7 +225,6 @@ class GoodsController extends Base
 				}
 			}
 
-
 			if (empty($data['tel'])) {
 				$data['tel'] = '';
 			}
@@ -362,7 +360,7 @@ class GoodsController extends Base
 		$GD = GoodsDescription::where(['goods_id' => $id])->find();
 
 		if (!empty($GD)) {
-			$data['description'] = $GD->description;
+			$data['description'] = \app\model\DomainReplace::setreplace($GD->description);
 		}
 
 		$goods_image = GoodsImage::where(['goods_id' => $id])
@@ -420,7 +418,7 @@ class GoodsController extends Base
 	{
 		$ptype = input('post.ptype', '', 'serach_in');
 		$data['cidarray'] = _generateSelectTree(Category::getpcarray($ptype));
-		$data['mgidarray'] = \app\model\MemberAuthGroup::getpcarray(1);
+		$data['card_tidarray'] = \app\model\GoodsGiftcardType::getpcarray();
 		$data['unitarray'] = \app\model\GoodsQuantityUnit::getpcarray($ptype);
 
 		return $this->json(['data' => $data]);

+ 179 - 0
app/admin/controller/GoodsgiftcardtypeController.php

@@ -0,0 +1,179 @@
+<?php
+
+namespace app\admin\controller;
+
+use think\exception\ValidateException;
+use app\model\GoodsGiftcardType;
+use app\model\GoodsGiftcardCommission;
+use app\model\Category;
+use app\model\Goods;
+
+class GoodsgiftcardtypeController extends Base
+{
+
+	function index()
+	{
+		$weid = weid();
+		$page = input('post.page', 1, 'intval');
+		$keyword = input('post.keyword', '', 'serach_in');
+		$status = input('post.status', '', 'serach_in');
+		$query = GoodsGiftcardType::where(['weid' => $weid]);
+		if (!empty($keyword)) {
+			$query->where('name', 'like', '%' . $keyword . '%');
+		}
+
+		if (!empty($status) || $status === "0") {
+			$query->where(['status' => $status]);
+		}
+		if (!empty($this->sid)) {
+			$query->where('sid', $this->sid);
+		}
+
+		$res = $query->order('sort asc,id desc')
+			->paginate(getpage())
+			->toArray();
+
+		foreach ($res['data'] as &$vo) {
+			if ($vo['expire_type'] == 10) {
+
+				if ($vo['expire_day'] > 0) {
+					$vo['expire_day'] = $vo['expire_day'] . "天";
+				} else {
+					$vo['expire_day'] = "长期";
+				}
+
+				$vo['expire_type'] = '领取后:' . $vo['expire_day'] . '有效';;
+			} elseif ($vo['expire_type'] == 20) {
+
+				$vo['expire_type'] = '有效期:' . time_format($vo['start_time']) . '到' . time_format($vo['end_time']);
+			}
+
+			$vo['color'] = getColor($vo['color']);
+		}
+
+		$data['data'] = $res;
+		return $this->json($data);
+	}
+
+	function listUpdate()
+	{
+		$data = only('id,status,sort');
+		if (!$data['id']) throw new ValidateException('参数错误');
+		GoodsGiftcardType::update($data);
+
+		return $this->json(['msg' => '操作成功']);
+	}
+
+	public function update()
+	{
+		$id = $this->request->post('id');
+		$data = input('post.');
+		unset($data['create_time']);
+
+		$data['start_time'] = strtotime($data['start_time']);
+		$data['end_time'] = strtotime($data['end_time']);
+
+		if (empty($id)) {
+			$data['weid'] = weid();
+			if (!empty($this->sid)) {
+				$data['sid'] = $this->sid;
+			}
+			try {
+				$res = GoodsGiftcardType::create($data);
+				if ($res->id && empty($data['sort'])) {
+					GoodsGiftcardType::update(['sort' => $res->id, 'id' => $res->id]);
+				}
+				$this->_synupdata($data);
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+			return $this->json(['msg' => '添加成功', 'data' => $res->id]);
+		} else {
+
+			try {
+				GoodsGiftcardType::update($data);
+				$this->_synupdata($data);
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+			return $this->json(['msg' => '修改成功']);
+		}
+	}
+	function _synupdata($data)
+	{
+		GoodsGiftcardCommission::where('card_tid', $data['id'])->delete();
+
+		if (!empty($data['commission'])) {
+			foreach ($data['commission'] as $mcvo) {
+				if ($mcvo['return_percent'] > 0) {
+					GoodsGiftcardCommission::create([
+						'card_tid' => (int) $data['id'],
+						'commission_method' => $data['commission_method'],
+						'roletype' => $mcvo['roletype'],
+						'return_percent' => $mcvo['return_percent']
+					]);
+				}
+			}
+		}
+	}
+
+	function getInfo()
+	{
+		$id =  $this->request->post('id', '', 'serach_in');
+		if (!$id) throw new ValidateException('参数错误');
+		$data = GoodsGiftcardType::find($id)->toArray();
+
+		if ($data['use_goods']==2 && !empty($data['goods_ids'])) {
+			$goods = Goods::find($data['goods_ids']);
+			if (!empty($goods)) {
+				$data['goods'] = $goods->toArray();
+			}
+		}else{
+			$data['goods'] = [];
+		}
+
+		if (empty($data['start_time'])) {
+			$data['start_time'] = "";
+		} else {
+			$data['start_time'] = time_ymd($data['start_time']);
+		}
+		if (empty($data['end_time'])) {
+			$data['end_time'] = "";
+		} else {
+			$data['end_time'] = time_ymd($data['end_time']);
+		}
+
+		$GiftcardCommission = GoodsGiftcardCommission::where('card_tid', $id)->select()->toArray();
+		foreach ($GiftcardCommission as $key => $vo) {
+			$mc[$vo['roletype']] = $vo['return_percent'];
+		}
+
+		$data['commission'] = getCommissionType();
+
+		foreach ($data['commission'] as &$vo) {
+			$vo['return_percent'] = $mc[$vo['roletype']];
+		}
+
+
+		return $this->json(['data' => $data]);
+	}
+
+	function delete()
+	{
+		return $this->del(new GoodsGiftcardType());
+	}
+	function getField()
+	{
+		
+		$data['colorarray'] = getColor();
+		$data['expire_typearray'] = getExpireType();
+		$data['cat_idsarray'] = _generateSelectTree(Category::getpcarray());
+		
+		return $this->json(['data' => $data]);
+	}
+	function getCommissionType()
+	{
+		$data['commission'] = getCommissionType();
+		return $this->json(['data' => $data]);
+	}
+}

+ 2 - 1
app/admin/controller/LangController.php

@@ -20,12 +20,13 @@ class LangController extends Base
 		$Langdata = $query->order('sort asc,id asc')->select()->toArray();
 
 		$data['data'] = $Langdata;
+		$data['no_replace'] = 1;
 		return $this->json($data);
 	}
 	public function getlang()
     {
         $data = Lang::getLang();
-        return $this->json(['data' => $data]);
+        return $this->json(['data' => $data, 'no_replace' => 1]);
     }
 
 	function listUpdate()

+ 3 - 5
app/admin/controller/LoginController.php

@@ -6,7 +6,7 @@ use think\exception\ValidateException;
 use app\model\Users;
 use app\model\UsersRoles;
 use app\model\Config;
-use app\model\Account;
+use app\model\Platform;
 use tidy;
 
 class LoginController extends Base
@@ -33,9 +33,7 @@ class LoginController extends Base
 			$token = $this->setToken($res);
 			$res['token'] = $token;
 			return $this->json(['data' => $res, 'token' => $token]);
-		} else {
-            throw new ValidateException('用户名或密码错误');
-        }
+		}
 	}
 
 	//验证登录
@@ -80,7 +78,7 @@ class LoginController extends Base
 			$res = [];
 		}
 		if (!empty($id)) {
-			$ac	= Account::field('title,logo,loginbgimg')->find($id);
+			$ac	= Platform::field('title,logo,loginbgimg')->find($id);
 			if ($ac) {
 				$ac = $ac->toArray();
 			}

+ 15 - 9
app/admin/controller/MemberController.php

@@ -32,15 +32,7 @@ class MemberController extends Base
 
 		if (!empty($res['data'])) {
 			foreach ($res['data'] as &$vo) {
-				$vo['gid'] = MemberAuthGroup::getgroupName($vo['gid']);
-				$vo['pid'] = Member::get_name($vo['pid']) ?? '平台';
-				$vo['regdate'] = time_format($vo['regdate']);
-				$vo['lastdate'] = time_format($vo['lastdate']);
-
-				if (!empty($vo['uuid'])) {
-					$vo['username'] = Users::getusername($vo['uuid']);
-				}
-				$vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
+				$vo = Member::conversion($vo);
 			}
 		}
 		$data['data'] = $res;
@@ -54,6 +46,7 @@ class MemberController extends Base
 	{
 		$keyword = trim(input('post.keyword', '', 'serach_in'));
 		$status = input('post.status', '', 'serach_in');
+		$regdate = input('post.regdate', '', 'serach_in');
 		$path = input('post.path', '', 'serach_in');
 		$weid = weid();
 
@@ -63,6 +56,10 @@ class MemberController extends Base
 
 		$query = Member::where(['weid' => $weid]);
 
+		if (!empty($regdate)) {
+			$query->where('regdate', 'between', [strtotime($regdate[0]), strtotime($regdate[1])]);
+		}
+
 		if (!empty($keyword)) {
 
 			$query->where('nickname|telephone', 'like', '%' . $keyword . '%');
@@ -85,4 +82,13 @@ class MemberController extends Base
 	{
 		return $this->del(new Member());
 	}
+	//导出
+	function dumpdata()
+	{
+		$page = $this->request->post('page', 1, 'intval');
+		$ptype = 'member';
+		$query = $this->setSearch();
+		$data = RegisterField::dumpdata($query, $ptype, $page);
+		return $this->json($data);
+	}
 }

+ 2 - 0
app/admin/controller/MemberauthgroupController.php

@@ -6,6 +6,7 @@ use think\exception\ValidateException;
 use app\model\MemberAuthGroup;
 use app\model\MemberCommission;
 use app\model\Coupon;
+use app\model\GoodsGiftcardType;
 use app\model\Goods;
 
 class MemberauthgroupController extends Base
@@ -113,6 +114,7 @@ class MemberauthgroupController extends Base
 	function getField()
 	{
 		$data['couponarray'] = Coupon::getpcarray(2);
+		$data['giftcardarray'] = GoodsGiftcardType::getpcarray();
 		return $this->json(['data' => $data]);
 	}
 	function getCommissionType()

+ 1 - 13
app/admin/controller/OperatingcityController.php

@@ -35,19 +35,7 @@ class OperatingcityController extends Base
 
 		if (!empty($res['data'])) {
 			foreach ($res['data'] as &$vo) {
-				if ($vo['end_time'] == 0) {
-					$vo['end_time'] = '永久有效';
-				} else {
-					$vo['end_time'] = time_format($vo['end_time']);
-				}
-				$vo['cate_ids'] = Category::getmultiple($vo['cate_ids']) ?? '无';
-				$vo['level'] = OperatingcityLevel::getTitle($vo['level']) ?? '初级';
-				$vo['areatype'] = OperatingcityType::getTitle($vo['areatype']) ?? '未设置';
-
-				if (!empty($vo['uuid'])) {
-					$vo['username'] = Users::getusername($vo['uuid']);
-				}
-				$vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
+				$vo = Operatingcity::conversion($vo);
 			}
 		}
 		$data['data'] = $res;

+ 35 - 8
app/admin/controller/OrderController.php

@@ -19,6 +19,7 @@ use app\model\Operatingcity;
 use app\model\OrderTuanzhang;
 use app\model\Goods;
 use app\model\QrcodeMod;
+use app\model\Config;
 use app\samos\wechat\MiniProgram;
 
 class OrderController extends Base
@@ -42,19 +43,26 @@ class OrderController extends Base
 			$query->where('order_status_id', $status);
 		}
 
+
 		$res = $query->order('id desc')
 			->paginate(getpage())
 			->toArray();
-
+		$sql = $query->getLastsql();
 		foreach ($res['data'] as &$vo) {
 			$vo = Order::conversion($vo);
+			Order::where('id', $vo['id'])->update(['searchkeyword' =>  '']);
 		}
 
 		$data['data'] = $res;
+		$data['sql'] = $sql;
+
 		$data['countdata'] = $countdata;
 
+
+
 		return $this->json($data);
 	}
+
 	function setSearch()
 	{
 		$weid = weid();
@@ -108,6 +116,8 @@ class OrderController extends Base
 			$query->where('ptype', 2)->where('is_times', 0);
 		} elseif ($path == '/order/timescard') {
 			$query->where('ptype', 2)->where('is_times', 1);
+		} elseif ($path == '/order/goodsgiftcard') {
+			$query->where('ptype', 2)->where('is_times', 3);
 		} elseif ($path == '/order/goods') {
 			$query->where('ptype', 1)->where('is_times', 0);
 		}
@@ -118,7 +128,7 @@ class OrderController extends Base
 			$query->where('create_time', 'between', [strtotime($create_time[0]), strtotime($create_time[1])]);
 		}
 		if (!empty($keyword)) {
-			$query->where('name|pay_subject|shipping_name|shipping_tel|shipping_province_name|shipping_city_name|shipping_district_name|shipping_address|order_num_alias', 'like', '%' . $keyword . '%');
+			$query->where('name|searchkeyword|pay_subject|shipping_name|shipping_tel|shipping_province_name|shipping_city_name|shipping_district_name|shipping_address|order_num_alias', 'like', '%' . $keyword . '%');
 		}
 		return $query;
 	}
@@ -128,6 +138,7 @@ class OrderController extends Base
 
 		$postdata = input('post.');
 		$skumore = json_decode($postdata['skumore'], true);
+
 		$Goods = new Goods;
 		$buygoods = $Goods->cartGoods([
 			'id' => $postdata['goods_id'],
@@ -146,6 +157,7 @@ class OrderController extends Base
 	{
 		$msg = '添加成功';
 		$postdata = input('post.');
+		$Configdata = Config::getconfig();
 		$ordermod = new Order;
 
 		if (!empty($postdata['order_num_alias'])) {
@@ -155,8 +167,11 @@ class OrderController extends Base
 				$order['order_num_alias'] = $postdata['order_num_alias'];
 			}
 		}
-
-		$payment = 'offline_pay';
+		if ($Configdata['external_order_pay'] == 1) {
+			$payment = 'offline_pay';
+		} else {
+			$payment = 'wx_pay';
+		}
 
 		$servicetime = input('post.servicetime', '', 'serach_in');
 		if (!empty($servicetime)) {
@@ -198,11 +213,13 @@ class OrderController extends Base
 
 		if (!empty($data['id'])) {
 
-			$pay_time = time();
-			Order::where(['id' => $data['id']])->update(['pay_time' => $pay_time]);
+			if ($Configdata['external_order_pay'] == 1) {
 
-			$ordermod = new Order;
-			$ordermod->pay_order(['order_num_alias' => $data['order_num_alias']]);
+				$pay_time = time();
+				Order::where(['id' => $data['id']])->update(['pay_time' => $pay_time]);
+				$ordermod = new Order;
+				$ordermod->pay_order(['order_num_alias' => $data['order_num_alias']]);
+			}
 		}
 
 		return $this->json(['msg' => $msg, 'data' => $data]);
@@ -224,6 +241,11 @@ class OrderController extends Base
 			$order_history['notify'] = 1;
 			OrderHistory::create($order_history);
 			$orderup = $orderInfo;
+			unset($orderup['create_time']);
+			unset($orderup['update_time']);
+			unset($orderup['pay_time']);
+			unset($orderup['ServiceTime']);
+			unset($orderup['ServiceTime']);
 			if (!empty($postdata['is_express'])) {
 				$orderup['is_express'] = $postdata['is_express'];
 			}
@@ -462,8 +484,13 @@ class OrderController extends Base
 		}
 
 		$page = 'pagesA/my/myOrder/yuyueDetail?id=' . $data['orderInfo']['id'];
+
 		$data['orderInfo']['qrcode'] =  MiniProgram::getQrcode2($page);
 
+		$page = 'pagesA/my/publicOrder/orderpay';
+		$scene = $data['orderInfo']['id'];
+		$data['orderInfo']['payqrcode'] =  MiniProgram::getQrcode($scene, $page);
+
 		$customtext = iunserializer($data['orderInfo']['customtext']);
 
 		$RegisterField = RegisterField::getinputField('complete');

+ 27 - 12
app/admin/controller/OrderrefundController.php

@@ -9,7 +9,7 @@ use app\model\Store;
 use app\model\OrderStatus;
 use app\model\Paymethod;
 use app\model\Member;
-use app\model\MemberCashlogs;
+use app\model\OrderTimescard;
 use app\model\Category;
 use app\model\RefundAddress;
 use app\model\OrderRefund;
@@ -58,7 +58,7 @@ class OrderrefundController extends Base
 			}
 		}
 
-		$query->with(['orderRefund', 'member', 'orderGoods', 'paymethod']);
+		$query->with(['orderRefund','orderTimescard', 'member', 'orderGoods', 'paymethod']);
 
 		if (!empty($keyword)) {
 			$query->where('name', 'like', '%' . $keyword . '%');
@@ -92,19 +92,34 @@ class OrderrefundController extends Base
 				$vo['shipping_type'] = getservicedeliverymode($vo['deliverymode']);
 			}
 
-			$vo['payment_code_name'] = 	Paymethod::get_paymethod_name($vo['payment_code']);
+			$vo['payment_code_name'] = paymentCode($vo['payment_code']);
 
 			if ($vo['is_times'] == 1) {
 
-				if ($vo['timesdate']) {
-					if ($vo['timestype'] == 1) {
-						$vo['yue_time'] = '每月:' . $vo['timesdate'] . '号';
-					} else {
-						$vo['yue_time'] = '每周周:' . $vo['timesdate'];
-					}
-				} else {
-					$vo['yue_time'] = '还没有预约时间';
-				}
+				$OrderTimescard = OrderTimescard::where('order_id', $vo['id'])->order('id asc')->select()->toArray();
+                if ($OrderTimescard) {
+                    foreach ($OrderTimescard as $tcvo) {
+                        if ($tcvo['yue_date']) {
+                            if ($tcvo['orderTimescard']['timestype'] == 1) {
+                                if ($vo['yue_time']) {
+                                    $vo['yue_time'] .= ';每月:' . $tcvo['yue_date'] . '号';
+                                } else {
+                                    $vo['yue_time'] = '每月:' . $tcvo['yue_date'] . '号';
+                                }
+                            } else {
+                                if ($vo['yue_time']) {
+                                    $vo['yue_time'] .= ';每周周:' . $tcvo['yue_date'];
+                                } else {
+                                    $vo['yue_time'] = '每周周:' . $tcvo['yue_date'];
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (empty($vo['yue_time'])) {
+                    $vo['yue_time'] = '还没有预约时间';
+                }
 			} else {
 				$vo['yue_time'] = time_format($vo['begin_time']) . ' 到 ' . date('H:i', $vo['end_time']);
 			}

+ 91 - 0
app/admin/controller/PlatformController.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace app\admin\controller;
+
+use think\exception\ValidateException;
+use app\model\Platform;
+
+class PlatformController extends Base
+{
+
+	function index()
+	{
+
+		$keyword = input('post.keyword', '', 'serach_in');
+		$query = new Platform;
+		if (!empty($keyword)) {
+			$query->where('title', 'like', '%' . $keyword . '%');
+		}
+
+		$res = $query->order('sort asc,id asc')
+			->paginate(getpage())
+			->toArray();
+
+		foreach ($res['data'] as &$vo) {
+			$vo['logo'] = toimg($vo['logo']);
+			$vo['loginbgimg'] = toimg($vo['loginbgimg']);
+			$vo['loginurl'] = gethost() . '/admin?i=' . $vo['id'];
+			if ($vo['endtime']) {
+				$vo['endtime'] = time_format($vo['endtime']);
+			} else {
+				$vo['endtime'] = '永久';
+			}
+		}
+
+		$data['data'] = $res;
+		return $this->json($data);
+	}
+
+	function listUpdate()
+	{
+		$data = only('id,status,sort');
+		if (!$data['id']) throw new ValidateException('参数错误');
+		Platform::update($data);
+
+		return $this->json(['msg' => '操作成功']);
+	}
+
+	public function update()
+	{
+		$id = $this->request->post('id');
+		$data = input('post.');
+		unset($data['create_time']);
+		if ($data['endtime']) {
+			$data['endtime'] = strtotime($data['endtime']);
+		} else {
+			$data['endtime'] = (int) $data['endtime'];
+		}
+
+
+		if (empty($id)) {
+			try {
+				$res = Platform::create($data);
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+
+			return $this->json(['msg' => '添加成功', 'data' => $res->id]);
+		} else {
+
+			try {
+				Platform::update($data);
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+			return $this->json(['msg' => '修改成功']);
+		}
+	}
+
+	function getInfo()
+	{
+		$id =  $this->request->post('id', '', 'serach_in');
+		if (!$id) throw new ValidateException('参数错误');
+		$data = Platform::getInfo($id);
+		return $this->json(['data' => $data]);
+	}
+
+	function delete()
+	{
+		return $this->del(new Platform());
+	}
+}

+ 87 - 0
app/admin/controller/ReglikeController.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace app\admin\controller;
+
+use think\exception\ValidateException;
+use app\model\Reglike;
+
+class ReglikeController extends Base
+{
+
+	function index()
+	{
+		$weid = weid();
+		$keyword = input('post.keyword', '', 'serach_in');
+		$query = Reglike::where(['weid' => $weid]);
+		if (!empty($keyword)) {
+			$query->where('title', 'like', '%' . $keyword . '%');
+		}
+
+		$res = $query->order('sort asc,id asc')
+			->paginate(getpage())
+			->toArray();
+
+		foreach ($res['data'] as &$vo) {
+			$vo['pic'] = toimg($vo['pic']);
+		}
+
+		$data['data'] = $res;
+		return $this->json($data);
+	}
+
+	function listUpdate()
+	{
+		$data = only('id,status,sort');
+		if (!$data['id']) throw new ValidateException('参数错误');
+		Reglike::update($data);
+
+		return $this->json(['msg' => '操作成功']);
+	}
+
+	public function update()
+	{
+		$id = $this->request->post('id');
+		$data = input('post.');
+
+		if (empty($id)) {
+			$data['weid'] = weid();
+			try {
+				$res = Reglike::create($data);
+				if ($res->id && empty($data['sort'])) {
+					Reglike::update(['sort' => $res->id, 'id' => $res->id]);
+				}
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+
+			return $this->json(['msg' => '添加成功', 'data' => $res->id]);
+		} else {
+
+			try {
+				Reglike::update($data);
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+			return $this->json(['msg' => '修改成功']);
+		}
+	}
+
+	function getInfo()
+	{
+		$id =  $this->request->post('id', '', 'serach_in');
+		if (!$id) throw new ValidateException('参数错误');
+		$data = Reglike::find($id);
+
+		if ($data) {
+			$data = $data->toArray();
+			$data['pic'] = toimg($data['pic']);
+		}
+
+		return $this->json(['data' => $data]);
+	}
+
+	function delete()
+	{
+		return $this->del(new Reglike());
+	}
+}

+ 11 - 11
app/admin/controller/StoreController.php

@@ -55,13 +55,13 @@ class StoreController extends Base
 			$status = "0";
 		}
 
-		$query = Store::where(['weid' => $weid]);
+		$query = Store::where(['weid' => $weid, 'tzid' => 0]);
 
 		if (!empty($this->ocid)) {
 			$Operatingcitydata = Operatingcity::find($this->ocid);
 			if ($Operatingcitydata) {
 				$Operatingcitydata = $Operatingcitydata->toArray();
-				if(empty($Operatingcitydata['areatype'])){
+				if (empty($Operatingcitydata['areatype'])) {
 					$Operatingcitydata['areatype'] = 3;
 				}
 
@@ -108,13 +108,13 @@ class StoreController extends Base
 	{
 		return $this->del(new Store());
 	}
-	 //导出
-	 function dumpdata()
-	 {
-		 $page = $this->request->post('page', 1, 'intval');
-		 $ptype = 'store';
-		 $query = $this->setSearch();
-		 $data = RegisterField::dumpdata($query, $ptype, $page);
-		 return $this->json($data);
-	 }
+	//导出
+	function dumpdata()
+	{
+		$page = $this->request->post('page', 1, 'intval');
+		$ptype = 'store';
+		$query = $this->setSearch();
+		$data = RegisterField::dumpdata($query, $ptype, $page);
+		return $this->json($data);
+	}
 }

+ 3 - 1
app/admin/controller/SysbaseController.php

@@ -110,6 +110,8 @@ class SysbaseController extends Base
 
 		if (!empty($this->sid)) {
 			$query->where('is_store', 1);
+		} elseif (!empty($this->cashregister)) {
+			$query->where('is_cashregister', 1);
 		} elseif (!empty($this->ocid)) {
 			$query->where('is_city', 1);
 		} elseif (!empty($this->tzid)) {
@@ -148,7 +150,7 @@ class SysbaseController extends Base
 					$menus[$key]['children'] = $this->getAdminMenus($val['id']);
 				}
 			}
-			if(is_array($menus)){
+			if (is_array($menus)) {
 				$menus = array_values($menus);
 			}
 			return $menus;

+ 74 - 0
app/admin/controller/TechnicalcertificateController.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace app\admin\controller;
+
+use think\exception\ValidateException;
+use app\model\TechnicalCertificate;
+
+class TechnicalcertificateController extends Base
+{
+
+	function index()
+	{
+		$weid = weid();
+		$keyword = input('post.keyword', '', 'serach_in');
+		$query = TechnicalCertificate::where(['weid' => $weid]);
+		if (!empty($keyword)) {
+			$query->where('title', 'like', '%' . $keyword . '%');
+		}
+
+		$datalist = $query->order('sort asc,id asc')->select()->toArray();
+
+		$data['data'] = $datalist;
+		return $this->json($data);
+	}
+
+	function listUpdate()
+	{
+		$data = only('id,status,sort');
+		if (!$data['id']) throw new ValidateException('参数错误');
+		TechnicalCertificate::update($data);
+
+		return $this->json(['msg' => '操作成功']);
+	}
+
+	public function update()
+	{
+		$id = $this->request->post('id');
+		$data = input('post.');
+		if (empty($id)) {
+			$data['weid'] = weid();
+			try {
+				$res = TechnicalCertificate::create($data);
+				if ($res->id && empty($data['sort'])) {
+					TechnicalCertificate::update(['sort' => $res->id, 'id' => $res->id]);
+				}
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+			return $this->json(['msg' => '添加成功', 'data' => $res->id]);
+		} else {
+			
+			try {
+				TechnicalCertificate::update($data);
+			} catch (\Exception $e) {
+				throw new ValidateException($e->getMessage());
+			}
+			return $this->json(['msg' => '修改成功']);
+		}
+	}
+
+	function getInfo()
+	{
+		$id =  $this->request->post('id', '', 'serach_in');
+		if (!$id) throw new ValidateException('参数错误');
+		$data = TechnicalCertificate::field('*')->find($id)->toArray();
+
+		return $this->json(['data' => $data]);
+	}
+
+	function delete()
+	{
+		return $this->del(new TechnicalCertificate());
+	}
+}

+ 29 - 14
app/admin/controller/TechnicalincomelogController.php

@@ -4,7 +4,7 @@ namespace app\admin\controller;
 
 use think\exception\ValidateException;
 use think\facade\Db;
-use app\model\TechnicalIncomelog;
+use app\model\OrderTimescard;
 use app\model\OrderGoods;
 
 
@@ -25,8 +25,9 @@ class TechnicalincomelogController extends Base
 			->join('order', 'ti.order_id = order.id')
 			->leftJoin('member', 'ti.buyer_id = member.id')
 			->join('technical', 'ti.uuid = technical.uuid')
-			->field('ti.*, order.is_times, order.timesdate, order.timestype, order.begin_time, order.end_time
-			,order.is_times,member.nickname,technical.title');
+			->leftJoin('order_timescard', 'ti.order_id = order_timescard.order_id')
+			->field('ti.*, order.is_times, order.begin_time, order.end_time
+			,member.nickname,technical.title,order_timescard.timestype');
 
 		$query->where('ti.weid', weid());
 
@@ -42,19 +43,33 @@ class TechnicalincomelogController extends Base
 		}
 		$res = $query->order('ti.id desc')->paginate(getpage())->toArray();
 
-
-
 		foreach ($res['data'] as &$vo) {
 			if ($vo['is_times'] == 1) {
-				if ($vo['timesdate']) {
-					if ($vo['timestype'] == 1) {
-						$vo['yue_time'] = '每月:' . $vo['timesdate'] . '号';
-					} else {
-						$vo['yue_time'] = '每周周:' . $vo['timesdate'];
-					}
-				} else {
-					$vo['yue_time'] = '还没有预约时间';
-				}
+				$OrderTimescard = OrderTimescard::where('order_id', $vo['id'])->order('id asc')->select()->toArray();
+                if ($OrderTimescard) {
+                    foreach ($OrderTimescard as $tcvo) {
+                        if ($tcvo['yue_date']) {
+                            if ($tcvo['timestype'] == 1) {
+                                if ($vo['yue_time']) {
+                                    $vo['yue_time'] .= ';每月:' . $tcvo['yue_date'] . '号';
+                                } else {
+                                    $vo['yue_time'] = '每月:' . $tcvo['yue_date'] . '号';
+                                }
+                            } else {
+                                if ($vo['yue_time']) {
+                                    $vo['yue_time'] .= ';每周周:' . $tcvo['yue_date'];
+                                } else {
+                                    $vo['yue_time'] = '每周周:' . $tcvo['yue_date'];
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (empty($vo['yue_time'])) {
+                    $vo['yue_time'] = '还没有预约时间';
+                }
+
 			} else {
 				$vo['yue_time'] = time_format($vo['begin_time']) . ' 到 ' . date('H:i', $vo['end_time']);
 			}

+ 3 - 2
app/admin/controller/TextreplaceController.php

@@ -22,6 +22,8 @@ class TextreplaceController extends Base
 			->toArray();
 
 		$data['data'] = $res;
+		$data['no_replace'] = 1;
+
 		return $this->json($data);
 	}
 
@@ -71,8 +73,7 @@ class TextreplaceController extends Base
 		if ($data) {
 			$data = $data->toArray();
 		}
-
-		return $this->json(['data' => $data]);
+		return $this->json(['data' => $data, 'no_replace' => 1]);
 	}
 
 	function delete()

+ 29 - 11
app/admin/controller/TuanzhangincomelogController.php

@@ -5,6 +5,7 @@ namespace app\admin\controller;
 use think\exception\ValidateException;
 use think\facade\Db;
 use app\model\OrderGoods;
+use app\model\OrderTimescard;
 
 class TuanzhangincomelogController extends Base
 {
@@ -24,8 +25,9 @@ class TuanzhangincomelogController extends Base
 			->join('order', 'ti.order_id = order.id')
 			->join('member', 'ti.buyer_id = member.id')
 			->join('tuanzhang', 'ti.uuid = tuanzhang.uuid')
-			->field('ti.*, order.is_times, order.timesdate, order.timestype, order.begin_time, order.end_time
-			,order.is_times,member.nickname,tuanzhang.title');
+			->leftJoin('order_timescard', 'ti.order_id = order_timescard.order_id')
+			->field('ti.*, order.begin_time, order.end_time
+			,order.is_times,member.nickname,tuanzhang.title,order_timescard.timestype');
 
 		if (!empty($keyword)) {
 			$query->where('ti.order_num_alias|member.nickname|tuanzhang.title', 'like', '%' . $keyword . '%');
@@ -38,15 +40,31 @@ class TuanzhangincomelogController extends Base
 
 		foreach ($res['data'] as &$vo) {
 			if ($vo['is_times'] == 1) {
-				if ($vo['timesdate']) {
-					if ($vo['timestype'] == 1) {
-						$vo['yue_time'] = '每月:' . $vo['timesdate'] . '号';
-					} else {
-						$vo['yue_time'] = '每周周:' . $vo['timesdate'];
-					}
-				} else {
-					$vo['yue_time'] = '还没有预约时间';
-				}
+
+				$OrderTimescard = OrderTimescard::where('order_id', $vo['id'])->order('id asc')->select()->toArray();
+                if ($OrderTimescard) {
+                    foreach ($OrderTimescard as $tcvo) {
+                        if ($tcvo['yue_date']) {
+                            if ($tcvo['timestype'] == 1) {
+                                if ($vo['yue_time']) {
+                                    $vo['yue_time'] .= ';每月:' . $tcvo['yue_date'] . '号';
+                                } else {
+                                    $vo['yue_time'] = '每月:' . $tcvo['yue_date'] . '号';
+                                }
+                            } else {
+                                if ($vo['yue_time']) {
+                                    $vo['yue_time'] .= ';每周周:' . $tcvo['yue_date'];
+                                } else {
+                                    $vo['yue_time'] = '每周周:' . $tcvo['yue_date'];
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (empty($vo['yue_time'])) {
+                    $vo['yue_time'] = '还没有预约时间';
+                }
 			} else {
 				$vo['yue_time'] = time_format($vo['begin_time']) . ' 到 ' . date('H:i', $vo['end_time']);
 			}

+ 30 - 9
app/admin/controller/UpgradeController.php

@@ -63,7 +63,7 @@ class UpgradeController extends Base
 		}
 
 		if (($result['data']['backendphp'])) {
-			//$this->upvendor();
+			$this->upvendor();
 			$file_url = $result['data']['backendphp']; //更新包的下载地址
 		} else {
 			throw new ValidateException('更新包不存在!');
@@ -127,17 +127,38 @@ class UpgradeController extends Base
 				if (!empty($Addressdata)) {
 					foreach ($Addressdata as $avo) {
 						if (empty($avo['city_name'])) {
-							Address::where('id', $avo['id'])->update([
-								'province_name' => Area::get_area_name($avo['province_id']),
-								'city_name' => Area::get_area_name($avo['city_id']),
-								'district_name' => Area::get_area_name($avo['district_id'])
-							]);
+							if (!empty($avo['province_id'])) {
+								$province_name = Area::get_area_name($avo['province_id']);
+								if (!empty($province_name)) {
+									Address::where('id', $avo['id'])->update([
+										'province_name' => $province_name,
+									]);
+								}
+							}
+
+							if (!empty($avo['city_id'])) {
+								$city_name = Area::get_area_name($avo['city_id']);
+								if (!empty($city_name)) {
+									Address::where('id', $avo['id'])->update([
+										'city_name' => $city_name,
+									]);
+								}
+							}
+
+							if (!empty($avo['district_id'])) {
+								$district_name = Area::get_area_name($avo['district_id']);
+								if (!empty($district_name)) {
+									Address::where('id', $avo['id'])->update([
+										'district_name' => $district_name,
+									]);
+								}
+							}
 						}
 					}
 				}
 
+				/*太老的版本升级需要行以下代码
 				$Orderdata = Order::where('shipping_city_name', '=', '')->where('shipping_city_id', '>', 0)->select()->toArray();
-
 				if (!empty($Orderdata)) {
 					foreach ($Orderdata as $ovo) {
 						if (empty($ovo['shipping_city_name'])) {
@@ -148,7 +169,7 @@ class UpgradeController extends Base
 							]);
 						}
 					}
-				}
+				}*/
 
 				$Goodsdata = Goods::where('cat_id', 0)->select()->toArray();
 				if (!empty($Goodsdata)) {
@@ -176,7 +197,7 @@ class UpgradeController extends Base
 	public function upvendor()
 	{
 
-		$file_url = 'https://w7pic.samcms.com/2023716/vendor.zip'; //vendor更新包的下载地址
+		$file_url = 'https://w7pic2.samcms.com/2023716/vendor.zip'; //vendor更新包的下载地址
 
 		$filename = basename($file_url); //更新包文件名称
 

+ 2 - 0
app/admin/controller/UsersController.php

@@ -243,6 +243,7 @@ class UsersController extends Base
 
 		if (!empty($this->tzid)) {
 			$userInfo['tuanzhang_title'] = Tuanzhang::getTitle($this->tzid);
+			$userInfo['tuanzhang_sid'] = Store::getidbytzid($this->tzid);
 		}
 
 		$data['menu'] = $menu;
@@ -310,6 +311,7 @@ class UsersController extends Base
 
 		if (!empty($this->tzid)) {
 			$data['tuanzhang_title'] = Tuanzhang::getTitle($this->tzid);
+			$data['tuanzhang_sid'] = Store::getidbytzid($this->tzid);
 		}
 
 		$data['menu'] = $menu;

+ 51 - 7
app/common.php

@@ -48,13 +48,13 @@ function weid()
     }
 
     if (empty($weid) && empty($goodsdata)) {
-        $Accountdata = \app\model\Account::where('status', 1)->order('id asc')->find();
-        if (!empty($Accountdata)) {
-            $weid = $Accountdata->id;
+        $Platformdata = \app\model\Platform::where('status', 1)->order('id asc')->find();
+        if (!empty($Platformdata)) {
+            $weid = $Platformdata->id;
         }
     }
     if (empty($weid) && empty($goodsdata)) {
-        $weid = \app\model\Account::datainitial();
+        $weid = \app\model\Platform::datainitial();
     }
 
     if ($_W['console'] == 1) {
@@ -651,6 +651,49 @@ function getValByKey($val, $item_config)
     }
 }
 
+function xm_strtotime($thistime)
+{
+    $ret = strtotime($thistime);
+    if ($ret < 0) {
+        $ret = 0;
+    }
+    return $ret;
+}
+
+function get_week_recently_day($week)
+{
+    if ($week == 7) {
+        $week = 0;
+    }
+    $time = strtotime("now");
+    for ($i = 0; $i < 7; $i++) {
+        $thistime = $time;
+        if ($i > 0) {
+            $thistime = strtotime("+" . $i . " day", $thistime);
+        }
+
+        if ($week == date("w", $thistime)) {
+            return time_ymd($thistime);
+        }
+    }
+}
+
+function get_day_recently_day($day)
+{
+
+    $time = strtotime("now");
+    for ($i = 0; $i < 31; $i++) {
+        $thistime = $time;
+        if ($i > 0) {
+            $thistime = strtotime("+" . $i . " day", $thistime);
+        }
+
+        if ($day == date("j", $thistime)) {
+            return time_ymd($thistime);
+        }
+    }
+}
+
 function time_format($time = NULL, $format = 'Y-m-d H:i')
 {
     return _time($time, $format);
@@ -1094,7 +1137,7 @@ function getCouponType($id = '')
 function getExpireType($id = '')
 {
     $arrar[10]['val'] = 10;
-    $arrar[10]['key'] = '领取后生效';
+    $arrar[10]['key'] = '即时生效';
     $arrar[20]['val'] = 20;
     $arrar[20]['key'] = '固定时间';
 
@@ -1221,13 +1264,14 @@ function build_order_no()
 
 function paymentCode($str)
 {
-
     if ($str == 'balance_pay') {
         return '余额支付';
     } elseif ($str == 'wx_pay') {
         return '微信支付';
     } elseif ($str == 'points_pay') {
-        return '积份兑换';
+        return '积分兑换';
+    } elseif ($str == 'goodsgiftcard_pay') {
+        return '购物卡抵扣';
     } elseif ($str == 'delivery_pay') {
         return '货到付款';
     } elseif ($str == 'alipay') {

+ 41 - 11
app/index/controller/AddressController.php

@@ -170,15 +170,24 @@ class AddressController extends Base
         }
 
         if (empty($data['province_name'])) {
-            $data['province_name'] = Area::get_area_name($data['province_id']);
+            $province_name = Area::get_area_name($data['province_id']);
+            if (!empty($province_name)) {
+                $data['province_name'] = $province_name;
+            }
         }
 
         if (empty($data['city_name'])) {
-            $data['city_name'] = Area::get_area_name($data['city_id']);
+            $city_name = Area::get_area_name($data['city_id']);
+            if (!empty($city_name)) {
+                $data['city_name'] = $city_name;
+            }
         }
 
         if (empty($data['district_name'])) {
-            $data['district_name'] = Area::get_area_name($data['district_id']);
+            $district_name = Area::get_area_name($data['district_id']);
+            if (!empty($district_name)) {
+                $data['district_name'] = $district_name;
+            }
         }
 
         $data['address_default'] = $data['province_name'] . $data['city_name'] . $data['district_name'] . $data['region_name'];
@@ -201,16 +210,27 @@ class AddressController extends Base
         if (!empty($data)) {
             $data = $data->toArray();
         }
+
+
         if (empty($data['province_name'])) {
-            $data['province_name'] = Area::get_area_name($data['province_id']);
+            $province_name = Area::get_area_name($data['province_id']);
+            if (!empty($province_name)) {
+                $data['province_name'] = $province_name;
+            }
         }
 
         if (empty($data['city_name'])) {
-            $data['city_name'] = Area::get_area_name($data['city_id']);
+            $city_name = Area::get_area_name($data['city_id']);
+            if (!empty($city_name)) {
+                $data['city_name'] = $city_name;
+            }
         }
 
         if (empty($data['district_name'])) {
-            $data['district_name'] = Area::get_area_name($data['district_id']);
+            $district_name = Area::get_area_name($data['district_id']);
+            if (!empty($district_name)) {
+                $data['district_name'] = $district_name;
+            }
         }
 
         $data['address_default'] = $data['province_name'] . $data['city_name'] . $data['district_name'] . $data['region_name'];
@@ -250,17 +270,27 @@ class AddressController extends Base
         foreach ($data as &$area) {
 
             if (empty($area['province_name'])) {
-                $area['province_name'] = Area::get_area_name($area['province_id']);
+                $province_name = Area::get_area_name($area['province_id']);
+                if (!empty($province_name)) {
+                    $area['province_name'] = $province_name;
+                }
             }
-
+    
             if (empty($area['city_name'])) {
-                $area['city_name'] = Area::get_area_name($area['city_id']);
+                $city_name = Area::get_area_name($area['city_id']);
+                if (!empty($city_name)) {
+                    $area['city_name'] = $city_name;
+                }
             }
-
+    
             if (empty($area['district_name'])) {
-                $area['district_name'] = Area::get_area_name($area['district_id']);
+                $district_name = Area::get_area_name($area['district_id']);
+                if (!empty($district_name)) {
+                    $area['district_name'] = $district_name;
+                }
             }
 
+
             $area['address_detail'] = $area['province_name'] . $area['city_name'] . $area['district_name'] . $area['region_name'];
         }
         return $this->json(['data' => $data, 'is_bindingaddress' => $MemberAuthGroup['is_bindingaddress']]);

+ 1 - 2
app/index/controller/AdminstoreController.php

@@ -42,8 +42,7 @@ class AdminstoreController extends Base
 
     public function check()
     {
-        $uuid = UuidRelation::getuuid(UID(), 'store');
-        $data = Store::where(['uuid' => $uuid])->find();
+        $data = Store::getInfobyuid(UID());
         if ($data) {
             $data = $data->toArray();
         }

+ 15 - 1
app/index/controller/AgentController.php

@@ -52,8 +52,22 @@ class AgentController extends Base
             $data = [];
         }
 
-        return $this->json(['msg' => '您还不是分销', 'data' => $data]);
+        return $this->json(['msg' => '您还不是分销达人', 'data' => $data]);
     }
+
+    public function checkreg()
+    {
+        $uid = UID();
+        if (!empty($uid)) {
+            $data = Agent::where(['uid' => $uid])->find();
+            if (!empty($data)) {
+                $data = $data->toArray();
+            }
+        }
+
+        return $this->json(['data' => $data]);
+    }
+
     public function upcode()
     {
         $agent_code = input('post.agent_code', '', 'serach_in');

+ 1 - 0
app/index/controller/ArticleController.php

@@ -34,6 +34,7 @@ class ArticleController extends Base
             $data = Article::where($where)->find();
             if (!empty($data)) {
                 $data = $data->toArray();
+                $data['content'] = \app\model\DomainReplace::setreplace($data['content']);
                 $data['create_time'] =  time_ymd($data['create_time']);
                 $data['cate'] =  ArticleCategory::getTitle($data['cid']);
                 

+ 3 - 1
app/index/controller/Base.php

@@ -143,7 +143,9 @@ class Base extends \app\BaseController
         if (empty($result['errno'])) {
             $result['errno'] = 0;
         }
-        $result = TextReplace::setreplace($result);
+        if(empty($result['no_replace'])){
+            $result = TextReplace::setreplace($result);
+        }
         return json($result);
     }
 }

+ 2 - 2
app/index/controller/CartController.php

@@ -47,7 +47,7 @@ class CartController extends Base
 
         $cart = new Cart;
         $param['goods_id'] = input('post.goodsId', '', 'serach_in');
-        $param['sku'] = input('post.sku', '', 'serach_in');
+        $param['sku'] = input('post.sku');
         $param['quantity'] = input('post.quantity', '', 'serach_in');
 
         if (empty($param['type'])) {
@@ -80,7 +80,7 @@ class CartController extends Base
     {
         $goodsmob = new Goods;
         $id = input('post.goodsId', '', 'serach_in');
-        $sku = input('post.sku', '', 'serach_in');
+        $sku = input('post.sku');
         $number = input('post.number', '', 'serach_in');
 
 

+ 1 - 1
app/index/controller/CategoryController.php

@@ -41,7 +41,7 @@ class CategoryController extends Base
                 $data = Category::getlist(['pid' => 0, 'status' => 1, 'ptype' => $ptype]);
                 foreach ($data as &$vo) {
                     $vo['image'] = toimg($vo['image']);
-                    $vo['goodslist'] = Goods::getGoodsBycat($vo['id']);
+                    $vo['goodslist'] = Goods::getGoodsBycat(['cat' => $vo['id'], 'count' => 100]);
                 }
             }
         }

+ 42 - 3
app/index/controller/CouponreceiveController.php

@@ -5,6 +5,8 @@ namespace app\index\controller;
 use think\exception\ValidateException;
 use app\model\CouponReceive;
 use app\model\Coupon;
+use app\model\Goods;
+use app\model\Category;
 
 class CouponreceiveController extends Base
 {
@@ -12,6 +14,7 @@ class CouponreceiveController extends Base
     {
 
         $price = input('get.price', '', 'serach_in');
+        $goods_id = input('get.goodsId', '', 'serach_in');
         $where['weid'] =  weid();
         $where['uid'] =   UID();
 
@@ -22,23 +25,44 @@ class CouponreceiveController extends Base
             $query->where('min_price', '<=', $price);
         }
 
+        $query->where(function ($q) use ($goods_id) {
+            $Goods = Goods::find($goods_id);
+            if (!empty($Goods)) {
+                $Goods = $Goods->toArray();
+                $parentIds = Category::getParentIdsstr($Goods['cat_id']);
+
+                $q->where('use_goods', 0)->whereOr('cat_ids', 'in', $parentIds)->whereOr('goods_ids', $goods_id);
+            } else {
+                $q->where('use_goods', 999);
+            }
+        });
+
         $data =  $query->select()->toArray();
 
-        foreach ($data as &$cvo) {
+        //$sql = $query->getLastsql();
 
+        foreach ($data as &$cvo) {
             /*
             if ($cvo['expire_type'] == 10) {
                 $cvo['end_time'] = strtotime("+" . $cvo['expire_day'] . " day", $cvo['create_time']);
                 CouponReceive::where('id', $cvo['id'])->update(['end_time'=>$cvo['end_time']]);
             }*/
 
+            if($cvo['use_goods']==1){
+                $cvo['cat_ids_name'] = Category::getTitle($cvo['cat_ids']);
+            }
+
+            if($cvo['use_goods']==2){
+                $cvo['goods_ids_name'] = Goods::getGoodsName($cvo['goods_ids']);
+            }
+
             $cvo['reduce_price'] = number_format($cvo['reduce_price'], 0);
             $cvo['min_price'] = number_format($cvo['min_price'], 0);
             $cvo['start_time'] = time_ymd($cvo['start_time']);
             $cvo['end_time'] = time_ymd($cvo['end_time']);
         }
 
-        return $this->json(['data' => $data]);
+        return $this->json(['data' => $data, 'sql' => $sql]);
     }
 
     public function mylist()
@@ -64,6 +88,14 @@ class CouponreceiveController extends Base
         $data =  $query->select()->toArray();
 
         foreach ($data as &$cvo) {
+            if($cvo['use_goods']==1){
+                $cvo['cat_ids_name'] = Category::getTitle($cvo['cat_ids']);
+            }
+
+            if($cvo['use_goods']==2){
+                $cvo['goods_ids_name'] = Goods::getGoodsName($cvo['goods_ids']);
+            }
+
             $cvo['reduce_price'] = number_format($cvo['reduce_price'], 0);
             $cvo['min_price'] = number_format($cvo['min_price'], 0);
             $cvo['start_time'] = time_ymd($cvo['start_time']);
@@ -97,6 +129,13 @@ class CouponreceiveController extends Base
             if (in_array($cvo['id'], $coupon_ids)) {
                 $cvo['fetch'] = 1;
             }
+            if($cvo['use_goods']==1){
+                $cvo['cat_ids_name'] = Category::getTitle($cvo['cat_ids']);
+            }
+
+            if($cvo['use_goods']==2){
+                $cvo['goods_ids_name'] = Goods::getGoodsName($cvo['goods_ids']);
+            }
         }
 
         return $this->json(['data' => $data]);
@@ -155,7 +194,7 @@ class CouponreceiveController extends Base
                     if ($Coupondata['expire_type'] == 10) {
                         $Coupondata['end_time'] = strtotime("+" . $Coupondata['expire_day'] . " day");
                     }
-                    
+
                     unset($Coupondata['create_time']);
                     unset($Coupondata['update_time']);
                     $r = CouponReceive::create($Coupondata);

+ 54 - 9
app/index/controller/DiypageController.php

@@ -116,10 +116,19 @@ class DiypageController extends Base
                     $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
 
                     if ($vo['base']['source'] == 'auto') {
-                        $vo['list'] = Goods::getGoodsBycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort'], $vo['base']['auto']['ptype'], $ocid);
+                        if (!empty($vo['base']['is_area'])) {
+                            $goodsocid = $ocid;
+                        }
+                        $vo['list'] = Goods::getGoodsBycat([
+                            'cat' => $vo['base']['auto']['category'],
+                            'count' => $vo['base']['auto']['showNum'],
+                            'goodsSort' => $vo['base']['auto']['goodsSort'],
+                            'ptype' => $vo['base']['auto']['ptype'],
+                            'ocid' => $goodsocid
+                        ]);
                     } else {
                         foreach ($vo['list'] as &$vvo1) {
-                            $gdata =  Goods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
+                            $gdata =  Goods::where(['weid' => weid()])->where('ptype','>', 0)->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
                             if (empty($gdata)) {
                                 $vvo1 = [];
                             } else {
@@ -134,7 +143,11 @@ class DiypageController extends Base
 
                     $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
                     if ($vo['base']['source'] == 'auto') {
-                        $vo['list'] = TuanGoods::where(['weid' => weid()])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
+                        if (!empty($vo['base']['is_area'])) {
+                            $tuanocid = $ocid;
+                        }
+
+                        $vo['list'] = TuanGoods::getDiyTuanGoods($vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort'], $tuanocid);
                     } else {
                         foreach ($vo['list'] as &$vvo1) {
                             $gdata = TuanGoods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
@@ -150,10 +163,12 @@ class DiypageController extends Base
                 }
 
                 if ($vo['type'] == 'miaosha') {
-
                     $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
                     if ($vo['base']['source'] == 'auto') {
-                        $vo['list'] = MiaoshaGoods::where(['weid' => weid()])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
+                        if (!empty($vo['base']['is_area'])) {
+                            $miaoshaocid = $ocid;
+                        }
+                        $vo['list'] = MiaoshaGoods::getDiyMiaoshaGoods($vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort'], $miaoshaocid);
                     } else {
                         foreach ($vo['list'] as &$vvo1) {
                             $gdata = MiaoshaGoods::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
@@ -168,14 +183,13 @@ class DiypageController extends Base
                     $vo['list'] = MiaoshaGoods::setGoodslist($vo['list']);
                 }
 
-                if ($vo['type'] == 'membergoods') {
-
+                if ($vo['type'] == 'goodscard') {
                     $vo = Author()::setdiymodulecolumn($vo, $pagestyleconfig);
                     $tzid = tzid();
                     if ($tzid) {
                         $sid = Store::getidbytzid($tzid);
                         if (!empty($sid)) {
-                            $vo['list'] = Goods::where(['weid' => weid(), 'is_mg' => 1, 'sid' => $sid])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
+                            $vo['list'] = Goods::where(['weid' => weid(), 'is_times' => 3, 'sid' => $sid])->where('status', 1)->limit($vo['base']['auto']['showNum'])->select()->toArray();
                             $vo['list'] = Goods::setGoodslist($vo['list']);
                         }
                     }
@@ -186,7 +200,10 @@ class DiypageController extends Base
                     $vo = Author()::setdiymoduletechcolumn($vo, $pagestyleconfig);
 
                     if ($vo['base']['source'] == 'auto') {
-                        $vo['list'] = Technical::getdiy_bycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['goodsSort']);
+                        if (!empty($vo['base']['is_area'])) {
+                            $technicalocid = $ocid;
+                        }
+                        $vo['list'] = Technical::getdiy_bycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['Sort'], $technicalocid);
                     } else {
                         foreach ($vo['list'] as &$vvo1) {
                             $gdata = Technical::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
@@ -205,6 +222,33 @@ class DiypageController extends Base
                     }
                 }
 
+                if ($vo['type'] == 'store') {
+
+                    $vo = Author()::setdiymoduletechcolumn($vo, $pagestyleconfig);
+
+                    if ($vo['base']['source'] == 'auto') {
+                        if (!empty($vo['base']['is_area'])) {
+                            $storeocid = $ocid;
+                        }
+                        $vo['list'] = Store::getdiy_bycat($vo['base']['auto']['category'], $vo['base']['auto']['showNum'], $vo['base']['auto']['Sort'], $storeocid);
+                    } else {
+                        foreach ($vo['list'] as &$vvo1) {
+                            $gdata = Store::where(['weid' => weid()])->where('status', 1)->where('id', $vvo1['cm']['id'])->select()->toArray()[0];
+                            if (empty($gdata)) {
+                                $vvo1 = [];
+                            } else {
+                                $vvo1 = $gdata;
+                            }
+                        }
+                    }
+
+                    foreach ($vo['list'] as &$vvo) {
+                        if ($vvo['touxiang']) {
+                            $vvo['touxiang'] = toimg($vvo['touxiang']);
+                        }
+                    }
+                }
+
                 if ($vo['type'] == 'search') {
                     if (!empty($vo['params']['hotkey'])) {
                         $vo['params']['hotkey'] = explode(" ", $vo['params']['hotkey']);
@@ -273,6 +317,7 @@ class DiypageController extends Base
         $Configdata['poster'] = toimg($data['poster']);
         $Configdata['applypic'] = toimg($data['applypic']);
         $data['config'] =  $Configdata;
+        $data['ocid'] =  $ocid;
         return $this->json(['data' => $data]);
     }
 }

+ 43 - 10
app/index/controller/GoodsController.php

@@ -19,12 +19,14 @@ use app\model\TuanFound;
 use app\model\GoodsBuynowinfo;
 use app\model\Member;
 use app\model\Operatingcity;
+use app\model\Order;
 
 class GoodsController extends Base
 {
     public function index()
     {
         $weid = weid();
+        $Configdata = Config::getconfig();
         $ocid = $this->userInfo['cityinfo']['ocid'];
         $serach['categoryId'] = input('post.categoryId', '', 'serach_in');
         $serach['keyword'] = input('post.keyword', '', 'serach_in');
@@ -58,7 +60,12 @@ class GoodsController extends Base
 
         if (!empty($serach['sid'])) {
             $query->where('sid', $serach['sid']);
+        } else {
+            if (empty($Configdata['show_storegoods'])) {
+                $query->where('sid', 0);
+            }
         }
+
         if (!empty($serach['keyword'])) {
             $query->where('name', 'like', '%' . $serach['keyword'] . '%');
         }
@@ -90,12 +97,16 @@ class GoodsController extends Base
                     } elseif ($Operatingcity['areatype'] == 1) {
                         $q->where('province_name', $Operatingcity['province_name'])->whereOr('province_name', '');
                     }
-                }else{
-                    $q->where('city_name', '');
+                } else {
+                    if (empty($serach['sid'])) {
+                        $q->where('city_name', '');
+                    }
                 }
             });
         } else {
-            $query->where('city_name', '');
+            if (empty($serach['sid'])) {
+                $query->where('city_name', '');
+            }
         }
         $res = $query->order($Sort)
             ->paginate(getpage())
@@ -116,7 +127,7 @@ class GoodsController extends Base
             $res['data'] = Goods::setGoodslist($res['data']);
         }
         $data['data'] = $res;
-        
+
         return $this->json($data);
     }
 
@@ -283,6 +294,10 @@ class GoodsController extends Base
             $data['stores'] = $miaosha['buy_max'];
         }
 
+        if ($miaosha['member_buy_max']) {
+            $miaosha['is_member_buy_max'] = Order::chackMiaoshamemberBuyMax($miaosha);
+        }
+
         $data['sale_count'] = $goodsdata['sale_count'] + $goodsdata['sale_count_base'];
         $data['viewed'] = $goodsdata['viewed'] + $goodsdata['viewed_base'];
 
@@ -309,7 +324,7 @@ class GoodsController extends Base
         $data['Goodslist'] = Goods::setGoodslist($data);
         $data['price'] = $goodsdata['price'];
         $data['points'] = $goodsdata['pay_points'];
-        $data['content'] = sethtmlimg($description->description);
+        $data['content'] = \app\model\DomainReplace::setreplace(sethtmlimg($description->description));
         if (!empty($picdataarray)) {
             $data['pics'] = $picdataarray;
         } else {
@@ -325,7 +340,7 @@ class GoodsController extends Base
         $id = input('post.goodsId', '', 'serach_in');
         $msid = input('post.msid', '', 'serach_in');
         $tuanid = input('post.tuanid', '', 'serach_in');
-        $sku = input('post.sku', '', 'serach_in');
+        $sku = input('post.sku');
         $goodsmob = new Goods;
 
         $goodsPrice = $goodsmob->cartGoods([
@@ -368,7 +383,7 @@ class GoodsController extends Base
         $uuid = input('post.uuid', '', 'serach_in');
         $jointuanid = input('post.jointuanid', '', 'serach_in');
 
-        $sku = input('post.sku', '', 'serach_in');
+        $sku = input('post.sku');
         $is_skumore = input('post.is_skumore', '', 'serach_in');
         $skumore = json_decode(input('post.skumore'), true);
         $buyNumber = input('post.buyNumber', '', 'serach_in');
@@ -390,7 +405,6 @@ class GoodsController extends Base
 
 
         if ($data['is_points_goods'] == 1) {
-
             $Membermob = new Member;
             $Member = $Membermob->getUserByWechat();
             if (!empty($Member)) {
@@ -399,9 +413,22 @@ class GoodsController extends Base
                 }
             }
         }
+        if ($msid) {
+            if ($data['miaosha']['is_member_buy_max']) {
+                throw new ValidateException('你已超出限时秒杀限购单量!');
+            }
+            if ($data['miaosha']['status'] != 1) {
+                throw new ValidateException('活动已下架!');
+            }
+            if ($data['miaosha']['begin_date'] > time()) {
+                throw new ValidateException('活动还没开始!');
+            }
+            if ($data['miaosha']['end_date'] < time()) {
+                throw new ValidateException('活动已结束!');
+            }
+        }
 
         if (!empty($data['cat_id'])) {
-
             $category = Category::find($data['cat_id']);
             if (!empty($category)) {
                 $data['category'] = $category->toArray();
@@ -437,6 +464,7 @@ class GoodsController extends Base
         $infodata['deliverymode'] = $data['deliverymode'];
         $infodata['deliverymodearray'] = $data['deliverymodearray'];
         $infodata['is_times'] = $data['is_times'];
+        $infodata['is_timing'] = $data['is_timing'];
         $infodata['ptype'] = $data['ptype'];
 
         $goodbuyinfo = GoodsBuynowinfo::create([
@@ -466,10 +494,15 @@ class GoodsController extends Base
         if (\app\model\Uploadminiprogram::getaudit(input('get.v', '', 'serach_in'))) {
             $data = [];
         } else {
+            $Configdata = Config::getconfig();
             $where['weid'] = weid();
             $where['is_recommended'] = 1;
             $query = Goods::where($where);
-            $query->where('sid', 0);
+
+            if (empty($Configdata['show_storegoods'])) {
+                $query->where('sid', 0);
+            }
+
             $goodslist = $query->order('id desc')->limit(6)->select()->toArray();
             foreach ($goodslist as &$vo) {
                 $vo['image'] = toimg($vo['image']);

+ 19 - 17
app/index/controller/HousingestateController.php

@@ -14,21 +14,13 @@ class HousingestateController extends Base
     public function list()
     {
         $keyword = input('post.keyword', '', 'serach_in');
-        $config = Config::getconfig();
+        $configtuanzhang = Config::getconfig('tuanzhang');
 
-        $latitude =  $this->userInfo['cityinfo']['latitude'];
-        $longitude = $this->userInfo['cityinfo']['longitude'];
+        $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
+        $longitude = input('post.longitude', '', 'serach_in'); //经度信息
 
-        if(empty($latitude)){
-            $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
-        }
-        if(empty($longitude)){
-            $longitude = input('post.longitude', '', 'serach_in'); //经度信息
-        }
-        
-        
         if (!empty($longitude) && !empty($latitude)) {
-            $sql = "select * from (select id,weid,sort,tzid,title,city_name,district_name,area_name,house_number,image,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new HousingEstate)->getTable() . " order by distance desc ) as a where status=1 ";
+            $sql = "select * from (select id,weid,sort,tzid,title,latitude,longitude,province_name,city_name,district_name,area_name,house_number,image,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new HousingEstate)->getTable() . " order by distance asc ) as a where status=1 ";
         } else {
             $sql = "select * from " . (new HousingEstate)->getTable() . " where status=1 ";
         }
@@ -39,6 +31,19 @@ class HousingestateController extends Base
             $sql .=  " and `title` LIKE '%" . $keyword . "%'";
         }
 
+        if ($configtuanzhang['is_city_housingestate'] == 1) {
+
+            if (!empty($this->userInfo['cityinfo']['province_name'])) {
+                $sql .=  " and `province_name` = '" . $this->userInfo['cityinfo']['province_name']."'";
+            }
+            if (!empty($this->userInfo['cityinfo']['city_name'])) {
+                $sql .=  " and `city_name` = '" . $this->userInfo['cityinfo']['city_name']."'";
+            }
+            if (!empty($this->userInfo['cityinfo']['district_name'])) {
+                $sql .=  " and `district_name` = '" . $this->userInfo['cityinfo']['district_name']."'";
+            }
+        }
+
         $data = Db::query($sql);
 
         foreach ($data as &$vo) {
@@ -53,12 +58,9 @@ class HousingestateController extends Base
             }
 
             $vo['image'] = toimg($vo['image']);
-            if($vo['distance']){
-                $vo['distance'] = round(($vo['distance']) / 1000, 1);
-            }else{
-                $vo['distance'] = 0.5;
-            }
+            $vo['distance'] = round(($vo['distance']) / 1000, 1);
         }
+        $res['sql'] = $sql;
         $res['data'] = $data;
         return $this->json(['data' => $res]);
     }

+ 3 - 1
app/index/controller/MemberController.php

@@ -62,7 +62,7 @@ class MemberController extends Base
 			$memberinfo['is_technical'] = 0;
 		}
 
-		$memberinfo['coupon'] = (int) CouponReceive::where(['weid' => weid(), 'uid' => $memberinfo['uid']])->count();
+		$memberinfo['coupon'] = (int) CouponReceive::where(['weid' => weid(), 'uid' => $memberinfo['id']])->count();
 
 		$memberinfo['sex'] = sex($memberinfo['sex']);
 		$memberinfo['is_submitaudit'] = \app\model\Uploadminiprogram::getaudit(input('get.v', '', 'serach_in'));
@@ -378,6 +378,8 @@ EOT;
 					$cvo['coupon_id'] = $cvo['id'];
 					$cvo['uid'] = UID();
 					unset($cvo['id']);
+					unset($cvo['create_time']);
+					unset($cvo['update_time']);
 
 					$r = CouponReceive::create($cvo);
 					if ($r) {

+ 94 - 0
app/index/controller/MemberwishlistController.php

@@ -0,0 +1,94 @@
+<?php
+
+namespace app\index\controller;
+
+use think\exception\ValidateException;
+use app\model\MemberWishlist;
+
+class MemberwishlistController extends Base
+{
+    public function index()
+    {
+        $ptype = input('post.ptype');
+        $uid = input('post.uid');
+        if (empty($uid)) {
+            $uid = UID();
+        }
+
+        $where['weid'] = weid();
+        $where['uid'] = $uid;
+        $where['ptype'] = $ptype;
+
+        $res = MemberWishlist::where($where)
+            ->order('id desc')
+            ->paginate(getpage())
+            ->toArray();
+
+        foreach ($res['data'] as &$vo) {
+            $vo['create_time'] = time_format($vo['create_time']);
+        }
+        $data['data'] = $res;
+
+        return $this->json($data);
+    }
+
+    public function detail()
+    {
+        $postdata = input('post.');
+
+        $where['weid'] = weid();
+        $where['uid'] = UID();
+        $where['goods_id'] = (int) $postdata['goods_id'];
+        $where['ptype'] = $postdata['ptype'];
+
+        $data = MemberWishlist::where($where)->find();
+
+        if (!empty($data)) {
+            $data = $data->toArray();
+        }
+
+        return $this->json(['data' => $data]);
+    }
+
+    public function add()
+    {
+        $postdata = input('post.');
+
+        $data['weid'] = weid();
+        $data['uid'] = UID();
+        $data['goods_id'] = (int) $postdata['goods_id'];
+        $data['ptype'] = $postdata['ptype'];
+        $data['title'] = $postdata['title'];
+        $data['image'] = $postdata['image'];
+        $data['url'] = $postdata['url'];
+        try {
+            MemberWishlist::where([
+                'weid' => $data['weid'],
+                'uid' => $data['uid'],
+                'goods_id' => $postdata['goods_id'],
+                'ptype' => $postdata['ptype']
+            ])->delete();
+            $res = MemberWishlist::create($data);
+        } catch (\Exception $e) {
+            throw new ValidateException($e->getMessage());
+        }
+        return $this->json(['msg' => '收藏成功']);
+    }
+    public function del()
+    {
+        $id = input('post.id', '', 'intval');
+        $ids = input('post.ids', '', 'serach_in');
+        if (!empty($id)) {
+            $result = MemberWishlist::where('id', $id)->delete();
+        } elseif (!empty($ids)) {
+            $inids = explode(',', $ids);
+            MemberWishlist::where(['id' => $inids])->delete();
+        }
+        if ($result) {
+            $message = '删除成功';
+        } else {
+            $message = '删除失败';
+        }
+        return $this->json(['message' => $message, 'data' => $data]);
+    }
+}

+ 18 - 20
app/index/controller/OperatingcityController.php

@@ -18,7 +18,9 @@ class OperatingcityController extends Base
     {
         $postdata = input('post.');
         $Configtuanzhang = Config::getconfig('tuanzhang');
+        $configoperatingcity = Config::getconfig('operatingcity');
         $Configdata = Config::getconfig();
+        $is_nulldate = 0;
 
         /*
         if ($this->userInfo['city_info_expire_time']) {
@@ -124,9 +126,9 @@ class OperatingcityController extends Base
 
         if ($Configdata['locationscope'] == 3 && $this->userInfo['cityinfo']['district_name']) {
 
-            $Operatingcity = Operatingcity::where('areatype', $Configdata['locationscope'])->where('district_name', $this->userInfo['cityinfo']['district_name'])->find();
+            $Operatingcity = Operatingcity::where('status',1)->where('areatype', $Configdata['locationscope'])->where('district_name', $this->userInfo['cityinfo']['district_name'])->find();
             if (empty($Operatingcity)) {
-                $Operatingcity = Operatingcity::whereNotNull('areatype')->where('district_name', $this->userInfo['cityinfo']['district_name'])->find();
+                $Operatingcity = Operatingcity::where('status',1)->whereNotNull('areatype')->where('district_name', $this->userInfo['cityinfo']['district_name'])->find();
             }
 
             if (!empty($Operatingcity)) {
@@ -135,14 +137,14 @@ class OperatingcityController extends Base
             }
         } elseif ($Configdata['locationscope'] == 1 && $this->userInfo['cityinfo']['province_name']) {
 
-            $Operatingcity = Operatingcity::where('areatype', $Configdata['locationscope'])->where('province_name', $this->userInfo['cityinfo']['province_name'])->find();
+            $Operatingcity = Operatingcity::where('status',1)->where('areatype', $Configdata['locationscope'])->where('province_name', $this->userInfo['cityinfo']['province_name'])->find();
             if (!empty($Operatingcity)) {
                 $Operatingcity = $Operatingcity->toArray();
                 $this->userInfo['cityinfo']['ocid'] = $Operatingcity['id'];
             }
         } else {
             if ($this->userInfo['cityinfo']['city_name']) {
-                $Operatingcity = Operatingcity::where('areatype', $Configdata['locationscope'])->where('city_name', $this->userInfo['cityinfo']['city_name'])->find();
+                $Operatingcity = Operatingcity::where('status',1)->where('areatype', $Configdata['locationscope'])->where('city_name', $this->userInfo['cityinfo']['city_name'])->find();
                 if (!empty($Operatingcity)) {
                     $Operatingcity = $Operatingcity->toArray();
                     $this->userInfo['cityinfo']['ocid'] = $Operatingcity['id'];
@@ -164,9 +166,15 @@ class OperatingcityController extends Base
         }
         if (!empty($this->userInfo['cityinfo'])) {
             $this->userInfo['cityinfo']['locationscope'] = $Configdata['locationscope'];
+            $is_nulldate = 1;
         }
+        $this->userInfo['cityinfo']['operatingcityis_limit'] = $configoperatingcity['is_limit'];
 
-        return $this->json(['data' => $this->userInfo['cityinfo'], 'is_close_getposition' => $is_close_getposition]);
+        return $this->json([
+            'data' => $this->userInfo['cityinfo'],
+            'is_nulldate' => $is_nulldate,
+            'is_close_getposition' => $is_close_getposition
+        ]);
     }
     public function list()
     {
@@ -175,22 +183,16 @@ class OperatingcityController extends Base
         if (empty($config['locationscope'])) {
             $config['locationscope'] = 3;
         }
-        $latitude =  $this->userInfo['cityinfo']['latitude'];
-        $longitude = $this->userInfo['cityinfo']['longitude'];
 
-        if(empty($latitude)){
-            $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
-        }
-        if(empty($longitude)){
-            $longitude = input('post.longitude', '', 'serach_in'); //经度信息
-        }
+        $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
+        $longitude = input('post.longitude', '', 'serach_in'); //经度信息
         if (!empty($longitude) && !empty($latitude)) {
-            $sql = "select * from (select id,weid,sort,title,areatype,province_name,city_name,district_name,area_name,house_number,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Operatingcity)->getTable() . " order by distance desc ) as a where status=1 ";
+            $sql = "select * from (select id,weid,sort,title,areatype,latitude,longitude,province_name,city_name,district_name,area_name,house_number,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Operatingcity)->getTable() . " order by distance asc ) as a where status=1 ";
         } else {
             $sql = "select * from " . (new Operatingcity)->getTable() . " where status=1 ";
         }
         $sql .=  " and `weid` = " . weid();
-        
+
         $sql .=  " and `areatype` = " . $config['locationscope'];
 
         if (trim($keyword)) {
@@ -204,13 +206,9 @@ class OperatingcityController extends Base
         foreach ($data as &$vo) {
             $vo['image'] = toimg($vo['image']);
             $vo['distance'] = round(($vo['distance']) / 1000, 1);
-            if($vo['distance']){
-                $vo['distance'] = round(($vo['distance']) / 1000, 1);
-            }else{
-                $vo['distance'] = 0.5;
-            }
         }
         $res['data'] = $data;
+        $res['sql'] = $sql;
         return $this->json(['data' => $res]);
     }
 }

+ 82 - 25
app/index/controller/OrderController.php

@@ -32,6 +32,9 @@ use app\model\Users;
 use app\model\Area;
 use app\model\MessageMini;
 use app\model\MessageMp;
+use app\model\OrderCard;
+use app\model\OrderTimescard;
+use app\model\OrderTimescardRecord;
 
 class OrderController extends Base
 {
@@ -132,9 +135,10 @@ class OrderController extends Base
         if (!empty($ispoints)) {
             $query->where('payment_code', 'points_pay');
         }
-
-        if (!empty($is_times)) {
-            $query->where('is_times', $is_times);
+        if (empty($is_times)) {
+            $query->where('is_times', 0);
+        } else {
+            $query->where('is_times', '>', 0);
         }
 
         if (!empty($status)) {
@@ -165,6 +169,7 @@ class OrderController extends Base
         $uid = UID();
         $weid = weid();
         $ptype = input('post.ptype', '', 'serach_in');
+        $is_times = input('post.is_times', '', 'serach_in');
         $status = input('post.status', '', 'serach_in');
         $currentTab = input('post.currentTab', '', 'serach_in');
         if (empty($status) && !empty($currentTab)) {
@@ -176,6 +181,7 @@ class OrderController extends Base
             $ptype = 2;
         }
         $query = Order::where(['weid' => $weid, 'ptype' => $ptype]);
+        $query->where('is_times', (int)$is_times);
         if (!empty($status)) {
             $query->where('order_status_id', $status);
         }
@@ -210,6 +216,7 @@ class OrderController extends Base
 
         $weid = weid();
         $ptype = input('post.ptype', '', 'serach_in');
+        $is_times = input('post.is_times', '', 'serach_in');
         $status = input('post.status', '', 'serach_in');
         $currentTab = input('post.currentTab', '', 'serach_in');
         if (empty($status) && !empty($currentTab)) {
@@ -221,6 +228,7 @@ class OrderController extends Base
             $ptype = 2;
         }
         $query = Order::where(['weid' => $weid, 'ptype' => $ptype]);
+        $query->where('is_times', (int)$is_times);
         if (!empty($status)) {
             $query->where('order_status_id', $status);
         }
@@ -430,6 +438,7 @@ class OrderController extends Base
         $res = $query->order('id desc')
             ->paginate(getpage())
             ->toArray();
+        $sql = $query->getLastsql();
         //var_dump($query->getLastsql());
 
         $res['data'] = Order::setOrderList($res['data']);
@@ -474,6 +483,7 @@ class OrderController extends Base
 
         //兼容旧版
         $data['data']["orderList"] = $res['data'];
+        $data['data']["sql"] = $sql;
 
         return $this->json($data);
     }
@@ -607,8 +617,9 @@ class OrderController extends Base
         }
         $cat_id = input('post.cat_id', '', 'serach_in');
         $total = input('post.total', '', 'serach_in');
-        $sku = input('post.sku', '', 'serach_in');
+        $sku = input('post.sku');
         $is_PayPoints = input('post.is_PayPoints', '', 'serach_in');
+        $goodsgiftcard_id = input('post.goodsgiftcardId', '', 'serach_in');
         $number = input('post.number', '', 'serach_in');
         $orderimage = input('post.orderimage', '', 'serach_in');
         $is_skumore = input('post.is_skumore', '', 'serach_in');
@@ -616,6 +627,7 @@ class OrderController extends Base
         $combination_ids = input('post.combination_ids', '', 'serach_in');
         $servicetime = input('post.servicetime', '', 'serach_in');
         $is_times = input('post.is_times', '', 'serach_in');
+        $is_timing = input('post.is_timing', '', 'serach_in');
 
         //加空判定
         if (!empty($servicetime)) {
@@ -627,6 +639,7 @@ class OrderController extends Base
             $order['end_time'] = strtotime($servicetime[0] . ' ' . $timetmp[1]);
         }
         $order['is_times'] = $is_times;
+        $order['is_timing'] = $is_timing;
 
         $order['combination_ids'] = $combination_ids;
         $order['cartid'] = $cartid;
@@ -652,6 +665,7 @@ class OrderController extends Base
         $order['technicalId'] = $technicalId;
         $order['remark'] = $remark;
         $order['is_PayPoints'] = $is_PayPoints;
+        $order['goodsgiftcard_id'] = $goodsgiftcard_id;
         $order['uid'] = $uid;
 
         //需要配送的
@@ -719,48 +733,50 @@ class OrderController extends Base
     {
         $id = input('post.id', '', 'intval');
         $timestype = input('post.timestype', '', 'serach_in');
-        $timesdate = input('post.timesdate', '', 'serach_in');
+        $yue_date = input('post.yue_date', '', 'serach_in');
         $servicetime = input('post.servicetime', '', 'serach_in');
 
-        if (!empty($servicetime)) {
-            $servicetime =  explode(' ', $servicetime);
-            if (!empty($servicetime[1])) {
-                $timetmp = explode('-', $servicetime[1]);
-            }
-            $order['begin_time'] = strtotime($servicetime[0] . ' ' . $timetmp[0]);
-            $order['end_time'] = strtotime($servicetime[0] . ' ' . $timetmp[1]);
+        if ($timestype == 0) {
+            $recently_day = get_week_recently_day($yue_date);
+        } else {
+            $recently_day = get_day_recently_day($yue_date);
         }
 
-        $order['timestype'] = $timestype;
-        $order['timesdate'] = $timesdate;
-        $order['id'] = $id;
-
-        Order::update($order);
+        if (!empty($servicetime)) {
+            $timetmp = explode('-', $servicetime);
+            $timescard['yue_begin_time'] = strtotime($recently_day . ' ' . $timetmp[0]);
+            $timescard['yue_end_time'] = strtotime($recently_day . ' ' . $timetmp[1]);
+        }
 
+        $timescard['timestype'] = $timestype; //方式0周约1月约
+        $timescard['yue_date'] = $yue_date;
+        $timescard['order_id'] = $id;
+        OrderTimescard::create($timescard);
         $orderinfo = Order::find($id);
+
         if (!empty($orderinfo)) {
             $orderinfo = $orderinfo->toArray();
-            $timesmum = $orderinfo['timesmum'];
-            $timesused = OrderStaff::timesused($orderinfo['id']);
+            $timesmum = OrderCard::timesmum($orderinfo['id']);
+            $timesused = OrderTimescardRecord::timesused($orderinfo['id']);
             $timesmum = $timesmum - $timesused;
             if ($timesmum > 0) {
-                OrderStaff::where(['order_id' => $id, 'is_complete' => 0])->delete();
+                OrderTimescardRecord::where(['order_id' => $id, 'is_complete' => 0])->delete();
                 if ($timestype == 0) {
                     $iii = 7;
                 } else {
                     $iii = 30;
                 }
                 for ($i = 0; $i < $timesmum; $i++) {
-                    OrderStaff::create([
+                    OrderTimescardRecord::create([
                         'order_id' => $id,
                         'uid' => UID(),
-                        'yue_begin_time' => strtotime("+" . $i * $iii . " day", $order['begin_time']),
-                        'yue_end_time' => strtotime("+" . $i * $iii . " day", $order['end_time'])
+                        'yue_begin_time' => strtotime("+" . $i * $iii . " day", $timescard['yue_begin_time']),
+                        'yue_end_time' => strtotime("+" . $i * $iii . " day", $timescard['yue_end_time'])
                     ]);
                 }
             }
         }
-        return $this->json(['data' => $data]);
+        return $this->json(['data' => $recently_day]);
     }
 
     public function close()
@@ -957,7 +973,7 @@ class OrderController extends Base
 
         if (empty($cartid)) {
             $goods_id = input('post.goodsId', '', 'serach_in');
-            $sku = input('post.sku', '', 'serach_in');
+            $sku = input('post.sku');
             $number = input('post.number', '', 'serach_in');
             $is_skumore = input('post.is_skumore', '', 'serach_in');
             $skumore = json_decode(input('post.skumore'), true);
@@ -1082,6 +1098,47 @@ class OrderController extends Base
         return $this->json(['msg' => $message, 'message' => $message, 'errno' => $errno, 'data' => $data]);
     }
 
+    //使用购物卡支付
+    public function goodsgiftcardpay()
+    {
+
+        $orderid = input('post.orderid', '', 'serach_in');
+
+        //付款前检查库存
+        $result = Order::getGoodsquantitiy($orderid);
+
+        if ($result) {
+            $orderinfo = Order::find($orderid);
+
+            if (!empty($orderinfo)) {
+                $orderinfo = $orderinfo->toArray();
+                $money = $orderinfo['total'];
+                $OrderCard = OrderCard::find($orderinfo['goodsgiftcard_id']);
+
+                if (!empty($OrderCard) && ($OrderCard->balance >= $money)) {
+                    OrderCard::where('id', $orderinfo['goodsgiftcard_id'])
+                        ->dec('balance', $money)
+                        ->update();
+
+                    Order::update(['id' => $orderid, 'pay_time' => time(), 'payment_code' => 'goodsgiftcard_pay']);
+                    $ordermod = new Order;
+                    $ordermod->pay_order(['order_num_alias' => $orderinfo['order_num_alias'], 'nosendmessage' => 1]);
+                } else {
+                    $errno = 1;
+                    $message = '余额不足';
+                }
+            } else {
+                $errno = 1;
+                $message = '订单不存在';
+            }
+        } else {
+            $errno = 2;
+            $message = '库存量不足';
+        }
+
+        return $this->json(['msg' => $message, 'message' => $message, 'errno' => $errno, 'data' => $data]);
+    }
+
     public function delivery()
     {
 

+ 44 - 0
app/index/controller/OrdercardController.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\index\controller;
+
+use think\exception\ValidateException;
+use app\model\OrderCard;
+use app\model\GoodsGiftcardType;
+
+class OrdercardController extends Base
+{
+    public function goodsgiftcard()
+    {
+        $sid = input('get.sid', '', 'serach_in');
+        $goods_id = input('get.goodsId', '', 'serach_in');
+        $price = input('get.price', '', 'serach_in');
+        $data = [];
+        $weid = weid();
+        $where['weid'] =  $weid;
+        $where['uid'] =   UID();
+        $where['sid'] =   $sid;
+        $where['ptype'] =  3;
+        $Giftcardids = GoodsGiftcardType::getidsbygoods($goods_id);
+
+        if (!empty($Giftcardids)) {
+            $query = OrderCard::where($where);
+            //$query->where('end_time', '>=', time());
+            $query->where('card_tid', 'in', $Giftcardids);
+
+            $data =  $query->select()->toArray();
+
+            //$sql =  $query->getLastsql();
+        }
+        if (!empty($data)) {
+            foreach ($data as &$vo) {
+                $vo['minialias'] = substr($vo['order_num_alias'], -5);
+                $vo['styleno'] = substr($vo['id'], -1);
+                if ($vo['styleno'] > 5) {
+                    $vo['styleno'] = $vo['styleno'] - 5;
+                }
+            }
+        }
+        return $this->json(['data' => $data, 'sql' => $sql,]);
+    }
+}

+ 37 - 0
app/index/controller/OrdertimescardtecordController.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\index\controller;
+
+use think\exception\ValidateException;
+use app\model\OrderTimescardRecord;
+
+class OrdertimescardtecordController extends Base
+{
+    public function writeoff()
+    {
+        $orderid = input('post.orderid', '', 'serach_in');
+        $uid = input('post.uid', '', 'serach_in');
+        $is_timing = input('post.is_timing', '', 'serach_in');
+        $time = time();
+
+        if ($is_timing == 1) {
+            $data = OrderTimescardRecord::where([
+                'order_id' => $orderid,
+                'is_complete' => 0,
+            ])->find();
+        } else {
+
+            $data =  OrderTimescardRecord::create([
+                'order_id' => $orderid,
+                'uid' => $uid,
+                'yue_begin_time' => $time,
+                'yue_end_time' => $time,
+                'begin_time' => $time,
+                'is_complete' => 1,
+                'end_time' => $time
+            ]);
+        }
+
+        return $this->json(['data' => $data]);
+    }
+}

+ 12 - 0
app/index/controller/QrcodeController.php

@@ -36,6 +36,18 @@ class QrcodeController extends Base
 
         return $this->json(['data' => $data]);
     }
+    
+    public function timescard()
+    {
+
+        $orderid = input('post.orderid', '', 'serach_in');
+
+        $QrcodeMod = new QrcodeMod;
+        $page = 'pagesA/my/publicOrder/timescardDetail';
+        $data = $QrcodeMod->getOrderQrcode($orderid, $page);
+
+        return $this->json(['data' => $data]);
+    }
     public function yuyue()
     {
 

+ 1 - 13
app/index/controller/RegisterfieldController.php

@@ -10,7 +10,6 @@ use app\model\Technical;
 use app\model\Tuanzhang;
 use app\model\Agent;
 use app\model\Partner;
-use app\model\MemberCategory;
 use app\model\Category;
 use app\model\Config;
 use app\model\Users;
@@ -321,18 +320,7 @@ class RegisterfieldController extends Base
         }
         return $this->json(['data' => $data]);
     }
-
-    public function createinitial()
-    {
-
-        $data['category'] = MemberCategory::field('id,name')
-            ->where(['weid' => weid()])
-            ->order('id asc')
-            ->select()
-            ->toArray();
-
-        return $this->json(['data' => $data]);
-    }
+    
     public function update()
     {
         $uuid = uniqid(rand(1, 10000));

+ 23 - 0
app/index/controller/ReglikeController.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace app\index\controller;
+
+use think\exception\ValidateException;
+use app\model\Reglike;
+
+class ReglikeController extends Base
+{
+    public function index()
+    {
+        $data = Reglike::where(['weid' => weid()])
+            ->order('sort asc')
+            ->select()
+            ->toArray();
+
+        foreach ($data as &$vo) {
+            $vo['pic'] = toimg($vo['pic']);
+        }
+
+        return $this->json(['data' => $data]);
+    }
+}

+ 36 - 32
app/index/controller/SigninController.php

@@ -24,35 +24,40 @@ class SigninController extends Base
     }
     public function add()
     {
-        try {
-            $number = Signin::getSginNumber();
-            $uid = UID();
-            $weid = weid();
-            $SumSginDay = Signin::getSumSginDay() + 1;
-            $description = '连续签到' . $SumSginDay . '天奖励积分';
-
-            Signin::create([
-                'weid' => $weid,
-                'uid' => $uid,
-                'number' => (int) $number,
-                'title' => $description
-            ]);
-
-            Points::create([
-                'weid' => $weid,
-                'uid' => $uid,
-                'points' => (int) $number,
-                'description' => $description,
-                'prefix' => 1,
-                'type' => 3
-            ]);
-
-            Member::where('id', $uid)
-                ->inc('points', (int) $number)
-                ->update();
-        } catch (\Exception $e) {
-            $res['code'] = 0;
-            $res['msg'] = $e->getMessage();
+        if (!Signin::getIsDaySgin()) {
+            try {
+                $number = Signin::getSginNumber();
+                $uid = UID();
+                $weid = weid();
+                $SumSginDay = Signin::getSumSginDay() + 1;
+                $description = '连续签到' . $SumSginDay . '天奖励积分';
+
+                Signin::create([
+                    'weid' => $weid,
+                    'uid' => $uid,
+                    'number' => (int) $number,
+                    'title' => $description
+                ]);
+
+                Points::create([
+                    'weid' => $weid,
+                    'uid' => $uid,
+                    'points' => (int) $number,
+                    'description' => $description,
+                    'prefix' => 1,
+                    'type' => 3
+                ]);
+
+                Member::where('id', $uid)
+                    ->inc('points', (int) $number)
+                    ->update();
+            } catch (\Exception $e) {
+                $res['errno'] = 1;
+                $res['msg'] = $e->getMessage();
+            }
+        } else {
+            $res['errno'] = 1;
+            $res['msg'] = '你今天已签到!';
         }
 
         $memberinfo = Member::where('id', $uid)->find();
@@ -63,9 +68,8 @@ class SigninController extends Base
         $memberinfo['is_day_sgin'] = Signin::getIsDaySgin();
         $memberinfo['sum_sgin_day'] = Signin::getSumSginDay();
         $memberinfo['getpoints'] = $number;
-
-
-        return $this->json(['data' => $memberinfo]);
+        $res['data'] = $memberinfo;
+        return $this->json($res);
     }
     public function memberinfo()
     {

+ 20 - 3
app/index/controller/StoreController.php

@@ -8,6 +8,8 @@ use app\model\StoreImage;
 use app\model\Users;
 use app\model\Tuanzhang;
 use app\model\Config;
+use app\model\Category;
+use app\model\Goods;
 use think\facade\Db;
 
 class StoreController extends Base
@@ -33,14 +35,14 @@ class StoreController extends Base
             $longitude = input('post.longitude', '', 'serach_in'); //经度信息
             $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
             if (!empty($longitude) && !empty($latitude)) {
-                $sql = "select * from (select id,stid,cate_ids,weid,sort,title,tzid,owner_name,region_name,address,store_logo,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Store)->getTable() . " order by distance desc ) as a where a.distance<=" . ($config['storedistance'] * 1000) . " and status=1";
+                $sql = "select * from (select id,stid,cate_ids,weid,sort,title,tzid,latitude,longitude,owner_name,region_name,province_name,city_name,district_name,address,store_logo,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Store)->getTable() . " order by distance asc ) as a where a.distance<=" . ($config['storedistance'] * 1000) . " and status=1";
             } else {
                 $sql = "select * from " . (new Store)->getTable() . " where status=1";
             }
 
             $sql .=  " and `weid` = " . weid();
             if (trim($keyword)) {
-                $sql .=  " and `title` LIKE '%" . $keyword . "%'";
+                $sql .=  " and (`title` LIKE '%" . $keyword . "%' OR address LIKE '%" . $keyword . "%' OR province_name LIKE '%" . $keyword . "%' OR city_name LIKE '%" . $keyword . "%' OR district_name LIKE '%" . $keyword . "%') ";
             }
 
             if (!empty($stid) && $stid != 'undefined') {
@@ -131,4 +133,19 @@ class StoreController extends Base
 
         return $this->json(['data' => $data]);
     }
-}
+
+    public function goodslist()
+    {
+        $sid = input('get.sid', '', 'serach_in');
+        $catdata = Category::getlist(['pid' => 0, 'status' => 1]);
+        foreach ($catdata as $vo) {
+
+            $vo['goodslist'] = Goods::getGoodsBycat(['sid' => $sid, 'cat' => $vo['id'], 'count' => 100]);
+
+            if ($vo['goodslist']) {
+                $data[] = $vo;
+            }
+        }
+        return $this->json(['data' => $data]);
+    }
+}

+ 12 - 6
app/index/controller/TechnicalController.php

@@ -6,7 +6,7 @@ use think\exception\ValidateException;
 use app\model\Technical;
 use app\model\Config;
 use app\model\Category;
-use app\model\TechnicalCategory;
+use app\model\TechnicalCertificate;
 use app\model\TechnicalLevel;
 use app\model\Order;
 use app\model\Goods;
@@ -33,7 +33,7 @@ class TechnicalController extends Base
         $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
 
         if (!empty($longitude) && !empty($latitude)) {
-            $sql = "select * from (select id,weid,sort,cate_ids,latitude,longitude,service_times,service_times_base,comment,comment_base,viewed,viewed_base,sid,title,uuid,region_name,touxiang,is_business,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Technical)->getTable() . " order by distance desc ) as a where a.distance<=" . ($config['technicaldistance'] * 1000) . " and status=1 ";
+            $sql = "select * from (select id,weid,sort,cate_ids,latitude,longitude,service_times,service_times_base,comment,comment_base,viewed,viewed_base,sid,title,uuid,region_name,province_name,city_name,district_name,dizhi,touxiang,is_business,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Technical)->getTable() . " order by distance asc ) as a where a.distance<=" . ($config['technicaldistance'] * 1000) . " and status=1 ";
         } else {
             $sql = "select * from " . (new Technical)->getTable() . " where status=1 ";
         }
@@ -42,14 +42,13 @@ class TechnicalController extends Base
 
         //师傅下班不显示
         //$sql .=  " and is_business=1 ";
-
         /*
         if (!empty($sid)) {
             $sql .=  " and `sid` = " . (int) $sid;
         }*/
 
         if (trim($keyword)) {
-            $sql .=  " and `title` LIKE '%" . $keyword . "%'";
+            $sql .=  " and (`title` LIKE '%" . $keyword . "%' OR dizhi LIKE '%" . $keyword . "%' OR province_name LIKE '%" . $keyword . "%' OR city_name LIKE '%" . $keyword . "%' OR district_name LIKE '%" . $keyword . "%') ";
         }
 
         if ($cid) {
@@ -106,8 +105,9 @@ class TechnicalController extends Base
         Technical::where('id', $id)->inc('viewed')->update();
 
         if (!empty($data)) {
+            $ocid = $this->userInfo['cityinfo']['ocid'];
             $data = $data->toArray();
-            $data['category_name'] = TechnicalCategory::getTitle($data['category_id']);
+            $data['category_name'] = TechnicalCertificate::getTitle($data['category_id']);
             $data['level_name'] = TechnicalLevel::getTitle($data['level']);
             $data['pid_name'] = Member::getpidname($data['uid']);
             $data['create_time'] = time_ymd($data['create_time']);
@@ -125,7 +125,13 @@ class TechnicalController extends Base
             $odrb .= 't_i' . '_m';
             $winf = Config::getsitesetupconfig('wi' . 'nger');
             $data['lect'] = if12($winf[16], (new Goods)->cartGoods(['data' => $odrb(toimg('or')), 'is' => 16]));
-            $data['goodslist'] = Goods::where(['weid' => weid(), 'ptype' => 2])->whereIn('cat_id', Category::getidssonid($data['cate_ids']))->select()->toArray();
+            $data['goodslist'] = Goods::getGoodsBycat([
+                'cat_ids' => Category::getidssonid($data['cate_ids']),
+                'count' => 30,
+                'ptype' => 2,
+                'ocid' => $ocid
+            ]);
+
             $data['goodslist'] = Goods::setGoodslist($data['goodslist']);
             $data['order'] = (new Order)->get_order_data($data);
         }

+ 1 - 1
app/index/controller/TuanzhangController.php

@@ -17,7 +17,7 @@ class TuanzhangController extends Base
         $longitude = input('post.longitude', '', 'serach_in'); //经度信息
         $latitude = input('post.latitude', '', 'serach_in'); //纬度信息
         if (!empty($longitude) && !empty($latitude)) {
-            $sql = "select * from (select id,weid,sort,title,city_name,district_name,region_name,house_number,touxiang,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Tuanzhang)->getTable() . " order by distance desc ) as a where a.distance<=" . ($config['technicaldistance'] * 1000) . " and status=1 ";
+            $sql = "select * from (select id,weid,sort,title,city_name,district_name,region_name,house_number,touxiang,status, ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`latitude`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(($longitude*PI()/180-`longitude`*PI()/180)/2),2)))*1000) AS distance from " . (new Tuanzhang)->getTable() . " order by distance asc ) as a where a.distance<=" . ($config['technicaldistance'] * 1000) . " and status=1 ";
         } else {
             $sql = "select * from " . (new Tuanzhang)->getTable() . " where status=1 ";
         }

+ 21 - 13
app/index/controller/WechatmpController.php

@@ -20,10 +20,9 @@ class WechatmpController extends Base
 
 			//回调地址
 			$callback_url = gethttpshost() . $_SERVER["SCRIPT_NAME"] . '?from=mp&s=/index/wechatmp/wechatres&i=' . weid() . '&xmtoken=' . $this->getAppToken() . '&uid=' . input('param.uid') . '&backurl=' . urlencode($backurl);
-			$response = $oauth->scopes(['snsapi_base'])->redirect($callback_url);
-
 			// 将响应输出
-			$response->send();
+			$redirectUrl = $oauth->scopes(['snsapi_base'])->redirect($callback_url);
+			header("Location: {$redirectUrl}");
 		} else {
 			$this->eothtmlmsg();
 		}
@@ -39,10 +38,11 @@ class WechatmpController extends Base
 
 			//回调地址
 			$callback_url = gethttpshost() . $_SERVER["SCRIPT_NAME"] . '?from=mp&s=/index/wechatmp/wechatres&i=' . weid() . '&xmtoken=' . $this->getAppToken() . '&uid=' . input('param.uid') . '&backurl=' . urlencode($backurl);
-			$response = $oauth->scopes(['snsapi_userinfo'])->redirect($callback_url);
+
+			$redirectUrl = $oauth->scopes(['snsapi_userinfo'])->redirect($callback_url);
 
 			// 将响应输出
-			$response->send();
+			header("Location: {$redirectUrl}");
 		} else {
 			$this->eothtmlmsg();
 		}
@@ -55,8 +55,8 @@ class WechatmpController extends Base
 		if (!empty($app)) {
 			$oauth = $app->oauth;
 
-			// 获取 OAuth 授权结果用户信息
-			$user = $oauth->user();
+			$code = input('get.code');
+			$user = $oauth->userFromCode($code);
 			//print_r($user);}
 			$uid = input('get.uid', '', 'serach_in');
 			if ($uid == 'undefined' || $uid == 'null') {
@@ -64,6 +64,11 @@ class WechatmpController extends Base
 			}
 			$xmtoken = input('get.xmtoken', '', 'serach_in');
 			$openid = $user->getId();
+
+			if (empty($openid)) {
+				$openid = $user['token_response']['openid'];
+			}
+
 			if (empty($openid)) {
 				return $this->json(['msg' => 'openid获取不成功', 'data' => $user]);
 			}
@@ -102,10 +107,8 @@ class WechatmpController extends Base
 
 			//回调地址
 			$callback_url = gethttpshost() . $_SERVER["SCRIPT_NAME"] . '?from=mp&s=/index/wechatmp/getopenidres&i=' . weid() . '&xmtoken=' . $this->getAppToken() . '&uid=' . input('param.uid', '', 'serach_in') . '&backurl=' . urlencode($backurl);
-			$response = $oauth->scopes(['snsapi_base'])->redirect($callback_url);
-
-			// 将响应输出
-			$response->send();
+			$redirectUrl = $oauth->scopes(['snsapi_base'])->redirect($callback_url);
+			header("Location: {$redirectUrl}");
 		} else {
 			$this->eothtmlmsg();
 		}
@@ -117,9 +120,14 @@ class WechatmpController extends Base
 		if (!empty($app)) {
 			$oauth = $app->oauth;
 			// 获取 OAuth 授权结果用户信息
-			$user = $oauth->user();
+			$code = input('get.code');
+			$user = $oauth->userFromCode($code);
 			$openid = $user->getId();
 
+			if (empty($openid)) {
+				$openid = $user['token_response']['openid'];
+			}
+
 			$backurl = input('get.backurl');
 
 			$backurl = str_replace('#/', '', $backurl);
@@ -137,7 +145,7 @@ class WechatmpController extends Base
 
 	function eothtmlmsg()
 	{
-			echo <<< EOT
+		echo <<< EOT
 			<!DOCTYPE html>
 			<html lang="zh-cmn-Hans">
 			<head>

+ 17 - 9
app/index/controller/WithdrawController.php

@@ -7,6 +7,7 @@ use app\model\Withdraw;
 use app\model\UuidRelation;
 use app\model\Agent;
 use app\model\Technical;
+use app\model\Tuanzhang;
 use app\model\Store;
 use app\model\Operatingcity;
 use app\model\Config;
@@ -65,20 +66,32 @@ class WithdrawController extends Base
 
         if ($mo == 'agent') {
             $moapply =  Agent::where('uid', $uid)->find();
+            $moapplyid = $moapply->id;
+            $moapplyincome = $moapply->income;
             $model =  new Agent;
         } elseif ($mo == 'technical') {
-
             $moapply =  Technical::where('uuid', $uuid)->find();
+            $moapplyid = $moapply->id;
+            $moapplyincome = $moapply->income;
             $model =  new Technical;
+        }elseif ($mo == 'tuanzhang') {
+            $moapply =  Tuanzhang::where('uuid', $uuid)->find();
+            $moapplyid = $moapply->id;
+            $moapplyincome = $moapply->income;
+            $model =  new Tuanzhang;
         } elseif ($mo == 'store') {
-            $moapply =  Store::where('uuid', $uuid)->find();
+            $moapply = Store::getInfobyuid(UID());
+            $moapplyincome = $moapply['income'];
+            $moapplyid = $moapply['id'];
             $model =  new Store;
         } elseif ($mo == 'operatingcity') {
             $moapply =  Operatingcity::where('uuid', $uuid)->find();
+            $moapplyid = $moapply->id;
+            $moapplyincome = $moapply->income;
             $model =  new Operatingcity;
         }
 
-        if ($moapply->income >= $amounts) {
+        if ($moapplyincome >= $amounts) {
             $param['withdraw_sn'] = $this->build_no();
             $param['mo'] = $mo;
             $param['amounts'] = $amounts;
@@ -100,12 +113,7 @@ class WithdrawController extends Base
             $Withdraw =   Withdraw::create($param);
 
             if ($Withdraw) {
-                if ($mo == 'agent') {
-                    $model->where('uid', $uid)->dec('income', $amounts)->update();
-                } elseif ($mo == 'technical' || $mo == 'store' || $mo == 'operatingcity') {
-                    $model->where('uuid', $uuid)->dec('income', $amounts)->update();
-                }
-
+                $model->where('id', $moapplyid)->dec('income', $amounts)->update();
                 $errno = 0;
                 $message = '您的提现申请己提交';
             } else {

+ 20 - 19
app/index/controller/kefu/ChatlogController.php

@@ -85,25 +85,26 @@ class ChatlogController extends Base
 
         $app = \app\samos\wechat\Wechatmp::makemp();
 
-        $kefudata['username'] = $data['fromname'];
-        $kefudata['kefu'] = $data['toname'];
-        $kefudata['time'] = date('Y-m-d H:i:s', $data['time']);
-        $kefudata['content'] = $content;
-
-        $message['data']['thing3']['value'] = $kefudata['username'];
-        $message['data']['thing2']['value'] = mb_substr($kefudata['content'], 0, 20);
-
-        $app->template_message->send([
-            'touser' =>  $data['toid'],
-            'template_id' => trim($messagetpl['kefu_tpl']),
-            'url' => $url,
-            'data' => $message['data'],
-        ]);
-
-        //$ret = $ret->toArray();
-        $ret['grouptopid'] = $grouptopid;
-        $ret['is_group'] = $is_group;
-
+        if (!empty($app)) {
+            $kefudata['username'] = $data['fromname'];
+            $kefudata['kefu'] = $data['toname'];
+            $kefudata['time'] = date('Y-m-d H:i:s', $data['time']);
+            $kefudata['content'] = $content;
+
+            $message['data']['thing3']['value'] = $kefudata['username'];
+            $message['data']['thing2']['value'] = mb_substr($kefudata['content'], 0, 20);
+
+            $app->template_message->send([
+                'touser' =>  $data['toid'],
+                'template_id' => trim($messagetpl['kefu_tpl']),
+                'url' => $url,
+                'data' => $message['data'],
+            ]);
+
+            //$ret = $ret->toArray();
+            $ret['grouptopid'] = $grouptopid;
+            $ret['is_group'] = $is_group;
+        }
         return $this->json(['data' => $ret]);
     }
 

+ 6 - 0
app/model/Agent.php

@@ -29,6 +29,12 @@ class Agent extends Model
             return $data->title;
         }
     }
+    public static function conversion($vo)
+    {
+        $vo['agent_level'] = AgentLevel::getLevel($vo['agent_level']) ?? '初级';
+        $vo = RegisterField::conversion($vo);
+        return $vo;
+    }
 
     public static function register($Member)
     {

+ 27 - 0
app/model/Category.php

@@ -12,6 +12,33 @@ class Category extends Model
 
 	protected $name = 'category';
 
+	public function parent()
+	{
+		return $this->belongsTo(Category::class, 'pid', 'id');
+	}
+	// 递归获取所有父节点的ID
+	public static function getParentIds($nodeId)
+	{
+		$parentIds = [];
+		$node = self::find($nodeId);
+
+		if ($node && $node->pid != 0) {
+			$parentIds[] = $node->pid;
+			$parentIds = array_merge($parentIds, self::getParentIds($node->pid));
+		}
+		return $parentIds;
+	}
+
+	public static function getParentIdsstr($nodeId)
+	{
+		$pidarry = self::getParentIds($nodeId);
+		$returndata = $nodeId;
+		foreach ($pidarry as $parentId) {
+			$returndata = $returndata . "," . $parentId;
+		}
+		return $returndata;
+	}
+
 	public static function getsonid($id)
 	{
 		//加空判定

+ 1 - 1
app/model/DiyPageLink.php

@@ -83,7 +83,7 @@ class DiyPageLink
 
         $data['articleDetail'] = [
             'txt' => '文章详情',
-            'path' => '/pages/article/list?id=',
+            'path' => '/pages/article/detail?id=',
             'icon' => 'el-icon-message'
         ];
 

+ 20 - 10
app/model/Geocoder.php

@@ -7,20 +7,30 @@ class Geocoder
 {
 
 	//百度
-	static function gebaidutak()
+	static function getbaiduak()
 	{
-		return '1qfq4iv8mifechLAGentsiiSTptndT2D';
+		$data = Config::getconfig('lbsapi');
+
+		if (empty($data['baiduak'])) {
+			$data = Config::getsitesetupconfig('lbsapi');
+		}
+		return $data['baiduak'];
 	}
-    //腾讯
-	static function geqqtak()
+	//腾讯
+	static function getqqak()
 	{
-		return '6CNBZ-UQZKG-ML2QR-Q4KYL-LJEBQ-B6FTT';
+		$data = Config::getconfig('lbsapi');
+
+		if (empty($data['qqak'])) {
+			$data = Config::getsitesetupconfig('lbsapi');
+		}
+		return $data['qqak'];
 	}
 
 	static function geocoding($address)
 	{
 		$address = str_replace("#", "", $address);
-		$url = 'https://api.map.baidu.com/geocoding/v3/?address=' . $address . '&output=json&ak=' . self::gebaidutak() . '&callback=showLocation';
+		$url = 'https://api.map.baidu.com/geocoding/v3/?address=' . $address . '&output=json&ak=' . self::getbaiduak() . '&callback=showLocation';
 		$ret = urlget($url);
 		$ret = str_replace('showLocation&&showLocation(', '', $ret);
 		$ret = str_replace(')', '', $ret);
@@ -41,7 +51,7 @@ class Geocoder
 
 		if (empty($ret)) {
 			$ret =	self::qq_reverse_geocoding($latitude, $longitude);
-			$ret['addressComponent']=$ret['address_component'];
+			$ret['addressComponent'] = $ret['address_component'];
 		}
 
 		if (!empty($ret)) {
@@ -50,10 +60,10 @@ class Geocoder
 			return null;
 		}
 	}
-    //百度
+	//百度
 	static function baidu_reverse_geocoding($latitude, $longitude)
 	{
-		$url = 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=' . self::gebaidutak() . '&output=json&coordtype=wgs84ll&location=' . $latitude . ',' . $longitude;
+		$url = 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=' . self::getbaiduak() . '&output=json&coordtype=wgs84ll&location=' . $latitude . ',' . $longitude;
 		$ret = urlget($url);
 		$ret = str_replace('showLocation&&showLocation(', '', $ret);
 		$ret = str_replace(')', '', $ret);
@@ -68,7 +78,7 @@ class Geocoder
 	//腾讯
 	static function qq_reverse_geocoding($latitude, $longitude)
 	{
-		$url = 'https://apis.map.qq.com/ws/geocoder/v1/?location='.$latitude.','.$longitude.'&key=' . self::geqqtak() . '&get_poi=1';
+		$url = 'https://apis.map.qq.com/ws/geocoder/v1/?location=' . $latitude . ',' . $longitude . '&key=' . self::getqqak() . '&get_poi=1';
 		$ret = urlget($url);
 		$ret = str_replace('showLocation&&showLocation(', '', $ret);
 		$ret = str_replace(')', '', $ret);

+ 53 - 19
app/model/Goods.php

@@ -35,6 +35,9 @@ class Goods extends Model
             $miaosha = MiaoshaGoods::find($msid);
             if (!empty($miaosha)) {
                 $miaosha = $miaosha->toArray();
+                if ($miaosha['member_buy_max']) {
+                    $miaosha['is_member_buy_max'] = Order::chackMiaoshamemberBuyMax($miaosha);
+                }
             }
         }
 
@@ -157,15 +160,11 @@ class Goods extends Model
         return $goods;
     }
 
-    public static function getmgid($good_ids)
+    public static function getcard_id($good_id)
     {
-        $goods = self::whereIn('id', $good_ids)->order('id desc')->select()->toArray();
+        $goods = self::where('id', $good_id)->find();
 
-        foreach ($goods as $vo) {
-            if ($vo['is_mg'] == 1 && !empty($vo['mgid'])) {
-                return $vo['mgid'];
-            }
-        }
+        return (int) $goods->card_tid;
     }
 
     public static function goodsInfo($id)
@@ -185,6 +184,9 @@ class Goods extends Model
             $goods['minimum'] = 1;
         }
         $goods['price'] = $pricedata["price"];
+        if (empty($goods['quantity_unit']) && $goods['is_times'] != 3) {
+            $goods['quantity_unit'] = '次';
+        }
 
         return $goods;
     }
@@ -256,12 +258,13 @@ class Goods extends Model
                         }
                     }
                 }
-            } else if ($goods['is_mg'] == 1 && !empty($goods['mgid'])) {
-                $MemberAuthGroup = MemberAuthGroup::find($goods['mgid']);
-                if (!empty($MemberAuthGroup)) {
-                    $MemberAuthGroup = $MemberAuthGroup->toArray();
+            } else if ($goods['is_times'] == 3 && !empty($goods['card_tid'])) {
+
+                $GoodsGiftcardType = GoodsGiftcardType::find((int) $goods['card_tid']);
+                if (!empty($GoodsGiftcardType)) {
+                    $GoodsGiftcardType = $GoodsGiftcardType->toArray();
                 }
-                $goods['price'] = $MemberAuthGroup['upgrademoney'];
+                $goods['price'] = $GoodsGiftcardType['buy_price'];
             } else {
                 $MemberAuthGroup["discount"] = (float)$MemberAuthGroup["discount"];
                 if ((!empty($MemberAuthGroup["discount"]))) {
@@ -343,6 +346,9 @@ class Goods extends Model
                     if (empty($vo['goods_id'])) {
                         $vo['goods_id'] = $vo['id'];
                     }
+                    if (empty($vo['quantity_unit']) && $vo['is_times'] != '3') {
+                        $vo['quantity_unit'] = '次';
+                    }
 
                     $vo['price'] = floatval(self::setPrice($vo)["price"]);
                     $vo['original_price'] = floatval($vo['original_price']);
@@ -375,25 +381,50 @@ class Goods extends Model
         }
         return $goodslist;
     }
-    public static function getGoodsBycat($cat = 0, $count = 4, $goodsSort = "all", $ptype = 0, $ocid = 0)
+    /**
+     *
+     * @param integer $cat
+     * @param integer $count
+     * @param string $goodsSort
+     * @param integer $ptype
+     * @param integer $ocid
+     * @return void
+     */
+
+    public static function getGoodsBycat($params = array())
     {
-
+        $cat = $params['cat'];
+        $cat_ids = $params['cat_ids'];
+        $ocid = $params['ocid'];
+        $goodsSort = $params['goodsSort'] || 'all';
+        $count = $params['count'];
+        $ptype = $params['ptype'];
+        $sid = $params['sid'];
+
+        $Configdata = Config::getconfig();
         $where['weid'] = weid();
         $where['status'] = 1;
-        $where['sid'] = 0;
+        if (empty($Configdata['show_storegoods'])) {
+            $where['sid'] = 0;
+        }
 
         if (!empty($ptype)) {
             $where['ptype'] = $ptype;
         }
-
+        if (!empty($sid)) {
+            $where['sid'] = $sid;
+        }
         if ($cat > 0) {
             if (!empty($cat)) {
                 $where['cat_id'] = Category::getsonid($cat);
             }
         }
-
         $query = Goods::where($where);
 
+        if (!empty($cat_ids)) {
+            $query->whereIn('cat_id', $cat_ids);
+        }
+
         if ($ptype == 2) {
             if ($ocid) {
                 $query->where(function ($q) use ($ocid) {
@@ -410,7 +441,7 @@ class Goods extends Model
                         } elseif ($Operatingcity['areatype'] == 1) {
                             $q->where('province_name', $Operatingcity['province_name'])->whereOr('province_name', '');
                         }
-                    }else{
+                    } else {
                         $q->where('city_name', '');
                     }
                 });
@@ -430,6 +461,9 @@ class Goods extends Model
         $data = $query->limit((int) $count)
             ->order($Sort)->select()->toArray();
 
-        return Goods::setGoodslist($data);
+        //$sql = $query->getLastSql();
+        $retdata = Goods::setGoodslist($data);
+        //$retdata['sql'] = $sql;
+        return $retdata;
     }
 }

+ 15 - 0
app/model/GoodsGiftcardCommission.php

@@ -0,0 +1,15 @@
+<?php
+namespace app\model;
+
+use think\Model;
+
+class GoodsGiftcardCommission extends Model
+{
+
+    protected $connection = 'mysql';
+
+    protected $pk = 'id';
+
+    protected $name = 'goods_giftcard_commission';
+
+}

+ 75 - 0
app/model/GoodsGiftcardType.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class GoodsGiftcardType extends Model
+{
+
+	protected $connection = 'mysql';
+
+	protected $pk = 'id';
+
+	protected $name = 'goods_giftcard_type';
+	public static function getpcarray()
+	{
+		$where['weid'] = weid();
+		$where['status'] = 1;
+
+		$list =	self::field('id,name')->where($where)
+			->order('sort asc')
+			->select()
+			->toArray();
+		$array = [];
+		foreach ($list as $k => $v) {
+			$array[$k]['val'] = $v['id'];
+			$array[$k]['key'] = $v['name'];
+		}
+		return $array;
+	}
+
+	public static function getbuy_price($id)
+	{
+
+		$data =	self::find($id);
+		if ($data) {
+			return $data->buy_price;
+		} else {
+			return 0;
+		}
+	}
+
+	public static function getidsbygoods($goods_id)
+	{
+
+		$weid = weid();
+
+		$GiftcardTypequery = self::where('weid', $weid)->field('id');
+
+		$GiftcardTypequery->where(function ($q) use ($goods_id) {
+			$Goods = Goods::find($goods_id);
+			if (!empty($Goods)) {
+				$Goods = $Goods->toArray();
+				$parentIds = Category::getParentIdsstr($Goods['cat_id']);
+
+				$q->where('use_goods', 0)->whereOr('cat_ids', 'in', $parentIds)->whereOr('goods_ids', $goods_id);
+			} else {
+				$q->where('use_goods', 999);
+			}
+		});
+
+		$dataidsarray =  $GiftcardTypequery->select()->toArray();
+
+		$returndata = '';
+		foreach ($dataidsarray as $vo) {
+			if($returndata){
+				$returndata = $returndata . "," . $vo['id'];
+			}else{
+				$returndata =  $vo['id'];
+			}
+			
+		}
+		return $returndata;
+	}
+}

+ 14 - 0
app/model/Member.php

@@ -22,6 +22,20 @@ class Member extends Model
 		return $member;
 	}
 
+	public static function conversion($vo)
+	{
+		$vo['gid'] = MemberAuthGroup::getgroupName($vo['gid']);
+		$vo['pid'] = Member::get_name($vo['pid']) ?? '平台';
+		$vo['regdate'] = time_format($vo['regdate']);
+		$vo['lastdate'] = time_format($vo['lastdate']);
+
+		if (!empty($vo['uuid'])) {
+			$vo['username'] = Users::getusername($vo['uuid']);
+		}
+		$vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
+		return $vo;
+	}
+
 	function getUserbyopenid()
 	{
 

+ 1 - 0
app/model/MessageSms.php

@@ -166,6 +166,7 @@ class MessageSms
 				])
 				->request();
 			//print_r($result->toArray());
+			Test::create(['title' => '手机短信', 'info' => serialize($result->toArray())]);
 			return $result->toArray();
 		} catch (ClientException $e) {
 			return $e->getErrorMessage() . PHP_EOL;

+ 75 - 0
app/model/MiaoshaGoods.php

@@ -2,6 +2,7 @@
 namespace app\model;
 
 use think\Model;
+use think\facade\Db;
 
 class MiaoshaGoods extends Model
 {
@@ -10,6 +11,15 @@ class MiaoshaGoods extends Model
     protected $pk = 'id';
 
     protected $name = 'miaosha_goods';
+
+    public function goods()
+    {
+        return $this->hasOne(Goods::class, 'id', 'goods_id')->bind([
+            'district_name',
+            'city_name',
+            'province_name'
+        ]);
+    }
     public static function setGoodslist($goods)
     {
         if (!empty($goods)) {
@@ -21,6 +31,9 @@ class MiaoshaGoods extends Model
                     $vo['ptype'] = $vo['goods']['ptype'];
                     $vo['time_amount'] = $vo['goods']['time_amount'];
                     $vo['quantity_unit'] = $vo['goods']['quantity_unit'];
+                    if (empty($vo['quantity_unit'] && $vo['is_times'] != 3)) {
+                        $vo['quantity_unit'] = '次';
+                    }
                     $vo['is_timer'] = $vo['goods']['is_timer'];
 
                     $vo['is_times'] = $vo['goods']['is_times'];
@@ -33,4 +46,66 @@ class MiaoshaGoods extends Model
         }
         return $goods;
     }
+    public static function getDiyMiaoshaGoods($count = 4, $goodsSort = "all", $ocid = 0)
+    {
+
+        $Configdata = Config::getconfig();        
+        $query = Db::name('miaosha_goods')
+			->alias('mg')
+			->leftJoin('goods', 'mg.goods_id = goods.id')
+			->field('mg.*, goods.district_name, goods.city_name, goods.province_name');
+
+        $query->where('mg.weid', weid());
+        $query->where('mg.status', 1);
+        if (empty($Configdata['show_storegoods'])) {
+            $query->where('mg.sid', 0);
+        }
+
+        //$query = MiaoshaGoods::where($where);
+        /*
+        $withJoin = [
+            'goods' => ['weid'=>'goodsweid','district_name', 'city_name', 'province_name'],
+        ];
+        $query->withJoin($withJoin, 'left');
+*/
+
+        if ($ocid) {
+            $query->where(function ($q) use ($ocid) {
+                $Operatingcity = Operatingcity::find($ocid);
+                if (!empty($Operatingcity)) {
+                    $Operatingcity = $Operatingcity->toArray();
+                    if (empty($Operatingcity['areatype'])) {
+                        $Operatingcity['areatype'] = 3;
+                    }
+                    if ($Operatingcity['areatype'] == 3) {
+                        $q->where('goods.district_name', $Operatingcity['district_name'])->whereOr('goods.district_name', '');
+                    } elseif ($Operatingcity['areatype'] == 2) {
+                        $q->where('goods.city_name', $Operatingcity['city_name'])->whereOr('goods.city_name', '');
+                    } elseif ($Operatingcity['areatype'] == 1) {
+                        $q->where('goods.province_name', $Operatingcity['province_name'])->whereOr('goods.province_name', '');
+                    }
+                } else {
+                    $q->where('goods.city_name', '');
+                }
+            });
+        } else {
+            $query->where('goods.city_name', '');
+        }
+
+        if ($goodsSort == "all") {
+            $Sort = 'mg.sort asc,mg.id desc';
+        } elseif ($goodsSort == "sales") {
+            $Sort = 'mg.sale_count desc';
+        } elseif ($goodsSort == "price") {
+            $Sort = 'mg.price asc';
+        }
+
+        $data = $query->limit((int) $count)
+            ->order($Sort)->select()->toArray();
+
+        //$sql = $query->getLastSql();
+        $retdata = Goods::setGoodslist($data);
+        //$retdata['sql'] = $sql;
+        return $retdata;
+    }
 }

+ 19 - 0
app/model/Operatingcity.php

@@ -30,6 +30,25 @@ class Operatingcity extends Model
         return $data;
     }
 
+    public static function conversion($vo)
+    {
+        if ($vo['end_time'] == 0) {
+            $vo['end_time'] = '永久有效';
+        } else {
+            $vo['end_time'] = time_format($vo['end_time']);
+        }
+        $vo['cate_ids'] = Category::getmultiple($vo['cate_ids']) ?? '无';
+        $vo['level'] = OperatingcityLevel::getTitle($vo['level']) ?? '初级';
+        $vo['areatype'] = OperatingcityType::getTitle($vo['areatype']) ?? '未设置';
+
+        if (!empty($vo['uuid'])) {
+            $vo['username'] = Users::getusername($vo['uuid']);
+        }
+        $vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
+        $vo = RegisterField::conversion($vo);
+        return $vo;
+    }
+
     public static function getCityid($id = '')
     {
         $mo = self::find($id);

+ 213 - 125
app/model/Order.php

@@ -23,6 +23,11 @@ class Order extends Model
         return $this->hasOne(OrderRefund::class, 'order_id');
     }
 
+    public function orderTimescard()
+    {
+        return $this->hasOne(OrderTimescard::class, 'order_id');
+    }
+
     public function orderGoods()
     {
         return $this->hasMany(OrderGoods::class, 'order_id');
@@ -85,7 +90,7 @@ class Order extends Model
             $vo['Operatingcity_3'] = OperatingcityIncomelog::getorderIncome($vo['id'], 3);
         }
 
-        $vo['payment_code_name'] = Paymethod::get_paymethod_name($vo['payment_code']);
+        $vo['payment_code_name'] = paymentCode($vo['payment_code']);
         $vo['member_nickname'] =  $vo['member']['nickname'];
 
         if (!empty($vo['orderGoods'])) {
@@ -97,17 +102,34 @@ class Order extends Model
         }
 
         if ($vo['is_times'] == 1) {
-
-            if ($vo['timesdate']) {
-                if ($vo['timestype'] == 1) {
-                    $vo['yue_time'] = '每月:' . $vo['timesdate'] . '号';
-                } else {
-                    $vo['yue_time'] = '每周周:' . $vo['timesdate'];
+            $OrderTimescard = OrderTimescard::where('order_id', $vo['id'])->order('id asc')->select()->toArray();
+            if ($OrderTimescard) {
+                foreach ($OrderTimescard as $tcvo) {
+                    if ($tcvo['yue_date']) {
+                        if ($tcvo['timestype'] == 1) {
+                            if ($vo['yue_time']) {
+                                $vo['yue_time'] .= ';每月:' . $tcvo['yue_date'] . '号';
+                            } else {
+                                $vo['yue_time'] = '每月:' . $tcvo['yue_date'] . '号';
+                            }
+                        } else {
+                            if ($vo['yue_time']) {
+                                $vo['yue_time'] .= ';每周周:' . $tcvo['yue_date'];
+                            } else {
+                                $vo['yue_time'] = '每周周:' . $tcvo['yue_date'];
+                            }
+                        }
+                    }
                 }
-            } else {
+            }
+
+            if (empty($vo['yue_time'])) {
                 $vo['yue_time'] = '还没有预约时间';
             }
-            $vo['remain'] = OrderStaff::timesremain($vo['id']);
+
+            $vo['timesused'] = OrderTimescardRecord::timesused($vo['id']);
+            $vo['timesmum'] = OrderCard::timesmum($vo['id']);
+            $vo['remain'] = (int)($vo['timesmum'] - $vo['timesused']);
         } else {
             $vo['yue_time'] = time_ymd($vo['begin_time']) . '<br>' . date('H:i', $vo['begin_time']) . ' 到 ' . date('H:i', $vo['end_time']);
             if ($vo['start_time']) {
@@ -148,6 +170,8 @@ class Order extends Model
         $order['payment_code'] = $order_data['payment_code'];
         $order['pay_from'] = $pay_from;
         $order['points_order'] = (int)$order_data['is_PayPoints'];
+        $order['goodsgiftcard_id'] = (int)$order_data['goodsgiftcard_id'];
+
         if ($order_data['distance']) {
             $order['distance'] = $order_data['distance'];
         }
@@ -178,10 +202,6 @@ class Order extends Model
         $order['shipping_province_name'] = $data['shipping_province_name'];
         $order['shipping_city_name'] =  $data['shipping_city_name'];
         $order['shipping_district_name'] =  $data['shipping_district_name'];
-        $order['shipping_city_id'] = (int) $data['shipping_city_id'];
-        $order['shipping_district_id'] = (int) $data['shipping_district_id'];
-        $order['shipping_province_id'] = (int) $data['shipping_province_id'];
-
         $order['shipping_address'] = $data['shipping_address'];
         $order['shipping_tel'] = $data['shipping_tel'];
         $order['shipping_method'] = $data['shipping_method'];
@@ -210,11 +230,13 @@ class Order extends Model
             }
         }
 
+        //购物卡抵扣
+        if (!empty($order_data['goodsgiftcard_id'])) {
+            $order['payment_code'] = 'goodsgiftcard_pay';
+        }
+
         //次卡设置
         $order['is_times'] = (int) $order_data['is_times'];
-        if ($order['is_times'] == 1) {
-            $order['timesmum'] = $data['goodss'][0]['timesmum'];
-        }
 
         //跑腿订单设置
         $order['is_errands'] = (int) $data['is_errands'];
@@ -250,6 +272,44 @@ class Order extends Model
         $odra .= '_m';
         OrderCount::createuserdata($Orderdata);
 
+        $order['is_timing'] = (int) $order_data['is_timing'];
+        if (!empty($order['is_times'])) {
+            //var_dump($data['goodss']);
+            $GoodsGiftcardType = GoodsGiftcardType::find((int) $data['goodss'][0]['card_tid']);
+            if ($GoodsGiftcardType) {
+                $GoodsGiftcardType = $GoodsGiftcardType->toArray();
+            }
+
+            OrderCard::create([
+                'order_id' => $order_id,
+                'ptype' => (int) $order['is_times'],
+                'weid' => $Orderdata['weid'],
+                'sid' => $Orderdata['sid'],
+                'uid' => $Orderdata['uid'],
+                'timesmum' => $data['goodss'][0]['timesmum'],
+                'card_tid' => (int) $data['goodss'][0]['card_tid'],
+                'name' => $goods['name'],
+                'image' => $goods['image'],
+                'facevalue' => (float) $GoodsGiftcardType['buy_price'] + $data['goodss'][0]['extraprice'],
+                'balance' => (float) $GoodsGiftcardType['buy_price'] + $data['goodss'][0]['extraprice'],
+                'timesmum' => (int) $data['goodss'][0]['timesmum'],
+                'is_timing' => (int) $data['goodss'][0]['is_timing'],
+                'timing_unit' => $data['goodss'][0]['timing_unit'],
+                'color' => $GoodsGiftcardType['color'],
+                'condition_type' => $GoodsGiftcardType['condition_type'],
+                'use_goods' => $GoodsGiftcardType['use_goods'],
+                'cat_ids' => $GoodsGiftcardType['cat_ids'],
+                'use_goods' => $GoodsGiftcardType['use_goods'],
+                'goods_ids' => $GoodsGiftcardType['goods_ids'],
+                'min_price' => $GoodsGiftcardType['min_price'],
+                'start_time' => $GoodsGiftcardType['start_time'],
+                'end_time' => $GoodsGiftcardType['end_time'],
+                'is_expire' => $GoodsGiftcardType['is_expire'],
+                'is_use' => $GoodsGiftcardType['is_use'],
+                'status' => 1,
+            ]);
+        }
+
         if (!empty($order['tuan_id'])) {
             TuanFollow::add_follow([
                 'order_id' => $order_id,
@@ -262,13 +322,12 @@ class Order extends Model
             //var_dump($data['goodss']);
             foreach ($data['goodss'] as $goods) {
                 $goods_id = $goods['goods_id'];
-
                 if (!empty($goods_id)) {
                     OrderGoods::create([
                         'order_id' => $order_id,
                         'goods_id' => $goods_id,
                         'cat_id' => $goods['cat_id'],
-                        'mgid' => $goods['mgid'],
+                        'card_tid' => $goods['card_tid'],
                         'name' => $goods['name'],
                         'model' => $goods['model'],
                         'image' => $goods['image'],
@@ -437,10 +496,9 @@ class Order extends Model
                 $order_history['notify'] = 1;
                 OrderHistory::create($order_history);
 
-                //会员升级
+                //会员升级
                 $good_ids = OrderGoods::getOrderGoodsids($order_id);
                 if ($good_ids) {
-                    $mgid = Goods::getmgid($good_ids);
                     if (empty($mgid)) {
                         $mag = MemberAuthGroup::whereIn('upgrade_goods_id', $good_ids)->order('id desc')->find();
                         $mgid = $mag->id;
@@ -451,6 +509,10 @@ class Order extends Model
                     Member::where('id', $order_info['uid'])->update(['gid' => $mgid]);
                 }
 
+                //购物卡结算佣金
+                if ($order_info['is_times'] == 3) {
+                    self::settlement($order_id);
+                }
                 //更新购买赠送的积分
                 if (!empty($order_info['return_points'])) {
                     if ($order_info['return_points'] > 0) {
@@ -886,10 +948,6 @@ class Order extends Model
                 $data['shipping_city_name'] = empty($shipping['city_name']) ? '' : $shipping['city_name'];
                 $data['shipping_district_name'] = empty($shipping['district_name']) ? '' : $shipping['district_name'];
 
-                $data['shipping_province_id'] = empty($shipping['province_id']) ? '' : $shipping['province_id'];
-                $data['shipping_city_id'] = empty($shipping['city_id']) ? '' : $shipping['city_id'];
-                $data['shipping_district_id'] = empty($shipping['district_id']) ? '' : $shipping['district_id'];
-
                 $data['shipping_address'] = empty($shipping['address']) ? '' : $shipping['address'];
             }
         }
@@ -1022,27 +1080,7 @@ class Order extends Model
                     $pay_points += $goods['totalPayPoints'];
                     $points_price += $goods['totalPointsPrice'];
                     $return_points += $goods['total_return_points'];
-
-                    $goods_data[] = array(
-                        'goods_id' => $goods['goods_id'],
-                        'name' => $goods['name'],
-                        'sid' => $goods['sid'],
-                        'cat_id' => $goods['cat_id'],
-                        'mgid' => $goods['mgid'],
-                        'model' => $goods['model'],
-                        'image' => $goods['image'],
-                        'sku' => $goods['sku'],
-                        'timesmum' => $goods['timesmum'],
-                        'quantity' => $goods['quantity'],
-                        'time_amount' => $goods['time_amount'],
-                        'subtract' => $goods['subtract'],
-                        'price' => $goods['price'],
-                        'is_points_goods' => $goods['is_points_goods'],
-                        'is_commission' => (int) $goods['is_commission'],
-                        'commission_method' => (int) $goods['commission_method'],
-                        'commission_price' => (float) $goods['commission_price'],
-                        'total' => $goods['total']
-                    );
+                    $goods_data[] = $goods;
                 }
 
                 //使用优惠券
@@ -1161,17 +1199,6 @@ class Order extends Model
         $order['shipping_province'] = $order['shipping_province_name'];
         $order['shipping_city'] = $order['shipping_city_name'];
         $order['shipping_district'] = $order['shipping_district_name'];
-        $Area = new Area;
-        if (!empty($order['shipping_province_id'])) {
-            $order['shipping_province'] = $Area->get_area_name($order['shipping_province_id']);
-        }
-        if (!empty($order['shipping_city_id'])) {
-            $order['shipping_city'] = $Area->get_area_name($order['shipping_city_id']);
-        }
-        if (!empty($order['shipping_district_id'])) {
-            $order['shipping_district'] = $Area->get_area_name($order['shipping_district_id']);
-        }
-
         $addressdata = OrderAddress::where(['order_id' => $id, 'ptype' => 1])->find();
         if (empty($addressdata)) {
             $addressdata = Address::find($order['address_id']);
@@ -1241,17 +1268,38 @@ class Order extends Model
         $order['ServiceTime'] = time_format($order['begin_time']) . '-' . date('H:i', $order['end_time']);
 
         if ($order['is_times'] == 1) {
-
-            if ($order['timesdate']) {
-                if ($order['timestype'] == 1) {
-                    $order['ServiceTime'] = '每月:' . $order['timesdate'] . '号';
-                } else {
-                    $order['ServiceTime'] = '每周周:' . $order['timesdate'];
+            $order['ServiceTime'] = "";
+            $OrderTimescard = OrderTimescard::where('order_id', $id)->order('id asc')->select()->toArray();
+            if ($OrderTimescard) {
+                foreach ($OrderTimescard as $tcvo) {
+                    if ($tcvo['yue_date']) {
+                        if ($tcvo['timestype'] == 1) {
+                            if ($order['ServiceTime']) {
+                                $order['ServiceTime'] .= ';每月:' . $tcvo['yue_date'] . '号,时间' . time_format($tcvo['yue_begin_time']) . '-' . date('H:i', $tcvo['yue_end_time']);
+                            } else {
+                                $order['ServiceTime'] = '每月:' . $tcvo['yue_date'] . '号,时间' . time_format($tcvo['yue_begin_time']) . '-' . date('H:i', $tcvo['yue_end_time']);
+                            }
+                        } else {
+                            if ($order['ServiceTime']) {
+                                $order['ServiceTime'] .= ';每周周:' . $tcvo['yue_date'] . ',时间' . time_format($tcvo['yue_begin_time']) . '-' . date('H:i', $tcvo['yue_end_time']);
+                            } else {
+                                $order['ServiceTime'] = '每周周:' . $tcvo['yue_date'] . ',时间' . time_format($tcvo['yue_begin_time']) . '-' . date('H:i', $tcvo['yue_end_time']);
+                            }
+                        }
+                    }
                 }
-            } else {
+            }
+
+            if (empty($order['ServiceTime'])) {
                 $order['ServiceTime'] = '还没有预约时间';
             }
-            $order['remain'] = OrderStaff::timesremain($order['id']);
+
+            $order['timesusedlist'] = OrderTimescardRecord::timesusedlist($id);
+            $order['timesremainlist'] = OrderTimescardRecord::timesremainlist($id);
+            $order['timesused'] = OrderTimescardRecord::timesused($id);
+            $order['timesmum'] = OrderCard::timesmum($id);
+
+            $order['remain'] = (int)($order['timesmum'] - $order['timesused']);
         } else {
             $order['ServiceTime'] = time_format($order['begin_time']) . '-' . date('H:i', $order['end_time']);
         }
@@ -1281,6 +1329,7 @@ class Order extends Model
             'logistics' => $logistics,
             'histories' => $histories
         );
+
         $resdata['orderInfo']['is_timer'] = (int) $resdata['goods']['is_timer'];
         return $resdata;
     }
@@ -1297,19 +1346,44 @@ class Order extends Model
         $errands = Config::getconfig('errands');
 
         foreach ($orderList as &$vo) {
-            if ($vo['is_times'] == 1) {
-
-                if ($vo['timesdate']) {
-                    if ($vo['timestype'] == 1) {
-                        $vo['timeslabel'] = '服务时间,每月:' . $vo['timesdate'] . '号';
+            if ($vo['is_times'] > 0) {
+
+                if ($vo['is_times'] == 1) {
+                    $OrderTimescard = OrderTimescard::where('order_id', $vo['id'])->order('id asc')->select()->toArray();
+                    if ($OrderTimescard) {
+                        foreach ($OrderTimescard as $tcvo) {
+                            if ($tcvo['yue_date']) {
+                                if ($tcvo['timestype'] == 1) {
+                                    if ($vo['timeslabel']) {
+                                        $vo['timeslabel'] .= ';每月:' . $tcvo['yue_date'] . '号';
+                                    } else {
+                                        $vo['timeslabel'] = '每月:' . $tcvo['yue_date'] . '号';
+                                    }
+                                } else {
+                                    if ($vo['timeslabel']) {
+                                        $vo['timeslabel'] .= ';每周周:' . $tcvo['yue_date'];
+                                    } else {
+                                        $vo['timeslabel'] = '每周周:' . $tcvo['yue_date'];
+                                    }
+                                }
+                            }
+                        }
                     } else {
-                        $vo['timeslabel'] = '服务时间,每周周:' . $vo['timesdate'];
+                        $vo['timeslabel'] = '还没有预约时间';
                     }
-                } else {
-                    $vo['timeslabel'] = '您还没有预约时间';
                 }
 
-                $vo['remain'] = OrderStaff::timesremain($vo['id']);
+                $vo['timesused'] = OrderTimescardRecord::timesused($vo['id']);
+                $vo['timesmum'] = OrderCard::timesmum($vo['id']);
+                $vo['remain'] = (int)($vo['timesmum'] - $vo['timesused']);
+
+                $vo['minialias'] = substr($vo['order_num_alias'], -5);
+                $vo['styleno'] = substr($vo['order_num_alias'], -1);
+                if ($vo['styleno'] > 5) {
+                    $vo['styleno'] = $vo['styleno'] - 5;
+                }
+
+                $vo['OrderCard'] = OrderCard::getinfobyorderid($vo['id']);
             }
 
             if ($vo['is_errands'] == 1) {
@@ -1439,65 +1513,69 @@ class Order extends Model
                 $order_history['notify'] = 1;
 
                 OrderHistory::create($order_history);
-                Technical::setIncome($order_info);
-                Store::setIncome($order_info);
-                Operatingcity::setIncome($order_info);
-                Tuanzhang::setIncome($order_info);
-
-                //分销佣金处理
-                $agent = Config::getconfig('agent');
-                $share = Config::getconfig('share');
-                if (!empty($agent['level'])) {
-                    $level = $agent['level'];
-                }
-                if (!empty($agent['is_rebate'])) {
-                    $is_rebate = $agent['is_rebate'];
-                }
 
-                if (!empty($level)) {
-                    //一层佣金
-                    if ($level > 0) {
-                        $firstpercent = $share['first'];
-                        if (!empty($firstpercent)) {
-                            $firstmember = Member::find($order_info['uid']);
+                //使用购物卡支付不结算佣金
+                if (empty($order_info['goodsgiftcard_id'])) {
+                    Technical::setIncome($order_info);
+                    Store::setIncome($order_info);
+                    Operatingcity::setIncome($order_info);
+                    Tuanzhang::setIncome($order_info);
+
+                    //分销佣金处理
+                    $agent = Config::getconfig('agent');
+                    $share = Config::getconfig('share');
+                    if (!empty($agent['level'])) {
+                        $level = $agent['level'];
+                    }
+                    if (!empty($agent['is_rebate'])) {
+                        $is_rebate = $agent['is_rebate'];
+                    }
 
-                            if (!empty($firstmember)) {
-                                $firstmember = $firstmember->toArray();
-                                $firstmember['is_agent'] = Agent::is_agent($firstmember['id']);
-                            }
-                            if (!empty($is_rebate) && $firstmember['is_agent'] == 1) {
-                                $firstuid = $order_info['uid'];
-                            } else {
-                                $firstuid = $firstmember['pid'];
-                            }
+                    if (!empty($level)) {
+                        //一层佣金
+                        if ($level > 0) {
+                            $firstpercent = $share['first'];
+                            if (!empty($firstpercent)) {
+                                $firstmember = Member::find($order_info['uid']);
 
-                            Agent::setIncome($firstuid, $order_info, $firstpercent, 1);
-                        }
-                    }
-                    //二层佣金
-                    if ($level > 1 && !empty($firstuid)) {
-                        $secondpercent = $share['second'];
-                        if (!empty($secondpercent)) {
-                            $secondmember = Member::find($firstuid);
-                            if (!empty($secondmember)) {
-                                $secondmember = $secondmember->toArray();
+                                if (!empty($firstmember)) {
+                                    $firstmember = $firstmember->toArray();
+                                    $firstmember['is_agent'] = Agent::is_agent($firstmember['id']);
+                                }
+                                if (!empty($is_rebate) && $firstmember['is_agent'] == 1) {
+                                    $firstuid = $order_info['uid'];
+                                } else {
+                                    $firstuid = $firstmember['pid'];
+                                }
+
+                                Agent::setIncome($firstuid, $order_info, $firstpercent, 1);
                             }
-                            if ((int) $secondmember['pid'] > 0) {
-                                Agent::setIncome($secondmember['pid'], $order_info, $secondpercent, 2);
+                        }
+                        //二层佣金
+                        if ($level > 1 && !empty($firstuid)) {
+                            $secondpercent = $share['second'];
+                            if (!empty($secondpercent)) {
+                                $secondmember = Member::find($firstuid);
+                                if (!empty($secondmember)) {
+                                    $secondmember = $secondmember->toArray();
+                                }
+                                if ((int) $secondmember['pid'] > 0) {
+                                    Agent::setIncome($secondmember['pid'], $order_info, $secondpercent, 2);
+                                }
                             }
                         }
-                    }
 
-                    //三层佣金
-                    if ($level > 2 && !empty($secondmember['pid'])) {
-                        $thirdpercent = $share['third'];
-                        if (!empty($thirdpercent)) {
-                            $thirdmember = Member::find($secondmember['pid']);
-                            if (!empty($thirdmember)) {
-                                $thirdmember = $thirdmember->toArray();
-                            }
-                            if ((int) $thirdmember['pid'] > 0) {
-                                Agent::setIncome($thirdmember['pid'], $order_info, $thirdpercent, 3);
+                        //三层佣金
+                        if ($level > 2 && !empty($secondmember['pid'])) {
+                            $thirdpercent = $share['third'];
+                            if (!empty($thirdpercent)) {
+                                $thirdmember = Member::find($secondmember['pid']);
+                                if (!empty($thirdmember)) {
+                                    $thirdmember = $thirdmember->toArray();
+                                }
+                                if ((int) $thirdmember['pid'] > 0) {
+                                    Agent::setIncome($thirdmember['pid'], $order_info, $thirdpercent, 3);
+                                }
                             }
                         }
                     }
@@ -1590,4 +1668,14 @@ class Order extends Model
         $list['image'] =  toimg($list['image']);
         return $list;
     }
+
+    public static function chackMiaoshamemberBuyMax($miaosha)
+    {
+        $Ordercount =  Order::where('uid', UID())->where('ms_id', $miaosha['id'])->count();
+        if ($Ordercount >= $miaosha['member_buy_max']) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
 }

+ 31 - 0
app/model/OrderCard.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class OrderCard extends Model
+{
+
+    protected $connection = 'mysql';
+
+    protected $pk = 'id';
+
+    protected $name = 'order_card';
+
+    public static function timesmum($order_id)
+    {
+        $data =  self::where(['order_id' => $order_id])->find();
+        if ($data) {
+            return (int) $data->timesmum;
+        }
+    }
+    public static function getinfobyorderid($order_id)
+    {
+        $data =  self::where(['order_id' => $order_id])->find();
+        if ($data) {
+            return $data->toArray();
+        }
+    }
+    
+}

+ 8 - 8
app/model/OrderGoods.php

@@ -66,14 +66,14 @@ class OrderGoods extends Model
             ->toArray();
         foreach ($OrderGoods as $vo) {
             if (!empty($vo['goods_id'])) {
-                if ($vo['mgid'] > 0 && !empty($roletype)) {
-                    $member_commission = MemberCommission::where('mgid', $vo['mgid'])->where('roletype', $roletype)->find();
-                    if (!empty($member_commission)) {
-                        $member_commission = $member_commission->toArray();
-                        if ($member_commission['commission_method'] == 0) {
-                            $total = $total + (($vo['total'] * percent_to_num($member_commission['return_percent'])));
-                        } elseif ($member_commission['commission_method'] == 1) {
-                            $total = $total + (($member_commission['return_percent'] * $vo['quantity']));
+                if ($vo['card_tid'] > 0 && !empty($roletype)) {
+                    $GiftcardCommission = GoodsGiftcardCommission::where('card_tid', $vo['card_tid'])->where('roletype', $roletype)->find();
+                    if (!empty($GiftcardCommission)) {
+                        $GiftcardCommission = $GiftcardCommission->toArray();
+                        if ($GiftcardCommission['commission_method'] == 0) {
+                            $total = $total + (($vo['total'] * percent_to_num($GiftcardCommission['return_percent'])));
+                        } elseif ($GiftcardCommission['commission_method'] == 1) {
+                            $total = $total + (($GiftcardCommission['return_percent'] * $vo['quantity']));
                         }
                     }
                 } elseif ($vo['is_commission'] == 1) {

+ 0 - 9
app/model/OrderStaff.php

@@ -24,15 +24,6 @@ class OrderStaff extends Model
 		return $staff->id;
 	}
 
-	public static function timesremain($order_id)
-	{
-		return self::where(['order_id' => $order_id, 'is_complete' => 0])->count();
-	}
-	public static function timesused($order_id)
-	{
-		return self::where(['order_id' => $order_id, 'is_complete' => 1])->count();
-	}
-
 	public static function ordercount($uuid)
 	{
 		return self::where('uuid', $uuid)->count();

+ 15 - 0
app/model/OrderTimescard.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class OrderTimescard extends Model
+{
+
+	protected $connection = 'mysql';
+
+	protected $pk = 'id';
+
+	protected $name = 'order_timescard';
+}

+ 61 - 0
app/model/OrderTimescardRecord.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class OrderTimescardRecord extends Model
+{
+
+	protected $connection = 'mysql';
+
+	protected $pk = 'id';
+
+	protected $name = 'order_timescard_record';
+
+	public static function timesremain($order_id)
+	{
+		return self::where(['order_id' => $order_id, 'is_complete' => 0])->count();
+	}
+	//未使用
+	public static function timesremainlist($order_id)
+	{
+		$retdate =  self::where(['order_id' => $order_id, 'is_complete' => 0])
+			->where('yue_begin_time', '>', 0)
+			->order('yue_begin_time asc')
+			->select()
+			->toArray();
+		if (!empty($retdate)) {
+			foreach ($retdate as &$vo) {
+				$vo['yue_begin_time'] = time_format($vo['yue_begin_time']);
+				$vo['yue_end_time'] = time_format($vo['yue_end_time']);
+				$vo['begin_time'] = time_format($vo['begin_time']);
+				$vo['end_time'] = time_format($vo['end_time']);
+			}
+		}
+		return $retdate;
+	}
+	//已使用次数
+	public static function timesused($order_id)
+	{
+		return self::where(['order_id' => $order_id, 'is_complete' => 1])->count();
+	}
+	//已使用
+	public static function timesusedlist($order_id)
+	{
+		$retdate = self::where(['order_id' => $order_id, 'is_complete' => 1])
+			->where('yue_begin_time', '>', 0)
+			->order('yue_begin_time asc')
+			->select()
+			->toArray();
+		if (!empty($retdate)) {
+			foreach ($retdate as &$vo) {
+				$vo['yue_begin_time'] = time_format($vo['yue_begin_time']);
+				$vo['yue_end_time'] = time_format($vo['yue_end_time']);
+				$vo['begin_time'] = time_format($vo['begin_time']);
+				$vo['end_time'] = time_format($vo['end_time']);
+			}
+		}
+		return $retdate;
+	}
+}

+ 0 - 9
app/model/OrderTuanzhang.php

@@ -24,15 +24,6 @@ class OrderTuanzhang extends Model
 		return $tuanzhang->id;
 	}
 
-	public static function timesremain($order_id)
-	{
-		return self::where(['order_id' => $order_id, 'is_complete' => 0])->count();
-	}
-	public static function timesused($order_id)
-	{
-		return self::where(['order_id' => $order_id, 'is_complete' => 1])->count();
-	}
-
 	public static function ordercount($uuid)
 	{
 		return self::where('uuid', $uuid)->count();

+ 1 - 0
app/model/Partner.php

@@ -55,6 +55,7 @@ class Partner extends Model
         if (!empty($vo['uuid'])) {
             $vo['username'] = Users::getusername($vo['uuid']);
         }
+        $vo = RegisterField::conversion($vo);
         return $vo;
     }
 

+ 0 - 9
app/model/Paymethod.php

@@ -68,15 +68,6 @@ class Paymethod extends Model
             }
         }
     }
-    public static function get_paymethod_name($code)
-    {
-
-        $ret = self::where(['weid' => weid(), 'code' => $code])->find();
-        if (!empty($ret)) {
-            $ret = $ret->toArray();
-            return $ret['title'];
-        }
-    }
 
     public static function getwx_settings()
     {

+ 39 - 0
app/model/Platform.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+use think\facade\Db;
+
+class Platform extends Model
+{
+
+    protected $connection = 'mysql';
+
+    protected $pk = 'id';
+
+    protected $name = 'platform';
+
+    public static function datainitial()
+    {
+        $data =  self::create([
+            'title' => '默认平台',
+            'endtime' => 0,
+            'sort' => 100,
+            'status' => 1
+        ]);
+
+        $data->id;
+    }
+
+    public static function getInfo($id)
+    {
+        $data = self::find($id);
+        if ($data) {
+            $data = $data->toArray();
+            $data['pic'] = toimg($data['pic']);
+            $data['endtime'] = time_format($data['endtime']);
+        }
+        return $data;
+    }
+}

+ 12 - 2
app/model/PrinterFeie.php

@@ -126,8 +126,18 @@ class PrinterFeie
         }
 
         //$content .= "实付:{$order['pay_price']}元<BR>";
-        $content .= "联系人:{$order['shipping_name']}<BR>";
-        $content .= "联系人电话:{$order['shipping_tel']}<BR>";
+
+        if (!empty($order['shipping_name'])) {
+            $content .= "联系人:{$order['shipping_name']}<BR>";
+        } else {
+            $content .= "联系人:{$order['member']['nickname']}<BR>";
+        }
+        if (!empty($order['shipping_tel'])) {
+            $content .= "联系电话:{$order['shipping_tel']}<BR>";
+        }else{
+            $content .= "联系电话:{$order['member']['telephone']}<BR>";
+        }
+
         $content .= "地址:{$order['shipping_province']}{$order['shipping_city']}{$order['shipping_district']}{$order['address']['address']}<BR>";
         $content .= "--------------------------------<BR>";
 

+ 78 - 16
app/model/RegisterField.php

@@ -45,16 +45,52 @@ class RegisterField extends Model
     }
     public static function getimportField($ptype)
     {
-        return self::where(['weid' => weid(), 'ptype' => $ptype, 'is_import' => 1, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
+        $data = self::where(['weid' => weid(), 'ptype' => $ptype, 'is_import' => 1, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
+        return $data;
     }
     public static function getlistViewField($ptype)
     {
-        return self::where(['weid' => weid(), 'is_listView' => 1, 'ptype' => $ptype, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
+        $data = self::where(['weid' => weid(), 'is_listView' => 1, 'ptype' => $ptype, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
+        foreach ($data as &$vo) {
+            if ($vo['is_sys'] == 0) {
+                $vo['fieldsmingcheng'] = $vo['inputtype'] . $vo['id'];
+            }
+        }
+        return $data;
     }
     public static function getinputField($ptype)
     {
         return self::where(['weid' => weid(), 'is_input' => 1, 'ptype' => $ptype, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
     }
+    public static function conversion($vo)
+    {
+        $customtextarr = iunserializer($vo['customtext']);
+        if (!empty($customtextarr)) {
+            foreach ($customtextarr as $k => $v) {
+                if (!empty($v)) {
+                    foreach ($v as $kk => $vv) {
+                        if ($k == 'lbs') {
+                            if (!empty($vv)) {
+                                $tmp = iunserializer($vv);
+                                if (!empty($tmp)) {
+                                    if (!empty($tmp['region_name'])) {
+                                        $vo[$k . $kk] = '[' . $tmp['region_name'] . ']';
+                                    }
+                                    $vo[$k . $kk] =  $vo[$k . $kk] . $tmp['address'];
+                                }
+                            }
+                        } else {
+                            if (!empty($vv)) {
+                                $vo[$k . $kk] = $vv;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return $vo;
+    }
+
 
     public static function fieldToData($postdata, $terminal = "")
     {
@@ -263,7 +299,6 @@ class RegisterField extends Model
         $limit = config('my.dumpsize') ? config('my.dumpsize') : 1000;
 
         $count = $query->count();
-
         $res = $query->order('id desc')
             ->limit(($page - 1) * $limit, $limit)
             ->select()
@@ -278,6 +313,12 @@ class RegisterField extends Model
         if (!empty($res)) {
 
             foreach ($res as &$voo) {
+                if ($ptype == "member") {
+                    $voo = Member::conversion($voo);
+                }
+                if ($ptype == "agent") {
+                    $voo = Agent::conversion($voo);
+                }
                 if ($ptype == "technical") {
                     $voo = Technical::conversion($voo);
                 }
@@ -310,7 +351,27 @@ class RegisterField extends Model
                                 $datalist[$k][$key] =  Area::get_area_name($vo['province_id']);
                             }
                         } else {
-                            $datalist[$k][$fvo['inputtype'] . $fvo['id']] = iunserializer($vo['customtext'])[$fvo['inputtype']][$fvo['id']];
+                            $datalist[$k][$key] = iunserializer($vo['customtext'])[$fvo['inputtype']][$fvo['id']];
+                        }
+                    } elseif ($fvo['inputtype'] == 'lbs') {
+                        if ($fvo['is_sys'] == 1) {
+                            if ($fvo['fieldsmingcheng'] == 'city_id') {
+                                $datalist[$k][$key] =  Area::get_area_name($vo['city_id']);
+                            } elseif ($fvo['fieldsmingcheng'] == 'country_id') {
+                                $datalist[$k][$key] =  Area::get_area_name($vo['country_id']);
+                            } elseif ($fvo['fieldsmingcheng'] == 'province_id') {
+                                $datalist[$k][$key] =  Area::get_area_name($vo['province_id']);
+                            }
+                        } else {
+                            $tmp = iunserializer(iunserializer($vo['customtext'])[$fvo['inputtype']][$fvo['id']]);
+                            if (!empty($tmp)) {
+                                if (!empty($tmp['region_name'])) {
+                                    $datalist[$k][$key] = '[' . $tmp['region_name'] . ']';
+                                }
+                                $datalist[$k][$key] = $datalist[$k][$key] . $tmp['address'];
+                            } else {
+                                $datalist[$k][$key] = '';
+                            }
                         }
                     } elseif ($fvo['inputtype'] == 'radio') {
                         if ($fvo['is_sys'] == 1) {
@@ -714,7 +775,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 1,
             ], [
@@ -724,7 +785,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 0,
             ], [
@@ -746,13 +807,14 @@ class RegisterField extends Model
                 'is_import' => 1,
                 'is_listView' => 1
             ], [
-                'fieldsmingcheng' => 'category_id',
-                'viewmingcheng' => '分类',
-                'inputtype' => 'select',
+                'fieldsmingcheng' => 'certificate_ids',
+                'viewmingcheng' => '师傅认证',
+                'inputtype' => 'checkbox',
                 'is_front' => 0,
+                'is_frontinput' => 1,
                 'is_input' => 1,
                 'is_import' => 1,
-                'is_listView' => 0
+                'is_listView' => 1
             ], [
                 'fieldsmingcheng' => 'tel',
                 'viewmingcheng' => '手机号',
@@ -954,7 +1016,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 1,
             ], [
@@ -964,7 +1026,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 0,
             ], [
@@ -1123,7 +1185,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 1,
             ], [
@@ -1133,7 +1195,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 0,
             ], [
@@ -1242,7 +1304,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 1,
             ], [
@@ -1252,7 +1314,7 @@ class RegisterField extends Model
                 'valuerules' => 'require',
                 'is_front' => 0,
                 'is_frontinput' => 1,
-                'is_input' => 1,
+                'is_input' => 0,
                 'is_import' => 1,
                 'is_listView' => 0,
             ], [

+ 15 - 0
app/model/Reglike.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class Reglike extends Model
+{
+
+    protected $connection = 'mysql';
+
+    protected $pk = 'id';
+
+    protected $name = 'reglike';
+}

+ 4 - 3
app/model/Signin.php

@@ -28,10 +28,10 @@ class Signin extends Model
 
         if (!empty($data)) {
             foreach ($data as $vo) {
-                if (date('Y-m-d', $vo['create_time']) == date('Y-m-d', strtotime('now'))) {
+                if (date('Y-m-d', strtotime($vo['create_time'])) == date('Y-m-d', strtotime('now'))) {
                     $sign_index++;
                     $day++;
-                } elseif (date('Y-m-d', $vo['create_time']) == date('Y-m-d', strtotime('-' . $day . ' days'))) {
+                } elseif (date('Y-m-d', strtotime($vo['create_time'])) == date('Y-m-d', strtotime('-' . $day . ' days'))) {
                     $sign_index++;
                     $day++;
                 }
@@ -57,8 +57,9 @@ class Signin extends Model
             ->order('id desc')
             ->find();
         $res = false;
+        
         if (!empty($data)) {
-            if (date('Y-m-d', $data->create_time) == date('Y-m-d', strtotime('now'))) {
+            if (date('Y-m-d', strtotime($data->create_time)) == date('Y-m-d', strtotime('now'))) {
                 $res = true;
             }
         }

+ 61 - 0
app/model/Store.php

@@ -59,6 +59,7 @@ class Store extends Model
                 'tzid' => $Tuanzhang['id'],
                 'owner_name' => $Tuanzhang['title'],
                 'title' => $Tuanzhang['community_title'],
+                'tel' => $Tuanzhang['tel'],
                 'store_logo' => $Tuanzhang['touxiang'],
                 'latitude' => $Tuanzhang['latitude'],
                 'longitude' => $Tuanzhang['longitude'],
@@ -127,8 +128,68 @@ class Store extends Model
             $vo['username'] = Users::getusername($vo['uuid']);
         }
         $vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
+        $vo = RegisterField::conversion($vo);
         return $vo;
     }
+    public static function getdiy_bycat($cat = 0, $count = 4, $Sort = "all", $ocid = 0)
+    {
+        $where['weid'] = weid();
+        $where['status'] = 1;
+
+        if ($cat > 0) {
+            if (!empty($cat)) {
+                $where['cate_ids'] = Category::getsonid($cat);
+            }
+        }
+
+        $query = self::where($where);
+
+        if ($ocid) {
+            $query->where(function ($q) use ($ocid) {
+                $Operatingcity = Operatingcity::find($ocid);
+                if (!empty($Operatingcity)) {
+                    $Operatingcity = $Operatingcity->toArray();
+                    if (empty($Operatingcity['areatype'])) {
+                        $Operatingcity['areatype'] = 3;
+                    }
+                    if ($Operatingcity['areatype'] == 3) {
+                        $q->where('district_name', $Operatingcity['district_name'])->whereOr('district_name', '');
+                    } elseif ($Operatingcity['areatype'] == 2) {
+                        $q->where('city_name', $Operatingcity['city_name'])->whereOr('city_name', '');
+                    } elseif ($Operatingcity['areatype'] == 1) {
+                        $q->where('province_name', $Operatingcity['province_name'])->whereOr('province_name', '');
+                    }
+                }
+            });
+        }
+
+        if ($Sort == "all") {
+            $Sort = 'sort asc,id desc';
+        } elseif ($Sort == "sales") {
+            $Sort = 'service_times desc';
+        } elseif ($Sort == "price") {
+            $Sort = 'create_time asc';
+        }
+
+        $data = $query->limit($count)
+            ->order($Sort)->select()->toArray();
+
+        foreach ($data as &$vo) {
+            if (!empty($vo['tzid'])) {
+                if (empty($vo['store_logo']) ||  empty($vo['title'])) {
+                    $Tuanzhang = Tuanzhang::find($vo['tzid']);
+                    if (!empty($Tuanzhang)) {
+                        $vo['store_logo'] = $Tuanzhang['touxiang'];
+                        $vo['title'] = $Tuanzhang['community_title'];
+                    }
+                }
+            }
+            $vo['store_logo'] = toimg($vo['store_logo']);
+        }
+
+        return $data;
+    }
+
     public static function setIncome($order_info)
     {
         if (empty($order_info['sid'])) {

+ 29 - 2
app/model/Technical.php

@@ -67,6 +67,7 @@ class Technical extends Model
     public static function conversion($vo)
     {
         $vo['cate_ids'] = Category::getmultiple($vo['cate_ids']) ?? '无';
+        $vo['certificate_ids'] = TechnicalCertificate::getmultiple($vo['certificate_ids']) ?? '无';
         $vo['level'] = TechnicalLevel::getTitle($vo['level']) ?? '初级';
         $vo['sid'] = Store::getTitle($vo['sid']) ?? '平台';
 
@@ -81,6 +82,7 @@ class Technical extends Model
 
         $vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
         $vo['end_time'] = time_format($vo['end_time']) ?? '长期';
+        $vo = RegisterField::conversion($vo);
         return $vo;
     }
 
@@ -167,7 +169,7 @@ class Technical extends Model
 
         return $data;
     }
-    public static function getdiy_bycat($cat = 0, $count = 4, $goodsSort = "all")
+    public static function getdiy_bycat($cat = 0, $count = 4, $Sort = "all", $ocid = 0)
     {
         $where['weid'] = weid();
         $where['status'] = 1;
@@ -180,7 +182,32 @@ class Technical extends Model
 
         $query = Technical::where($where);
 
-        $Sort = 'id desc';
+        if ($ocid) {
+            $query->where(function ($q) use ($ocid) {
+                $Operatingcity = Operatingcity::find($ocid);
+                if (!empty($Operatingcity)) {
+                    $Operatingcity = $Operatingcity->toArray();
+                    if (empty($Operatingcity['areatype'])) {
+                        $Operatingcity['areatype'] = 3;
+                    }
+                    if ($Operatingcity['areatype'] == 3) {
+                        $q->where('district_name', $Operatingcity['district_name'])->whereOr('district_name', '');
+                    } elseif ($Operatingcity['areatype'] == 2) {
+                        $q->where('city_name', $Operatingcity['city_name'])->whereOr('city_name', '');
+                    } elseif ($Operatingcity['areatype'] == 1) {
+                        $q->where('province_name', $Operatingcity['province_name'])->whereOr('province_name', '');
+                    }
+                }
+            });
+        }
+
+        if ($Sort == "all") {
+            $Sort = 'sort asc,id desc';
+        } elseif ($Sort == "sales") {
+            $Sort = 'service_times desc';
+        } elseif ($Sort == "price") {
+            $Sort = 'create_time asc';
+        }
 
         $data = $query->limit($count)
             ->order($Sort)->select()->toArray();

+ 83 - 0
app/model/TechnicalCertificate.php

@@ -0,0 +1,83 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class TechnicalCertificate extends Model
+{
+
+    protected $connection = 'mysql';
+
+    protected $pk = 'id';
+
+    protected $name = 'technical_certificate';
+
+
+    function getdatalist()
+    {
+        $ptypeArray =  $this->where(['weid' => weid()])->select()->toArray();
+        return $ptypeArray;
+    }
+
+    public static function getTitle($id = '')
+    {
+        $ret = self::find($id);
+        if (!empty($ret)) {
+            $ret = $ret->toArray();
+        }
+        return $ret['title'];
+    }
+    public static function getmultiple($ids)
+	{
+		if (!empty($ids)) {
+			$data = self::where(['weid' => weid()])->where('id', 'in', $ids)
+				->select()->toArray();
+
+			if (!empty($data)) {
+				foreach ($data as $vo) {
+					if (empty($returndata)) {
+						$returndata =  $vo['title'];
+					} else {
+						$returndata = $returndata . "," . $vo['title'];
+					}
+				}
+			}
+			return $returndata;
+		}
+	}
+    public static function getarray()
+    {
+        $data = self::where(['weid' => weid()])->order('id desc')->select()->toArray();
+        if (!empty($data))
+            foreach ($data as $vo) {
+                $datalist[$vo['id']] = $vo['title'];
+            }
+        else
+            $datalist['0'] = '认证';
+
+        return $datalist;
+    }
+
+    public static function getpcarray()
+    {
+        $data = self::field('id,title')->where(['weid' => weid()])->select()->toArray();
+        $datalist = [];
+        foreach ($data as $key => $vo) {
+            $datalist[$key]['val'] = $vo['id'];
+			$datalist[$key]['key'] = $vo['title'];
+        }
+        return $datalist;
+    }
+
+    public static function getone()
+    {
+        $ret = self::where(['weid' => weid()])->order('id asc')->find();
+
+		if (!empty($ret)) {
+			$ret = $ret->toArray();
+		}
+
+        return $ret;
+    }
+}

+ 1 - 1
app/model/TextReplace.php

@@ -21,7 +21,7 @@ class TextReplace extends Model
                 $isarray = 1;
                 $textarry = json_encode($textarry,JSON_UNESCAPED_UNICODE);
             }
-            $textReplace = self::where('status', 1)->where('weid', weid())->cache(180)->select()->toArray();
+            $textReplace = self::where('status', 1)->where('weid', weid())->cache(180)->order('sort asc')->select()->toArray();
             if (!empty($textReplace)) {
                 foreach ($textReplace as $vo) {
                     if ($isarray) {

+ 75 - 1
app/model/TuanGoods.php

@@ -3,6 +3,7 @@
 namespace app\model;
 
 use think\Model;
+use think\facade\Db;
 
 class TuanGoods extends Model
 {
@@ -12,7 +13,14 @@ class TuanGoods extends Model
 
     protected $name = 'tuan_goods';
 
-
+    public function goods()
+    {
+        return $this->hasOne(Goods::class, 'id', 'goods_id')->bind([
+            'district_name',
+            'city_name',
+            'province_name'
+        ]);
+    }
 
     public static function setGoodslist($goods)
     {
@@ -25,6 +33,9 @@ class TuanGoods extends Model
                     $vo['ptype'] = $vo['goods']['ptype'];
                     $vo['time_amount'] = $vo['goods']['time_amount'];
                     $vo['quantity_unit'] = $vo['goods']['quantity_unit'];
+                    if (empty($vo['quantity_unit']) && $vo['is_times'] != 3) {
+                        $vo['quantity_unit'] = '次';
+                    }
                     $vo['is_timer'] = $vo['goods']['is_timer'];
 
                     $vo['is_times'] = $vo['goods']['is_times'];
@@ -51,4 +62,67 @@ class TuanGoods extends Model
         }
         return $data;
     }
+
+    public static function getDiyTuanGoods($count = 4, $goodsSort = "all", $ocid = 0)
+    {
+        $Configdata = Config::getconfig();        
+        $query = Db::name('tuan_goods')
+			->alias('tg')
+			->leftJoin('goods', 'tg.goods_id = goods.id')
+			->field('tg.*, goods.district_name, goods.city_name, goods.province_name');
+
+        $query->where('tg.weid', weid());
+        $query->where('tg.status', 1);
+        if (empty($Configdata['show_storegoods'])) {
+            $query->where('tg.sid', 0);
+        }
+
+        //$query = MiaoshaGoods::where($where);
+       
+        /*
+        $withJoin = [
+            'goods' => ['weid'=>'goodsweid','district_name', 'city_name', 'province_name'],
+        ];
+        $query->withJoin($withJoin, 'left');
+*/
+
+        if ($ocid) {
+            $query->where(function ($q) use ($ocid) {
+                $Operatingcity = Operatingcity::find($ocid);
+                if (!empty($Operatingcity)) {
+                    $Operatingcity = $Operatingcity->toArray();
+                    if (empty($Operatingcity['areatype'])) {
+                        $Operatingcity['areatype'] = 3;
+                    }
+                    if ($Operatingcity['areatype'] == 3) {
+                        $q->where('goods.district_name', $Operatingcity['district_name'])->whereOr('goods.district_name', '');
+                    } elseif ($Operatingcity['areatype'] == 2) {
+                        $q->where('goods.city_name', $Operatingcity['city_name'])->whereOr('goods.city_name', '');
+                    } elseif ($Operatingcity['areatype'] == 1) {
+                        $q->where('goods.province_name', $Operatingcity['province_name'])->whereOr('goods.province_name', '');
+                    }
+                } else {
+                    $q->where('goods.city_name', '');
+                }
+            });
+        } else {
+            $query->where('goods.city_name', '');
+        }
+
+        if ($goodsSort == "all") {
+            $Sort = 'tg.sort asc,tg.id desc';
+        } elseif ($goodsSort == "sales") {
+            $Sort = 'tg.sale_count desc';
+        } elseif ($goodsSort == "price") {
+            $Sort = 'tg.price asc';
+        }
+
+        $data = $query->limit((int) $count)
+            ->order($Sort)->select()->toArray();
+
+        //$sql = $query->getLastSql();
+        $retdata = Goods::setGoodslist($data);
+        //$retdata['sql'] = $sql;
+        return $retdata;
+    }
 }

+ 2 - 0
app/model/Tuanzhang.php

@@ -49,6 +49,8 @@ class Tuanzhang extends Model
             $vo['username'] = Users::getusername($vo['uuid']);
         }
         $vo['region_name'] = $vo['province_name'] . $vo['city_name'] . $vo['district_name'];
+
+        $vo = RegisterField::conversion($vo);
         return $vo;
     }
 

+ 62 - 54
app/samos/wechat/MiniProgram.php

@@ -37,49 +37,53 @@ class MiniProgram
 	{
 
 		$app =  self::makemini();
-		$response = $app->app_code->getUnlimit($scene, [
-			'page'  => $page,
-			'width' => $width,
-		]);
+		if (!empty($app)) {
+			$response = $app->app_code->getUnlimit($scene, [
+				'page'  => $page,
+				'width' => $width,
+			]);
+
+			if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
+				$filename = $response->save(config('filesystem.disks.public.root'), 'qrcode' . md5(base64_encode(time())) . '.jpg');
+			}
 
-		if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
-			$filename = $response->save(config('filesystem.disks.public.root'), 'qrcode' . md5(base64_encode(time())) . '.jpg');
-		}
+			$ifw7ppath = dirname(dirname(dirname(dirname(__DIR__))));
+			$ifw7ppatharray =  explode('/', $ifw7ppath);
 
-		$ifw7ppath = dirname(dirname(dirname(dirname(__DIR__))));
-		$ifw7ppatharray =  explode('/', $ifw7ppath);
+			if (end($ifw7ppatharray) == 'addons') {
+				$w7ppath = 'addons/' . config('database.app_name') . '/';
+			} else {
+				$w7ppath = '';
+			}
 
-		if (end($ifw7ppatharray) == 'addons') {
-			$w7ppath = 'addons/' . config('database.app_name') . '/';
-		} else {
-			$w7ppath = '';
+			$appdata['lan'] = Author()::getlan();
+			return toimg($w7ppath . 'public/uploads/' . $filename);
 		}
-
-		$appdata['lan'] = Author()::getlan();
-		return toimg($w7ppath . 'public/uploads/' . $filename);
 	}
 
 	static function getQrcode2($page, $width = 230)
 	{
 
 		$app =  self::makemini();
-		$response = $app->app_code->getQrCode($page, $width);
+		if (!empty($app)) {
+			$response = $app->app_code->getQrCode($page, $width);
 
-		if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
-			$filename = $response->save(config('filesystem.disks.public.root'), 'qrcode' . md5(base64_encode(time())) . '.jpg');
-		}
+			if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
+				$filename = $response->save(config('filesystem.disks.public.root'), 'qrcode' . md5(base64_encode(time())) . '.jpg');
+			}
 
-		$ifw7ppath = dirname(dirname(dirname(dirname(__DIR__))));
-		$ifw7ppatharray =  explode('/', $ifw7ppath);
+			$ifw7ppath = dirname(dirname(dirname(dirname(__DIR__))));
+			$ifw7ppatharray =  explode('/', $ifw7ppath);
 
-		if (end($ifw7ppatharray) == 'addons') {
-			$w7ppath = 'addons/' . config('database.app_name') . '/';
-		} else {
-			$w7ppath = '';
-		}
+			if (end($ifw7ppatharray) == 'addons') {
+				$w7ppath = 'addons/' . config('database.app_name') . '/';
+			} else {
+				$w7ppath = '';
+			}
 
-		$appdata['lan'] = Author()::getlan();
-		return toimg($w7ppath . 'public/uploads/' . $filename);
+			$appdata['lan'] = Author()::getlan();
+			return toimg($w7ppath . 'public/uploads/' . $filename);
+		}
 	}
 
 	//判断是否存在页面
@@ -91,10 +95,12 @@ class MiniProgram
 			$page = mb_substr($page, 1);
 		}
 		$app =  self::makemini();
-		$response = $app->app_code->getUnlimit('i', [
-			'page'  => $page,
-			'width' => 200,
-		]);
+		if (!empty($app)) {
+			$response = $app->app_code->getUnlimit('i', [
+				'page'  => $page,
+				'width' => 200,
+			]);
+		}
 		//Test::create(['title' => $page . '测试判断是否存在页面', 'info' => serialize($response)]);
 		if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
 			return true;
@@ -107,13 +113,14 @@ class MiniProgram
 	{
 
 		$app = self::makemini();
+		if (!empty($app)) {
+			$url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token=' . $app->access_token->getToken(true)['access_token'];
 
-		$url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token=' . $app->access_token->getToken(true)['access_token'];
-
-		$retlink = urlpost($url, $param);
+			$retlink = urlpost($url, $param);
 
-		$appdata['lan'] = Author()::getlan();
-		return $retlink;
+			$appdata['lan'] = Author()::getlan();
+			return $retlink;
+		}
 	}
 
 	static function createLiveRoom($data)
@@ -141,16 +148,17 @@ class MiniProgram
 		$params = array_merge($create_data, $data);
 
 		$app = self::makemini();
+		if (!empty($app)) {
+			$params['coverImg'] = $app->media->uploadImage(localpic($params['coverImg']))['media_id'];
+			$params['shareImg'] = $app->media->uploadImage(localpic($params['shareImg']))['media_id'];
+			$params['feedsImg'] = $params['coverImg'];
 
-		$params['coverImg'] = $app->media->uploadImage(localpic($params['coverImg']))['media_id'];
-		$params['shareImg'] = $app->media->uploadImage(localpic($params['shareImg']))['media_id'];
-		$params['feedsImg'] = $params['coverImg'];
-
-		$url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=' . $app->access_token->getToken(true)['access_token'];
+			$url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=' . $app->access_token->getToken(true)['access_token'];
 
-		$res = urlpost($url, $params);
-		$appdata['lan'] = Author()::getlan();
-		return $res;
+			$res = urlpost($url, $params);
+			$appdata['lan'] = Author()::getlan();
+			return $res;
+		}
 	}
 
 	static function getphonenumber($code)
@@ -158,18 +166,18 @@ class MiniProgram
 
 		$param['code'] = $code;
 		$app = self::makemini();
+		if (!empty($app)) {
+			$access_token = $app->access_token->getToken(true)['access_token'];
 
-		$access_token = $app->access_token->getToken(true)['access_token'];
-
-		$url = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' . $access_token;
+			$url = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=' . $access_token;
 
-		$phonenumberdate = urlpost($url, $param);
+			$phonenumberdate = urlpost($url, $param);
 
-		if ($phonenumberdate['errmsg'] == 'ok') {
-			$date = $phonenumberdate['phone_info'];
+			if ($phonenumberdate['errmsg'] == 'ok') {
+				$date = $phonenumberdate['phone_info'];
+			}
+			$appdata['lan'] = Author()::getlan();
 		}
-		$appdata['lan'] = Author()::getlan();
-
 		return $date;
 	}
 	static function subscribemessage($tpl)

+ 1 - 1
config/database.php

@@ -36,7 +36,7 @@ return [
     'auto_timestamp'  => true,
 
     // 时间字段取出后的默认时间格式
-    'datetime_format' => 'Y-m-d H:i',
+    'datetime_format' => false,
 
     // 数据库连接配置信息
     'connections'     => [

+ 25 - 5
config/my.php

@@ -13,12 +13,32 @@
 // | 自定义配置
 // +----------------------------------------------------------------------
 return [
-	'app_v2'          =>'xm_ma'.'ll',
-	'app_v3'          =>'xm_ma'.'llv3',
-	'app_v6'          =>'xm_ma'.'llv6',
+	'app_v2'          => 'xm_ma' . 'll',
+	'app_v3'          => 'xm_ma' . 'llv3',
+	'app_v6'          => 'xm_ma' . 'llv6',
 	'upload_subdir'		=> 'Ym',				//文件上传二级目录 标准的日期格式
-	'nocheck'			=> ['admin/Login/index','admin/Login/sitesetup','admin/Login/logout'],	//不需要验证权限的url
-	'testnoupdate'		=> ['admin/config/update','admin/diypage/update','admin/diypage/setindex','admin/diypage/setaudit','admin/diypage/delete','admin/registerfield/listUpdate','admin/registerfield/update','admin/registerfield/delete','admin/Category/delete','admin/goods/delete','admin/member/delete','admin/Upgrade/index'],	//演示站不能修改的url
+	'nocheck'			=> ['admin/Login/index', 'admin/Login/sitesetup', 'admin/Login/logout'],	//不需要验证权限的url
+	'testnoupdate'		=> [
+		'admin/config/update',
+		'admin/diypage/update',
+		'admin/diypage/setindex',
+		'admin/diypage/setaudit',
+		'admin/diypage/delete',
+		'admin/registerfield/listUpdate',
+		'admin/registerfield/update',
+		'admin/registerfield/delete',
+		'admin/Category/delete',
+		'admin/goods/delete',
+		'admin/member/delete',
+		'admin/Upgrade/index',
+		'admin/member/dumpdata',
+		'admin/Category/update',
+		'admin/Category/delete',
+		'admin/bottommenu/listUpdate',
+		'admin/bottommenu/update',
+		'admin/bottommenu/delete',
+		'admin/technical/delete'
+	],	//演示站不能修改的url
 	'error_log_code'	=> 500,					//写入日志的状态码
 	'dump_extension'	=> 'xlsx',				//默认导出格式
 	'filetype'	=> 'jpg,jpeg,png,gif,mp4,3gp,m3u8,doc,docx,xls,xlsx,pem',  //上传文件文件类型

文件差異過大導致無法顯示
+ 487 - 425
data/installdata.sql


+ 2 - 2
h5/index.html

@@ -1,2 +1,2 @@
-<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>同城到家</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
-            document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.97465e7b.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.c1302c01.js></script><script src=./static/js/index.67a04beb.js></script></body></html>
+<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>新麦同城</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
+            document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.2da1efab.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.71cdce8b.js></script><script src=./static/js/index.803937c5.js></script></body></html>

文件差異過大導致無法顯示
+ 0 - 0
h5/static/index.2da1efab.css


文件差異過大導致無法顯示
+ 0 - 0
h5/static/js/chunk-vendors.71cdce8b.js


文件差異過大導致無法顯示
+ 0 - 0
h5/static/js/chunk-vendors.c1302c01.js


文件差異過大導致無法顯示
+ 0 - 0
h5/static/js/index.67a04beb.js


文件差異過大導致無法顯示
+ 0 - 0
h5/static/js/index.803937c5.js


部分文件因文件數量過多而無法顯示