duxin 3 mēneši atpakaļ
vecāks
revīzija
9185ad4b51

+ 3 - 3
internal/jyutil/equityOpen.go

@@ -24,7 +24,7 @@ func EntServiceOpen(entId int, phone string) (int, int) {
 	if user == nil {
 		return 0, 0
 	}
-	sql := "SELECT  COUNT(1)  FROM  entniche_power a  INNER JOIN entniche_wait_empower b ON a.wait_empower_id = b.id  and  b.end_time > now() where  a.ent_id=" + common.InterfaceToStr(entId) + " and a.ent_user_id=" + common.InterfaceToStr(user.Map()["id"]) + " and  a.`status`=1"
+	sql := "SELECT  *  FROM  entniche_power a  INNER JOIN entniche_wait_empower b ON a.wait_empower_id = b.id  and  b.end_time > now() where  a.ent_id=" + common.InterfaceToStr(entId) + " and a.ent_user_id=" + common.InterfaceToStr(user.Map()["id"]) + " and  a.`status`=1"
 	number, _ := g.DB().Ctx(ctx).GetCount(ctx, sql)
 	if number == 0 {
 		return 1, 1
@@ -74,7 +74,7 @@ func AutomaticallyCreatingEnt(name, phone, orderCode string, userId string) (int
 func EntLicense(ctx context.Context, entId, empowerCount, provinceCount, orderId, userCount int, productType, st, et, phone string) (error, int64) {
 	log.Println("订单企业授权信息记录===", entId, productType)
 	e, pid := func() (error, int64) {
-		if count, _ := g.DB().Ctx(ctx).GetCount(ctx, fmt.Sprintf(`SELECT count(1) FROM entniche_order WHERE order_detail_id = '%d' `, orderId)); count > 0 {
+		if count, _ := g.DB().Ctx(ctx).GetCount(ctx, fmt.Sprintf(`SELECT * FROM entniche_order WHERE order_detail_id = '%d' `, orderId)); count > 0 {
 			return nil, 0
 		}
 		var pid int64
@@ -123,7 +123,7 @@ func EntLicense(ctx context.Context, entId, empowerCount, provinceCount, orderId
 				g.DB().Ctx(ctx).Insert(ctx, "entniche_order", inData)
 				if userCount > 0 {
 					if !user.IsEmpty() {
-						sql := "SELECT  COUNT(1)  FROM  entniche_power a  INNER JOIN entniche_wait_empower b ON a.wait_empower_id = b.id  and  b.end_time > now()   where  a.ent_id=" + fmt.Sprint(entId) + " and a.ent_user_id=" + common.InterfaceToStr(user.Map()["id"]) + " and  a.`status`=1"
+						sql := "SELECT  *  FROM  entniche_power a  INNER JOIN entniche_wait_empower b ON a.wait_empower_id = b.id  and  b.end_time > now()   where  a.ent_id=" + fmt.Sprint(entId) + " and a.ent_user_id=" + common.InterfaceToStr(user.Map()["id"]) + " and  a.`status`=1"
 						number, _ := g.DB().Ctx(ctx).GetCount(ctx, sql)
 						if number == 0 {
 							g.DB().Ctx(ctx).Insert(ctx, "entniche_power", map[string]interface{}{"wait_empower_id": id,

+ 4 - 4
internal/jyutil/user.go

@@ -257,7 +257,7 @@ func SellerCheck(ctx context.Context, posId int64, UserPhone string) error {
 		total int
 		err   error
 	)
-	total, err = g.DB("subject").GetCount(ctx, fmt.Sprintf("SELECT COUNT(*) FROM dwd_f_crm_clue_info a inner join dwd_f_userbase_contacts b on a.uid=b.baseinfo_id WHERE b.phone='%s' and a.position_id=%d", UserPhone, posId))
+	total, err = g.DB("subject").GetCount(ctx, fmt.Sprintf("SELECT * FROM dwd_f_crm_clue_info a inner join dwd_f_userbase_contacts b on a.uid=b.baseinfo_id WHERE b.phone='%s' and a.position_id=%d", UserPhone, posId))
 	if err != nil {
 		return err
 	}
@@ -284,7 +284,7 @@ func SellerCheck(ctx context.Context, posId int64, UserPhone string) error {
 	}
 	phonesStr = strings.Join(phoneArr, "','")
 	//(1)最近3天(可配置)该电销人员与用户存在通话时长≥60秒(可配置);
-	if num, err := g.DB("subject").GetCount(ctx, fmt.Sprintf(`SELECT count(*) 
+	if num, err := g.DB("subject").GetCount(ctx, fmt.Sprintf(`SELECT * 
 				FROM Call_Accounting.voice_record 
 				WHERE CallTimeLength >= ? 
 				AND Ring > (SELECT DATE_SUB(NOW(), INTERVAL ? HOUR)) 
@@ -297,7 +297,7 @@ func SellerCheck(ctx context.Context, posId int64, UserPhone string) error {
 		return nil
 	}
 	//(2)最近3天(可配置)该电销人员与该用户存在已上传附件的跟进记录;
-	if num, err := g.DB("subject").GetCount(ctx, `SELECT count(*) 
+	if num, err := g.DB("subject").GetCount(ctx, `SELECT * 
 				FROM dwd_f_crm_clue_info a 
     			INNER JOIN dwd_f_crm_trail_content b  ON a.id =b.clue_id 
     			INNER JOIN attachment c  ON b.id =c.change_id 
@@ -305,7 +305,7 @@ func SellerCheck(ctx context.Context, posId int64, UserPhone string) error {
 		return nil
 	}
 	//(3)该电销人员与该用户正在通话中。
-	if num, err := g.DB("subject").GetCount(ctx, `SELECT count(*) FROM dwd_f_userbase_contacts 
+	if num, err := g.DB("subject").GetCount(ctx, `SELECT * FROM dwd_f_userbase_contacts 
                 WHERE baseinfo_id=? AND is_talking=1 
                 AND is_talking_seat_number IN(
                 	SELECT seat_number 

+ 1 - 1
internal/logic/order/contract.go

@@ -8,7 +8,7 @@ import (
 )
 
 func SaveOrUpdateContract(ctx context.Context, orderCode, companyName string, money int, contract model.Contract) error {
-	count, err := g.DB().GetCount(ctx, "SELECT count(*) from contract where order_code = ?", orderCode)
+	count, err := g.DB().GetCount(ctx, "SELECT * from contract where order_code = ?", orderCode)
 	if err != nil {
 		return gerror.Wrapf(err, "查询回款计划异常")
 	}

+ 1 - 1
internal/logic/order/contractPdf.go

@@ -50,7 +50,7 @@ const (
 
 func GetContractPdf(ctx context.Context, orderCode, userName string) (interface{}, error) {
 	detail, orderQueryErr := func() (map[string]interface{}, error) {
-		if num, _ := g.DB().GetCount(ctx, "SELECT count(*) FROM jy_order_detail WHERE order_code=?", orderCode); num != 1 {
+		if num, _ := g.DB().GetCount(ctx, "SELECT * FROM jy_order_detail WHERE order_code=?", orderCode); num != 1 {
 			return nil, fmt.Errorf("当前订单不支持合同下载")
 		}
 		orderRes, err := g.DB().GetOne(ctx, "SELECT c.filter,c.service_type,a.audit_status,c.product_type,a.vip_type,a.salesperson,a.buy_subject,a.signing_subject,b.contract_status,b.seal_type,b.partyA_type,b.partyA_name,b.partyA_person,b.partyA_tel,b.partyA_address,b.partyB_person,b.remark,b.contract_money FROM dataexport_order a INNER JOIN jy_order_detail c ON a.order_code=c.order_code INNER JOIN contract b  ON a.order_code=b.order_code WHERE a.order_code=? ", orderCode)

+ 1 - 1
internal/logic/order/examineList.go

@@ -90,7 +90,7 @@ func ExamineList(ctx context.Context, param model.OrderExamineListParams) (map[s
 		"lists": []map[string]interface{}{},
 		"total": 0,
 	}
-	qCount := fmt.Sprintf("SELECT count(*) FROM(select DISTINCT(d.order_code) from dataexport_order d inner join order_sale_record s  on ( d.order_code=s.ordercode and (s.state=1 or s.state=2) %s) where %s )as orderData", innerSale, strings.Join(condition, " and "))
+	qCount := fmt.Sprintf("SELECT * FROM(select DISTINCT(d.order_code) from dataexport_order d inner join order_sale_record s  on ( d.order_code=s.ordercode and (s.state=1 or s.state=2) %s) where %s )as orderData", innerSale, strings.Join(condition, " and "))
 	log.Println("count sql", qCount)
 	count, _ := g.DB().GetCount(ctx, qCount)
 	if count > 0 {

+ 4 - 3
internal/logic/order/list.go

@@ -26,7 +26,7 @@ func List(ctx context.Context, param model.OrderListParams) (map[string]interfac
 	if param.IsHelpList {
 		// 我的订单、高翔、沈炳义查看所有得帮助用户下单的订单
 		orderSql = append(orderSql, " a.del_status = 0 ")
-		countRes, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT count(1) from cadmin.request_auth WHERE user_id = %d and request_call = 'Baiy.Cadmin.Order.helpUserOrders'`, adminId))
+		countRes, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT * from cadmin.request_auth WHERE user_id = %d and request_call = 'Baiy.Cadmin.Order.helpUserOrders'`, adminId))
 		if countRes > 0 {
 			orderSql = append(orderSql, " a.order_channel = 'xdqd04' ")
 		} else {
@@ -135,7 +135,7 @@ LEFT JOIN (
         invoice_status = 1 and invoice_changed = 0
     GROUP BY 
         order_code
-) b ON a.order_code = b.order_code
+) b ON a.order_code = b.order_code 
 LEFT JOIN (
     SELECT 
         order_code,
@@ -172,7 +172,7 @@ LEFT JOIN (
 WHERE 
     %s`
 	sql := fmt.Sprintf(sqlWhere, " a.id,\n  a.order_code,\n  a.create_time,\n  a.company_name,\n    a.user_phone,\n    a.user_nickname,\n    a.buy_subject,\n    a.audit_status,\n    a.order_status,\n    a.pay_money - IFNULL(g.orderMoney, 0) as pay_money,\n    a.commission,\n    a.return_status,\n    IFNULL(c.return_money, 0) as return_money,\n    IFNULL(b.invoiced_amount, 0) as invoiced_amount,\n    a.refund_status,\n    IFNULL(d.refund_money, 0) as refund_money,\n    f.ent_userId,\n    e.contract_status,\n    e.contract_time,\n    e.contract_archive_status,\n    e.contract_archive_time,\n    (SELECT id FROM jy_order_detail where order_code = a.order_code order by final_price desc, id desc LIMIT 1) as order_detail_id  ", adminId, strings.Join(orderSql, " and "))
-	sqlCount := fmt.Sprintf(sqlWhere, " count(1) ", adminId, strings.Join(orderSql, " and "))
+	sqlCount := fmt.Sprintf(sqlWhere, " * ", adminId, strings.Join(orderSql, " and "))
 
 	log.Println("list count sql :", sqlCount)
 	log.Println("list sql :", sql)
@@ -193,6 +193,7 @@ WHERE
 			continue
 		}
 		m["service_type"] = jyOrderDetail.Map()["service_type"]
+		m["filter"] = jyOrderDetail.Map()["filter"]
 		//未回款金额
 		m["no_return_money"] = gconv.Int(m["pay_money"]) - gconv.Int(m["return_money"]) - gconv.Int(m["commission"])
 		//未退款金额

+ 1 - 1
internal/logic/order/returnPlant.go

@@ -11,7 +11,7 @@ import (
 
 // SaveOrUpdateReturnPlant 保存更新回款计划
 func SaveOrUpdateReturnPlant(ctx context.Context, orderCode string, orderMoney int, plant model.ReturnPlant) error {
-	num, err := g.DB().GetCount(ctx, "SELECT count(*) from return_money_plant where order_code = ?", orderCode)
+	num, err := g.DB().GetCount(ctx, "SELECT * from return_money_plant where order_code = ?", orderCode)
 	if err != nil {
 		return gerror.Wrapf(err, "查询回款计划异常")
 	}

+ 1 - 1
internal/logic/order/saleRecord.go

@@ -404,7 +404,7 @@ func CommonChange(ctx context.Context, orderCode, operationTime string, operatio
 	)
 	if operationType == ReturnProtocol { //未回款、已归档
 		//校验是否首次归档
-		count, err := g.DB().GetCount(ctx, "SELECT count(*) FROM contract WHERE contract_archive_status=1 AND order_code=?", orderCode)
+		count, err := g.DB().GetCount(ctx, "SELECT * FROM contract WHERE contract_archive_status=1 AND order_code=?", orderCode)
 		if err != nil {
 			return errors.Wrap(err, "查询是否首次回款异常")
 		}

+ 1 - 1
internal/logic/product/bigmember/bigcommon.go

@@ -30,7 +30,7 @@ const (
 
 // ExistProcessOrder 是否存在处理的订单
 func ExistProcessOrder(phone, orderCode string) bool {
-	sql := fmt.Sprintf(`SELECT count(1) FROM dataexport_order a
+	sql := fmt.Sprintf(`SELECT * FROM dataexport_order a
 INNER JOIN jy_order_detail b on a.order_code = b.order_code 
 WHERE  a.user_phone = '%s' and b.is_service_open = 0 and b.product_type = '大会员' `, phone)
 	if orderCode != "" {

+ 3 - 3
internal/logic/product/subvip/check.go

@@ -64,7 +64,7 @@ func (p jySubVipProduct) Check(ctx context.Context, t int) error {
 			switch p.OrderDetail.ReqSubject {
 			case 1: //个人
 				if p.OrderDetail.ServiceType == 1 || p.OrderDetail.ServiceType == 4 { //校验是否有待生效的订单
-					num, err := g.DB().GetCount(ctx, "SELECT COUNT(*) FROM dataexport_order d inner join jy_order_detail jyd on(d.order_code=jyd.order_code) WHERE d.user_phone=? and jyd.product_type= 'VIP订阅' and (jyd.vip_type=0 or jyd.vip_type=3)", p.OrderDetail.Phone)
+					num, err := g.DB().GetCount(ctx, "SELECT * FROM dataexport_order d inner join jy_order_detail jyd on(d.order_code=jyd.order_code) WHERE d.user_phone=? and jyd.product_type= 'VIP订阅' and (jyd.vip_type=0 or jyd.vip_type=3)", p.OrderDetail.Phone)
 					if err != nil {
 						return gerror.Wrapf(err, "查询账户订单信息异常")
 					}
@@ -72,7 +72,7 @@ func (p jySubVipProduct) Check(ctx context.Context, t int) error {
 						return errors.New("已存在同类型订单")
 					}
 				} else { //关联id是否存在
-					num, err := g.DB().GetCount(ctx, "SELECT COUNT(*) FROM jy_order_detail  WHERE status =1 and is_service_open=1 and  product_type ='VIP订阅' and d.linked_detail_id=? and  service_endtime>? ", p.OrderDetail.LinkedOrderId, time.Now().Format(time.DateTime))
+					num, err := g.DB().GetCount(ctx, "SELECT * FROM jy_order_detail  WHERE status =1 and is_service_open=1 and  product_type ='VIP订阅' and d.linked_detail_id=? and  service_endtime>? ", p.OrderDetail.LinkedOrderId, time.Now().Format(time.DateTime))
 					if err != nil {
 						return gerror.Wrapf(err, "查询账户权益信息异常")
 					}
@@ -94,7 +94,7 @@ func (p jySubVipProduct) Check(ctx context.Context, t int) error {
 			case 2: //企业
 				//校验当前套餐内容是否满足升级续费
 				if p.OrderDetail.ServiceType == 3 || p.OrderDetail.ServiceType == 5 {
-					num, err := g.DB().GetCount(ctx, "SELECT COUNT(*) FROM jy_order_detail d inner join entniche_order eo (on d.id =eo.order_detail_id) inner join entniche_wait_empower ewe on(eo.wait_empower_id=ewe.id ) WHERE  d.status =1 and d.is_service_open=1 and  d.product_type ='VIP订阅' and d.linked_detail_id=? and ewe.ent_id=? and end_time>?", p.OrderDetail.LinkedOrderId, entId, time.Now().Format(time.DateTime))
+					num, err := g.DB().GetCount(ctx, "SELECT * FROM jy_order_detail d inner join entniche_order eo (on d.id =eo.order_detail_id) inner join entniche_wait_empower ewe on(eo.wait_empower_id=ewe.id ) WHERE  d.status =1 and d.is_service_open=1 and  d.product_type ='VIP订阅' and d.linked_detail_id=? and ewe.ent_id=? and end_time>?", p.OrderDetail.LinkedOrderId, entId, time.Now().Format(time.DateTime))
 					if err != nil {
 						return gerror.Wrapf(err, "查询账户权益信息异常")
 					}

+ 3 - 3
internal/logic/product/subvip/service.go

@@ -58,7 +58,7 @@ func (p jySubVipProduct) OpenService(ctx context.Context) error {
 					"areacount":       filter.FinalAccountCount,
 					"newcitys":        []int{},
 					"buyerclasscount": -1,
-				},                                                    //购买内容 城市、省份、行业数量
+				}, //购买内容 城市、省份、行业数量
 				"l_vip_starttime":      vipStartTime.Unix(),          //开始时间
 				"l_vip_endtime":        vipEndTime.Unix(),            //结束时间
 				"i_vip_status":         common.If(doType == 1, 2, 1), //1试用 2正式
@@ -177,7 +177,7 @@ func (p jySubVipProduct) OpenService(ctx context.Context) error {
 
 // entPower 企业超级订阅
 func vipEntPower(ctx context.Context, entId, entUserId int64, doType, empowerCount, provinceCount int, orderDetailId int64, st, et time.Time) (pid int64, err error) {
-	if count, _ := g.DB().GetCount(ctx, "SELECT count(1) FROM entniche_order WHERE order_detail_id = ?", orderDetailId); count > 0 {
+	if count, _ := g.DB().GetCount(ctx, "SELECT * FROM entniche_order WHERE order_detail_id = ?", orderDetailId); count > 0 {
 		return 0, fmt.Errorf("此订单已开通服务")
 	}
 	t := date.NowFormat(date.Date_Full_Layout)
@@ -208,7 +208,7 @@ func vipEntPower(ctx context.Context, entId, entUserId int64, doType, empowerCou
 			return 0, errors.Wrap(err, "插待授权表更新失败入")
 		}
 		//判断当前用户是否有企业级超级订阅权益
-		number, err := g.DB().Ctx(ctx).GetCount(ctx, "SELECT  COUNT(1)  FROM  entniche_power a  INNER JOIN entniche_wait_empower b ON a.wait_empower_id = b.id  and  b.end_time > now() where  a.`status`=1 and a.ent_id=? and a.ent_user_id=?", entId, entUserId)
+		number, err := g.DB().Ctx(ctx).GetCount(ctx, "SELECT  *  FROM  entniche_power a  INNER JOIN entniche_wait_empower b ON a.wait_empower_id = b.id  and  b.end_time > now() where  a.`status`=1 and a.ent_id=? and a.ent_user_id=?", entId, entUserId)
 		if err != nil {
 			return 0, fmt.Errorf("查询用户权益异常")
 		}

+ 1 - 1
internal/logic/user/getService.go

@@ -145,7 +145,7 @@ WHERE a.status = 1 %s and a.user_id = '%s' and a.product_type like '%s' ORDER BY
 						userServer, _ := g.DB().Query(ctx, fmt.Sprintf(`SELECT s_serviceid,s_smainid,l_endtime,l_starttime FROM bigmember_service_user WHERE s_userid = '%s' and i_status =0`, userId))
 						if !userServer.IsEmpty() {
 							vipExist = true
-							count, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT count(1) as count FROM bigmember_service_user WHERE s_userid = %s and i_status =0 and (s_serviceid=4 or s_serviceid =19)`, userId))
+							count, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT *  FROM bigmember_service_user WHERE s_userid = '%s' and i_status =0 and (s_serviceid=4 or s_serviceid =19)`, userId))
 							isHUa := count > 0
 							for _, v := range userServer.List() {
 								if isHUa && v["s_serviceid"] == 26 {

+ 1 - 1
internal/logic/user/personService.go

@@ -12,7 +12,7 @@ import (
 )
 
 func OrderUserChangePhone(ctx context.Context, param model.UserServiceParams) (interface{}, error) {
-	buySubject, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT count(1) FROM dataexport_order WHERE order_code = '%s' and buy_subject =1`, param.OrderCode))
+	buySubject, _ := g.DB().GetCount(ctx, fmt.Sprintf(`SELECT * FROM dataexport_order WHERE order_code = '%s' and buy_subject =1`, param.OrderCode))
 	if buySubject == 0 {
 		return nil, nil
 	}