Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

159 linhas
4.3 KiB

  1. <?php
  2. /**
  3. * 数据库表类 fx_commission_info
  4. * ============================================================================
  5. * * 版权所有 蜘蛛出行 * *
  6. * 网站地址: http://www.zhizhuchuxing.com
  7. * ----------------------------------------------------------------------------
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
  9. * 使用;不允许对程序代码以任何形式任何目的的再发布。
  10. * ============================================================================
  11. * Author By: 倪宗锋
  12. * PhpStorm LoginController.php
  13. * Create By 2017/06/15 14:22 $
  14. */
  15. namespace common\models;
  16. use yii\db\ActiveRecord;
  17. use yii\db\Expression;
  18. /**
  19. * 数据库表类 fx_commission_info.
  20. * @property integer $id
  21. * @property integer $fx_uid
  22. * @property integer $total_money
  23. * @property integer $order_id
  24. * @property integer $status
  25. * @property integer $delete_flag
  26. * @property string $create_time
  27. * @property string $update_time
  28. * @property string $update_user
  29. */
  30. class FxCommissionInfo extends ActiveRecord
  31. {
  32. /**
  33. * @inheritdoc
  34. */
  35. public static function tableName()
  36. {
  37. return 'fx_commission_info';
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function rules()
  43. {
  44. return [
  45. [['fx_uid', 'total_money', 'order_id'], 'required'],
  46. [['fx_uid', 'order_id', 'status', 'delete_flag'], 'integer'],
  47. [['total_money'], 'number'],
  48. [['create_time', 'update_time'], 'safe'],
  49. [['update_user'], 'string', 'max' => 50],
  50. ];
  51. }
  52. /**
  53. * @inheritdoc
  54. */
  55. public function attributeLabels()
  56. {
  57. return [
  58. 'id' => 'ID',
  59. 'fx_uid' => 'Fx Uid',
  60. 'total_money' => 'Total Money',
  61. 'order_id' => 'Order ID',
  62. 'status' => 'Status',
  63. 'delete_flag' => 'Delete Flag',
  64. 'create_time' => 'Create Time',
  65. 'update_time' => 'Update Time',
  66. 'update_user' => 'Update User',
  67. ];
  68. }
  69. /**
  70. * Des:插入记录
  71. * Name: add
  72. * @param $fx_uid
  73. * @param $commission
  74. * @param $orderId
  75. * @return bool
  76. * @author 倪宗锋
  77. */
  78. public function add($fx_uid, $commission, $orderId)
  79. {
  80. $commissionArray = [
  81. 'fx_uid' => $fx_uid,
  82. 'total_money' => $commission,
  83. 'order_id' => $orderId,
  84. 'status' => 1,
  85. 'create_time' => date('Y-m-d H:i:s'),
  86. 'update_user' => 'system'
  87. ];
  88. $this->attributes = $commissionArray;
  89. $flag = $this->insert();
  90. return $flag;
  91. }
  92. /**
  93. * Des:根据订单ID获取佣金详细
  94. * Name: getInfoByOrderId
  95. * @param $oder_id
  96. * @return array
  97. * @author 倪宗锋
  98. */
  99. public function getInfoByOrderId($oder_id)
  100. {
  101. $orderInfo = self::find()
  102. ->from(static::tableName())
  103. ->where(['=', 'order_id', $oder_id])
  104. ->asArray()
  105. ->one();
  106. return $orderInfo;
  107. }
  108. /**
  109. * Des:修改单状态
  110. * Name: editStatus
  111. * @param $oder_id
  112. * @param $status
  113. * @return int
  114. * @author 倪宗锋
  115. */
  116. public function editStatus($oder_id, $status)
  117. {
  118. $flag = self::updateAll(['status' => $status], ['=', 'order_id', $oder_id]);
  119. return $flag;
  120. }
  121. /**
  122. * Des:获取发送微信信息
  123. * Name: getSendWxMsg
  124. * @param $order_id
  125. * @return array
  126. * @author 倪宗锋
  127. */
  128. public function getSendWxMsg($order_id)
  129. {
  130. $where = ['=', 'a.order_id', $order_id];
  131. $select = [
  132. 'commission' => 'a.total_money',
  133. 'b.total_money',
  134. 'b.order_name',
  135. 'b.order_status',
  136. 'b.order_id',
  137. 'b.prod_cnt',
  138. 'category_name' => new Expression("(SELECT c.category_name from base_category c WHERE c.category_id = b.category_id)"),
  139. 'open_id' => new Expression("(SELECT d.openid from fx_user d WHERE d.uid = b.fx_uid)")
  140. ];
  141. $getInfo = self::find()->select($select)
  142. ->from(static::tableName() . ' a')
  143. ->innerJoin(OrderMain::tableName() . ' b', 'a.order_id = b.order_id')
  144. ->where($where)
  145. ->asArray()
  146. ->one();
  147. return $getInfo;
  148. }
  149. }