コミットを比較

...

7 コミット

作成者 SHA1 メッセージ 日付
  DengBiao a08845466c update 供应链加入商品库 10ヶ月前
  DengBiao d0da1451da update 10ヶ月前
  zengzhengrong d70d41372d 1 10ヶ月前
  DengBiao f3435c10d6 update 10ヶ月前
  DengBiao cd7a79e6b3 update 10ヶ月前
  DengBiao 62f5e0f787 update 10ヶ月前
  DengBiao 67c846b4e7 update 10ヶ月前
6個のファイルの変更140行の追加51行の削除
分割表示
  1. +76
    -0
      app/utils/aes/aes_utils.go
  2. +1
    -1
      app/utils/convert.go
  3. +43
    -43
      consume/init.go
  4. +12
    -1
      consume/mall_add_supply_goods.go
  5. +4
    -2
      consume/supply_cloud_chain_fenxiao_new_change.go
  6. +4
    -4
      etc/cfg.yml

+ 76
- 0
app/utils/aes/aes_utils.go ファイルの表示

@@ -0,0 +1,76 @@
package aes

import (
"bytes"
"crypto/aes"
"encoding/base64"
)

const AesKey = "zhiyingos@qq.com"

// 加密
func AesEncryptByECB(key, data string) string {
// 判断key长度
keyLenMap := map[int]struct{}{16: {}, 24: {}, 32: {}}
if _, ok := keyLenMap[len(key)]; !ok {
panic("key长度必须是 16、24、32 其中一个")
}
// 密钥和待加密数据转成[]byte
originByte := []byte(data)
keyByte := []byte(key)
// 创建密码组,长度只能是16、24、32 字节
block, _ := aes.NewCipher(keyByte)
// 获取密钥长度
blockSize := block.BlockSize()
// 补码
originByte = PKCS7Padding(originByte, blockSize)
// 创建保存加密变量
encryptResult := make([]byte, len(originByte))
// CEB是把整个明文分成若干段相同的小段,然后对每一小段进行加密
for bs, be := 0, blockSize; bs < len(originByte); bs, be = bs+blockSize, be+blockSize {
block.Encrypt(encryptResult[bs:be], originByte[bs:be])
}
res := base64.StdEncoding.EncodeToString(encryptResult)
return res
}

// 补码
func PKCS7Padding(originByte []byte, blockSize int) []byte {
// 计算补码长度
padding := blockSize - len(originByte)%blockSize
// 生成补码
padText := bytes.Repeat([]byte{byte(padding)}, padding)
// 追加补码
return append(originByte, padText...)
}

// 解密
func AesDecryptByECB(key, data string) string {
// 判断key长度
keyLenMap := map[int]struct{}{16: {}, 24: {}, 32: {}}
if _, ok := keyLenMap[len(key)]; !ok {
panic("key长度必须是 16、24、32 其中一个")
}
// 反解密码base64
originByte, _ := base64.StdEncoding.DecodeString(data)
// 密钥和待加密数据转成[]byte
keyByte := []byte(key)
// 创建密码组,长度只能是16、24、32字节
block, _ := aes.NewCipher(keyByte)
// 获取密钥长度
blockSize := block.BlockSize()
// 创建保存解密变量
decrypted := make([]byte, len(originByte))
for bs, be := 0, blockSize; bs < len(originByte); bs, be = bs+blockSize, be+blockSize {
block.Decrypt(decrypted[bs:be], originByte[bs:be])
}
// 解码
return string(PKCS7UNPadding(decrypted))
}

// 解码
func PKCS7UNPadding(originDataByte []byte) []byte {
length := len(originDataByte)
unpadding := int(originDataByte[length-1])
return originDataByte[:(length - unpadding)]
}

+ 1
- 1
app/utils/convert.go ファイルの表示

@@ -140,7 +140,7 @@ func AnyToString(raw interface{}) string {
case bool:
return strconv.FormatBool(i)
}
return fmt.Sprintf("%#v", raw)
return fmt.Sprintf("%+v", raw)
}

func AnyToFloat64(raw interface{}) float64 {


+ 43
- 43
consume/init.go ファイルの表示

@@ -17,50 +17,50 @@ func Init() {

// 增加消费任务队列
func initConsumes() {
jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
//jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
//jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
//jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
//jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
//jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
//jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
////
//jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
//jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
//jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
////
//jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
//jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
//
jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
//jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
//jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
//
jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder

jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser

jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume

jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv

jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond

jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore

jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail

jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate

jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
//jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
//jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
//jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
//jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
//
//jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
//jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
//jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
//jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
//jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
//
//jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
//jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
//jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
//jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
//
//jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
//
//jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
//
//jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
//jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
//jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
//
//jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
//jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
//jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward

////////////////////////////////////// V1 /////////////////////////////////////////////////////
//jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
@@ -69,7 +69,7 @@ func initConsumes() {
//jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume

//////////////////////////////////////// V3 /////////////////////////////////////////////////////
//jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume
jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume

}



+ 12
- 1
consume/mall_add_supply_goods.go ファイルの表示

@@ -2,6 +2,7 @@ package consume

import (
svc2 "applet/app/svc"
"applet/app/utils/aes"
"applet/app/utils/logx"
"applet/consume/md"
md3 "applet/mall/md"
@@ -24,6 +25,9 @@ func MallAddSupplyGoodsConsume(queue md.MqQueue) {
return
}
defer ch.Release()

//1、将自己绑定到交换机上
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey)
//2、取出数据进行消费
ch.Qos(1)
delivery := ch.Consume(queue.Name, false)
@@ -47,7 +51,14 @@ func MallAddSupplyGoodsConsume(queue md.MqQueue) {
}

func handleMallAddSupplyGoodsConsume(msgData []byte) error {
var msg map[string]string
err := json.Unmarshal(msgData, &msg)
if err != nil {
panic(err)
}

//解析mq中queue的数据结构体
strs := aes.AesDecryptByECB(aes.AesKey, msg["aes_data"])
var pushStuct struct {
Args struct {
GoodsInfo []*md3.OfficialGoods `json:"goods_info"`
@@ -55,7 +66,7 @@ func handleMallAddSupplyGoodsConsume(msgData []byte) error {
} `json:"args"`
Mid string `json:"mid"`
}
err := json.Unmarshal(msgData, &pushStuct)
err = json.Unmarshal([]byte(strs), &pushStuct)
if err != nil {
panic(err)
}


+ 4
- 2
consume/supply_cloud_chain_fenxiao_new_change.go ファイルの表示

@@ -17,6 +17,7 @@ import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/streadway/amqp"
"strconv"
"strings"
"time"
)
@@ -191,6 +192,8 @@ func handleSupplyCloudChainFenxiaoNewChangeConsume(msgData []byte) error {

utils.FilePutContents("cloudChainGoods", utils.SerializeStr(cloudChainGoods))
for _, id := range ids {
var req md2.AddGoodsReq

if cloudChainGoods[id] == nil {
continue
}
@@ -203,9 +206,8 @@ func handleSupplyCloudChainFenxiaoNewChangeConsume(msgData []byte) error {
continue
}
if getV2 {
continue
req.Base.GoodsId = strconv.FormatInt(goods.GoodsId, 10)
}
var req md2.AddGoodsReq
req.Base.GoodsType = 1
req.Base.CloudChainGoodsId = id
req.Base.SaleState = enum.MallGoodsSaleStateOnShelf


+ 4
- 4
etc/cfg.yml ファイルの表示

@@ -29,10 +29,10 @@ wxapplet_filepath:

# 连接官网数据库获取db mapping
db:
host: 'zhios123.rwlb.rds.aliyuncs.com:3306'
name: 'zyos_website'
user: 'canal'
psw: 'canal'
host: '119.23.182.117:3306'
name: 'zyso_website_back'
user: 'root'
psw: 'Fnuo123com@'
show_log: true
max_lifetime: 30
max_open_conns: 100


読み込み中…
キャンセル
保存